Index: ossp-pkg/sio/al.c RCS File: /v/ossp/cvs/ossp-pkg/sio/Attic/al.c,v rcsdiff -q -kk '-r1.32' '-r1.33' -u '/v/ossp/cvs/ossp-pkg/sio/Attic/al.c,v' 2>/dev/null --- 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