X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Ffb-grow.c;h=0898a1a4be68b6128796bdc866f0598f77024942;hb=06cac26f0d8895b5cb8fbe03ca96444dc4ac8d51;hp=27b5bf038b0a8329b8e9ca3e939b838a4762d7c4;hpb=f20ecabf44f24743a1383f2ae2148adb660aa8f5;p=libucw.git diff --git a/ucw/fb-grow.c b/ucw/fb-grow.c index 27b5bf03..0898a1a4 100644 --- a/ucw/fb-grow.c +++ b/ucw/fb-grow.c @@ -7,9 +7,9 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/fastbuf.h" -#include "ucw/mempool.h" +#include +#include +#include #include #include @@ -19,7 +19,7 @@ struct fb_gbuf { struct mempool *mp; byte *end; }; -#define FB_GBUF(f) ((struct fb_gbuf *)(f)->is_fastbuf) +#define FB_GBUF(f) ((struct fb_gbuf *)(f)) static int fbgrow_refill(struct fastbuf *b) { @@ -56,7 +56,7 @@ static int fbgrow_seek(struct fastbuf *b, ucw_off_t pos, int whence) if (whence == SEEK_END) pos += len; if (pos < 0 || pos > len) - bthrow(b, "fb.seek", "Seek out of range"); + bthrow(b, "seek", "Seek out of range"); b->bptr = b->buffer + pos; b->bstop = b->buffer; b->pos = 0; @@ -92,7 +92,6 @@ struct fastbuf *fbgrow_create_mp(struct mempool *mp, unsigned basic_size) b->spout = fbgrow_spout; b->seek = fbgrow_seek; b->can_overwrite_buffer = 1; - fb_tie(b); return b; } @@ -112,6 +111,15 @@ void fbgrow_rewind(struct fastbuf *b) brewind(b); } +uns fbgrow_get_buf(struct fastbuf *b, byte **buf) +{ + byte *end = FB_GBUF(b)->end; + end = MAX(end, b->bptr); + if (buf) + *buf = b->buffer; + return end - b->buffer; +} + #ifdef TEST int main(void)