* of the GNU Lesser General Public License.
*/
-#include "ucw/lib.h"
-#include "ucw/fastbuf.h"
-#include "ucw/mempool.h"
+#include <ucw/lib.h>
+#include <ucw/fastbuf.h>
+#include <ucw/mempool.h>
#include <stdio.h>
#include <stdlib.h>
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)
{
{
if (b->bptr == b->bufend)
{
- uns len = b->bufend - b->buffer;
+ uint len = b->bufend - b->buffer;
if (FB_GBUF(b)->mp)
{
byte *old = b->buffer;
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;
xfree(b);
}
-struct fastbuf *fbgrow_create_mp(struct mempool *mp, unsigned basic_size)
+struct fastbuf *fbgrow_create_mp(struct mempool *mp, uint basic_size)
{
ASSERT(basic_size);
struct fastbuf *b;
}
b->bufend = b->buffer + basic_size;
b->bptr = b->bstop = b->buffer;
+ FB_GBUF(b)->end = b->buffer;
b->name = "<fbgbuf>";
b->refill = fbgrow_refill;
b->spout = fbgrow_spout;
b->seek = fbgrow_seek;
b->can_overwrite_buffer = 1;
- return fb_tie(b);
+ return b;
}
-struct fastbuf *fbgrow_create(unsigned basic_size)
+struct fastbuf *fbgrow_create(uint basic_size)
{
return fbgrow_create_mp(NULL, basic_size);
}
brewind(b);
}
-uns fbgrow_get_buf(struct fastbuf *b, byte **buf)
+uint fbgrow_get_buf(struct fastbuf *b, byte **buf)
{
byte *end = FB_GBUF(b)->end;
end = MAX(end, b->bptr);
int main(void)
{
struct fastbuf *f;
- uns t;
+ uint t;
f = fbgrow_create(3);
- for (uns i=0; i<5; i++)
+ for (uint i=0; i<5; i++)
{
fbgrow_reset(f);
bwrite(f, "12345", 5);