2 * Copyright (c) 1995, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.2 1995-11-01 13:55:06 quinn
10 * Revision 1.1 1995/10/06 08:51:25 quinn
17 * Growing buffer for writing various stuff.
24 WRBUF wrbuf_alloc(void)
28 if (!(n = xmalloc(sizeof(*n))))
36 void wrbuf_free(WRBUF b, int free_buf)
38 if (free_buf && b->buf)
43 void wrbuf_rewind(WRBUF b)
48 int wrbuf_grow(WRBUF b, int minsize)
58 if (b->size && !(b->buf =xrealloc(b->buf, b->size += togrow)))
60 else if (!b->size && !(b->buf = xmalloc(b->size = togrow)))
65 int wrbuf_write(WRBUF b, char *buf, int size)
67 if (b->pos + size >= b->size)
69 memcpy(b->buf + b->pos, buf, size);