X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Ffastbuf.h;h=4f0d99d3190be67c6fad8ae22e4e11a46760167d;hb=92b3bd34e6024ec20c67e3c1285f3a442fe6f326;hp=0c0ea427ad0c04adc1d7d498fe6b3772713a599c;hpb=17129a2f190d006f88fb3bc92aafb61f31e164d8;p=libucw.git diff --git a/ucw/fastbuf.h b/ucw/fastbuf.h index 0c0ea427..4f0d99d3 100644 --- a/ucw/fastbuf.h +++ b/ucw/fastbuf.h @@ -491,40 +491,34 @@ static inline void fbatomic_commit(struct fastbuf *b) * You aren't allowed to do anything with the underlying buffers while these * are connected into fbmulti. * - * You may init a fbmulti by @fbmulti_create(bufsize, fb1, fb2, ..., NULL). - * This call returns a fastbuf that concatenates all the given fastbufs. - * The last parameter of @fbmulti_create must be NULL. + * The fbmulti is inited by @fbmulti_create(). It returns an empty fbmulti. + * Then you call @fbmulti_append() for each fbmulti. * - * By default, if @bclose() is called on fbmulti, all the underlying buffers - * get closed recursively. + * If @bclose() is called on fbmulti, all the underlying buffers get closed + * recursively. * - * You may init a fbmulti by @fbmulti_create(bufsize) with no underlying buffers - * and then append the underlying buffers one by one. If allow_close is set to 0, - * the fastbuf doesn't get closed at @bclose() and you have to do the cleanup on - * yourself. + * If you want to keep an underlying fastbuf open after @bclose, just remove it + * by @fbmulti_remove where the second parameter is a pointer to the removed + * fastbuf. If you pass NULL, all the underlying fastbufs are removed. * - * If used in some formatter, you'll probably have a large and deep structure - * of nested fastbufs. Just before reading from the fbmulti, you may call - * @fbmulti_flatten() to flatten the structure. After @fbmulti_flatten(), the - * 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. - * - * When a fastbuf is removed from the chain, the overall position may change: - * If bstop pointed into it, after removal it points to the boundary of the - * previous and next fastbufs. Length of the removed fastbuf is subtracted from - * the overall offset of all the fastbufs after the removed fb in the chain. + * After @fbmulti_remove, the state of the fbmulti is undefined. The only allowed + * operation is either another @fbmulti_remove or @bclose on the fbmulti. ***/ -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); +/** + * Create an empty fbmulti + **/ +struct fastbuf *fbmulti_create(void); +/** + * Append a fb to fbmulti + **/ +void fbmulti_append(struct fastbuf *f, struct fastbuf *fb); + +/** + * Remove a fb from fbmulti + **/ +void fbmulti_remove(struct fastbuf *f, struct fastbuf *fb); /*** === Configuring stream parameters [[bconfig]] ***/