/*
* UCW Library -- Fast Buffered I/O
*
- * (c) 1997--2007 Martin Mares <mj@ucw.cz>
+ * (c) 1997--2011 Martin Mares <mj@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU Lesser General Public License.
.free = fb_res_free,
};
-void fb_tie(struct fastbuf *f)
+struct fastbuf *fb_tie(struct fastbuf *f)
{
f->res = res_new(&fb_res_class, f);
+ return f;
}
/*
* UCW Library -- Fast Buffered I/O
*
- * (c) 1997--2008 Martin Mares <mj@ucw.cz>
+ * (c) 1997--2011 Martin Mares <mj@ucw.cz>
* (c) 2004 Robert Spalek <robert@ucw.cz>
*
* This software may be freely distributed and used according to the terms
*
* - Initialization:
* * out: `buffer <= bstop <= bptr <= bufend` (flushed).
+ * * @fb_tie() should be called on the newly created fastbuf.
*
* - `refill`:
* * in: `buffer <= bstop <= bptr <= bufend` (reading or flushed).
struct resource *res; /* The fastbuf can be tied to a resource pool */
};
-void fb_tie(struct fastbuf *b); /* Tie fastbuf to a resource if there is an active pool */
+struct fastbuf *fb_tie(struct fastbuf *b); /* Tie fastbuf to a resource if there is an active pool */
/**
* Fastbuf flags
f->name = af->name;
f->spout = fbatomic_spout;
f->close = fbatomic_close;
- fb_tie(f);
- return f;
+ return fb_tie(f);
}
#ifdef TEST
f->close = fbdir_close;
f->config = fbdir_config;
f->can_overwrite_buffer = 2;
- fb_tie(f);
- return f;
+ return fb_tie(f);
}
#ifdef TEST
f->close = bfd_close;
f->config = bfd_config;
f->can_overwrite_buffer = 2;
- fb_tie(f);
- return f;
+ return fb_tie(f);
}
void
b->spout = fbgrow_spout;
b->seek = fbgrow_seek;
b->can_overwrite_buffer = 1;
- fb_tie(b);
- return b;
+ return fb_tie(b);
}
struct fastbuf *fbgrow_create(unsigned basic_size)
f->refill = bfl_refill;
f->close = bfl_close;
f->can_overwrite_buffer = 2;
- fb_tie(f);
- return f;
+ return fb_tie(f);
}
#ifdef TEST
f->name = "<fbmem-write>";
f->spout = fbmem_spout;
f->close = fbmem_close;
- fb_tie(f);
- return f;
+ return fb_tie(f);
}
struct fastbuf *
f->seek = fbmem_seek;
f->close = fbmem_close;
f->can_overwrite_buffer = 1;
- fb_tie(f);
- return f;
+ return fb_tie(f);
}
#ifdef TEST
f->seek = bfmm_seek;
f->close = bfmm_close;
f->config = bfmm_config;
- fb_tie(f);
- return f;
+ return fb_tie(f);
}
#ifdef TEST
f->spout = fbs_spout;
f->close = fbs_close;
f->can_overwrite_buffer = 1;
- fb_tie(f);
- return f;
+ return fb_tie(f);
}
#ifdef TEST