#include "lib/lib.h"
#include "lib/fastbuf.h"
+#include <stdio.h>
#include <stdlib.h>
struct fb_gbuf {
}
}
-static void
+static int
fbgrow_seek(struct fastbuf *b, sh_off_t pos, int whence)
{
ASSERT(FB_GBUF(b)->last_written); /* Seeks allowed only in read mode */
b->bptr = b->buffer + pos;
b->bstop = FB_GBUF(b)->last_written;
b->pos = len;
+ return 1;
}
static void
int main(void)
{
struct fastbuf *f;
- int t;
+ uns t;
f = fbgrow_create(3);
for (uns i=0; i<5; i++)
{
- fbgrow_write(f);
+ fbgrow_reset(f);
bwrite(f, "12345", 5);
bwrite(f, "12345", 5);
printf("<%d>", (int)btell(f));
printf("<%d>", (int)btell(f));
fbgrow_rewind(f);
printf("<%d>", (int)btell(f));
- while ((t = bgetc(f)) >= 0)
+ while ((t = bgetc(f)) != ~0U)
putchar(t);
printf("<%d>", (int)btell(f));
fbgrow_rewind(f);
bseek(f, -1, SEEK_END);
printf("<%d>", (int)btell(f));
- while ((t = bgetc(f)) >= 0)
+ while ((t = bgetc(f)) != ~0U)
putchar(t);
printf("<%d>\n", (int)btell(f));
}