if (!next)
return 0;
- // Get the end of current buf if not known yet.
+ // Get the end of current buf if not known yet
if (!f->seek && !next->begin)
- next->begin = FB_MULTI(f)->cur->end = f->pos;
+ next->begin = cur->end = f->pos;
// Set the beginning of the next buf
if (next->fb->seek)
bthrow(f, "seek", "Seek out of range");
while (pos > FB_MULTI(f)->cur->end) // Moving forward
- ASSERT(fbmulti_subbuf_next(f));
+ {
+ int r = fbmulti_subbuf_next(f);
+ ASSERT(r);
+ }
while (pos < FB_MULTI(f)->cur->begin) // Moving backwards
- ASSERT(fbmulti_subbuf_prev(f));
+ {
+ int r = fbmulti_subbuf_prev(f);
+ ASSERT(r);
+ }
// Now cur is the right buffer.
FB_MULTI(f)->cur->fb->seek(FB_MULTI(f)->cur->fb, (pos - FB_MULTI(f)->cur->begin), SEEK_SET);
fbmulti_get_ptrs(f);
return 1;
- break;
case SEEK_END:
- return fbmulti_seek(f, FB_MULTI(f)->len+pos, SEEK_SET);
- break;
+ return fbmulti_seek(f, FB_MULTI(f)->len + pos, SEEK_SET);
default:
ASSERT(0);
struct fastbuf *
fbmulti_create(void)
{
- struct mempool *mp = mp_new(128);
+ struct mempool *mp = mp_new(1024);
struct fastbuf *fb_out = mp_alloc(mp, sizeof(struct fb_multi));
struct fb_multi *fbm = FB_MULTI(fb_out);
{
struct subbuf *last = clist_tail(&FB_MULTI(f)->subbufs);
- struct subbuf *sb = mp_alloc(FB_MULTI(f)->mp, sizeof(struct subbuf));
+ struct subbuf *sb = mp_alloc(FB_MULTI(f)->mp, sizeof(*sb));
sb->fb = fb;
clist_add_tail(&FB_MULTI(f)->subbufs, &(sb->n));
{
clist_remove(&(n->n));
return;
- };
+ }
- die("Given fastbuf %p not in given fbmulti %p.", fb, f);
+ die("Given fastbuf %p not in given fbmulti %p", fb, f);
}
else
clist_init(&FB_MULTI(f)->subbufs);
{
if (argc < 2)
{
- fprintf(stderr, "You must specify a test (r, w, o)\n");
+ fprintf(stderr, "You must specify a test (r, m, i, n)\n");
return 1;
}
switch (*argv[1])