- clist_init(FB_MULTI(f)->subbufs);
-
- fbmulti_update_capability(f);
-}
-
-static void fbmulti_flatten_internal(struct fastbuf *f, clist *c, int allow_close)
-{
- CLIST_FOR_EACH(struct subbuf *, n, *c)
- {
- if (strcmp(n->fb->name, FB_MULTI_NAME))
- fbmulti_append(f, n->fb, n->allow_close && allow_close);
-
- else
- {
- fbmulti_flatten_internal(f, FB_MULTI(n->fb)->subbufs, allow_close && n->allow_close);
- if (allow_close && n->allow_close)
- {
- FB_MULTI(n->fb)->subbufs = mp_alloc(FB_MULTI(n->fb)->mp, sizeof(clist));
- clist_init(FB_MULTI(n->fb)->subbufs);
- bclose(n->fb);
- }
- }
- }
-}
-
-void
-fbmulti_flatten(struct fastbuf *f)
-{
- if (strcmp(f->name, FB_MULTI_NAME))
- {
- DBG("fbmulti: given fastbuf isn't fbmulti");
- return;
- }
-
- clist *c = FB_MULTI(f)->subbufs;
- FB_MULTI(f)->subbufs = mp_alloc(FB_MULTI(f)->mp, sizeof(clist));
- clist_init(FB_MULTI(f)->subbufs);
-
- fbmulti_flatten_internal(f, c, 1);
- FB_MULTI(f)->cur = clist_head(FB_MULTI(f)->subbufs);
- f->bptr = f->bstop = f->buffer;
- f->pos = 0;