]> mj.ucw.cz Git - libucw.git/blob - ucw/doc/growbuf.txt
Redblack: Added search_up
[libucw.git] / ucw / doc / growbuf.txt
1 Growing buffers
2 ===============
3
4 *This module is obsolete. Please use <<gary:,growing arrays>> instead.*
5
6 It is quite usual situation when you need an array of items and you
7 don not know how large it will be in the time you allocate it. Then
8 you need some kind of dynamically growing buffer.
9
10 - <<gbuf,Generic growing buffers>>
11 - <<bbuf,Growing buffers for byte-sized items>>
12
13 [[gbuf]]
14 Generic growing buffers
15 -----------------------
16
17 The generic buffers are in `ucw/gbuf.h`. They are <<generic:,generics
18 generated by preprocessor>>. To use them, you need to define:
19
20 - `GBUF_PREFIX(name)` -- the identifier generating macro.
21 - `GBUF_TYPE` -- the data type they operate with.
22
23 You may define `GBUF_TRACE(\...)` macro. If you do, it will be used to
24 log the growing of the buffer. The macro should act like printf() --
25 the first parameter will be format, the rest variables for it.
26
27 !!ucw/gbuf.h GBUF_PREFIX
28
29 [[bbuf]]
30 Growing buffers for byte-sized items
31 ------------------------------------
32
33 It is often needed to allocate the buffer by bytes (if you handle some
34 anonymous data) or characters (strings of unknown length).
35
36 With the `ucw/bbuf.h` header, you get an instance of growing buffers
37 with type `byte` and prefix `bb_`. Aside from that, you get few
38 functions to manipulate strings in the buffers.
39
40 !!ucw/bbuf.h