4 It is quite usual situation when you need an array of items and you
5 don not know how large it will be in the time you allocate it. Then
6 you need some kind of dynamically growing buffer.
8 You can either use <<mempool:gbuf,mempools>>, which has similar
9 functionality, or this module.
11 - <<gbuf,Generic growing buffers>>
12 - <<bbuf,Growing buffers for byte-sized items>>
15 Generic growing buffers
16 -----------------------
18 The generic buffers are in `ucw/gbuf.h`. They are <<generic:,generics
19 generated by preprocessor>>. To use them, you need to define:
21 - `GBUF_PREFIX(name)` -- the identifier generating macro.
22 - `GBUF_TYPE` -- the data type they operate with.
24 You may define `GBUF_TRACE(\...)` macro. If you do, it will be used to
25 log the growing of the buffer. The macro should act like printf() --
26 the first parameter will be format, the rest variables for it.
28 !!ucw/gbuf.h GBUF_PREFIX
31 Growing buffers for byte-sized items
32 ------------------------------------
34 It is often needed to allocate the buffer by bytes (if you handle some
35 anonymous data) or characters (strings of unknown length).
37 With the `ucw/bbuf.h` header, you get an instance of growing buffers
38 with type `byte` and prefix `bb_`. Aside from that, you get few
39 functions to manipulate strings in the buffers.