2 * A simple growing buffer
4 * (c) 2004, Robert Spalek <robert@ucw.cz>
6 * Define the following macros:
8 * GBUF_TYPE data type of records stored in the buffer
9 * GBUF_PREFIX(x) add a name prefix to all global symbols
14 #define BUF_T GBUF_PREFIX(t)
24 GBUF_PREFIX(init)(BUF_T *b)
31 GBUF_PREFIX(done)(BUF_T *b)
40 GBUF_PREFIX(realloc)(BUF_T *b, uns len)
43 b->ptr = xrealloc(b->ptr, len * sizeof(GBUF_TYPE));
47 GBUF_PREFIX(grow)(BUF_T *b, uns len)
51 if (len < 2*b->len) // to ensure logarithmic cost
53 GBUF_PREFIX(realloc)(b, len);