* fbmulti is seeked to the beginning, flushed and ready to read the whole buffer.
*
* For performance reasons, use @fbmulti_flatten() only once, just before reading.
+ *
+ * If you want to remove a fastbuf from the chain, just call @fbmulti_remove
+ * where the second parameter is a pointer to the removed fastbuf. If you pass
+ * NULL, all the underlying fastbufs are removed.
***/
struct fastbuf *fbmulti_create(uns bufsize, ...) SENTINEL_CHECK;
void fbmulti_append(struct fastbuf *f, struct fastbuf *fa, int allow_close);
void fbmulti_flatten(struct fastbuf *f);
+void fbmulti_remove(struct fastbuf *f, struct fastbuf *fb);
/*** === Configuring stream parameters [[bconfig]] ***/
CLIST_FOR_EACH(struct subbuf *, n, *(FB_MULTI(f)->subbufs))
{
- ASSERT(n->fb->refill)
+ ASSERT(n->fb->refill);
if (!n->fb->seek)
f->seek = NULL;
sb->fb = fb;
sb->allow_close = allow_close;
clist_add_tail(FB_MULTI(f)->subbufs, &(sb->n));
+ fbmulti_update_capability(f);
+}
+
+void
+fbmulti_remove(struct fastbuf *f, struct fastbuf *fb)
+{
+ if (fb)
+ {
+ CLIST_FOR_EACH(struct subbuf *, n, *(FB_MULTI(f)->subbufs))
+ if (fb == n->fb)
+ {
+ // TODO: fix seek positions
+ clist_remove(&(n->n));
+ fbmulti_update_capability(f);
+ return;
+ }
+
+ die("Given fastbuf %p not in given fbmulti %p.", fb, f);
+ }
+ else
+ clist_init(FB_MULTI(f)->subbufs);
+
+ fbmulti_update_capability(f);
}
static void fbmulti_flatten_internal(struct fastbuf *f, clist *c, int allow_close)