2 * Copyright (c) 1995, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1995-10-06 08:51:25 quinn
14 * Growing buffer for writing various stuff.
21 WRBUF wrbuf_alloc(void)
25 if (!(n = malloc(sizeof(*n))))
33 void wrbuf_free(WRBUF b, int free_buf)
35 if (free_buf && b->buf)
40 void wrbuf_rewind(WRBUF b)
45 int wrbuf_grow(WRBUF b, int minsize)
55 if (b->size && !(b->buf = realloc(b->buf, b->size += togrow)))
57 else if (!b->size && !(b->buf = malloc(b->size = togrow)))
62 int wrbuf_write(WRBUF b, char *buf, int size)
64 if (b->pos + size >= b->size)
66 memcpy(b->buf + b->pos, buf, size);