X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Ffb-pool.c;h=e8628dcd9e09bd9c9efd6e4ca09b9fe1b230fc85;hb=117c8e6725fca812c6ef9ebc26d3133f980ecb7e;hp=b55f09038da2d7417de285e5f41bf3694211b73a;hpb=031256ad2e123eec58521f8e3eb9496c197641d2;p=libucw.git diff --git a/ucw/fb-pool.c b/ucw/fb-pool.c index b55f0903..e8628dcd 100644 --- a/ucw/fb-pool.c +++ b/ucw/fb-pool.c @@ -7,24 +7,23 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/mempool.h" -#include "ucw/fastbuf.h" +#include +#include +#include #include #include -#define FB_POOL(f) ((struct fbpool *)(f)->is_fastbuf) +#define FB_POOL(f) ((struct fbpool *)(f)) static void fbpool_spout(struct fastbuf *b) { - if (b->bptr >= b->bufend) + if (b->bptr == b->bufend) { uns len = b->bufend - b->buffer; - b->buffer = mp_expand(FB_POOL(b)->mp); + b->bstop = b->buffer = mp_expand(FB_POOL(b)->mp); b->bufend = b->buffer + mp_avail(FB_POOL(b)->mp); - b->bstop = b->buffer; b->bptr = b->buffer + len; } } @@ -40,7 +39,7 @@ fbpool_start(struct fbpool *b, struct mempool *mp, uns init_size) void * fbpool_end(struct fbpool *b) { - return mp_end(b->mp, b->fb.bptr); + return mp_end(b->mp, b->fb.bptr); } void @@ -60,7 +59,7 @@ int main(void) struct fbpool fb; byte *p; uns l; - + mp = mp_new(64); fbpool_init(&fb); fbpool_start(&fb, mp, 16); @@ -74,7 +73,7 @@ int main(void) if (memcmp(p + i * 7, "", 7)) ASSERT(0); mp_delete(mp); - + return 0; }