OSSP CVS Repository

ossp - Check-in [2727]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2727
Date: 2002-Nov-04 14:14:50 (local)
2002-Nov-04 13:14:50 (UTC)
User:mlelstv
Branch:
Comment: prepending to a zero length chunk is now possible, the chunk is aligned to the end of the buffer

PR: Submitted by: Reviewed by: Approved by: Obtained from:

Tickets:
Inspections:
Files:
ossp-pkg/sio/al.c      1.32 -> 1.33     15 inserted, 3 deleted

ossp-pkg/sio/al.c 1.32 -> 1.33

--- al.c 2002/10/25 13:29:02     1.32
+++ al.c 2002/11/04 13:14:50     1.33
@@ -137,17 +137,29 @@
  * number of bytes a chunk can be grown to the beginning
  * we must not grow a chunk in a shared buffer since
  * we do not track other chunks sharing the buffer
+ *
+ * empty chunks can be aligned with end
  */
 #define AL_CHUNK_PRESERVE(alc,label) \
     ( (alc) != NULL \
      ? (  (alc)->buf->usecount > 1 || !AL_SAME_LABEL(alc,label) \
         ? 0 \
-        : (alc)->begin) \
+        : (alc)->end <= (alc)->begin ? \
+          (alc)->buf->size \
+          : (alc)->begin) \
      : 0)
 
-/* grow chunk to the beginning */
+/*
+ * grow chunk to the beginning
+ *
+ * empty chunks can be aligned with end
+ */
 #define AL_PRESIZE(al, alc, n) \
-    do { (alc)->begin -= n; (al)->bytes += (n); } while (0)
+    do { \
+        if ((alc)->end <= (alc)->begin) \
+            (alc)->end = (alc)->begin = (alc)->buf->size; \
+        (alc)->begin -= n; (al)->bytes += (n); \
+    } while (0)
 
 /*
  * callback to release buffer memory allocated by the library

CVSTrac 2.0.1