OSSP CVS Repository

ossp - Difference in ossp-pkg/sio/al.c versions 1.32 and 1.33
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

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