2 * Copyright (c) 1995, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.4 1998-02-11 11:53:36 adam
8 * Changed code so that it compiles as C++.
10 * Revision 1.3 1997/05/01 15:08:15 adam
11 * Added log_mask_str_x routine.
13 * Revision 1.2 1995/11/01 13:55:06 quinn
16 * Revision 1.1 1995/10/06 08:51:25 quinn
23 * Growing buffer for writing various stuff.
31 WRBUF wrbuf_alloc(void)
35 if (!(n = (WRBUF)xmalloc(sizeof(*n))))
43 void wrbuf_free(WRBUF b, int free_buf)
45 if (free_buf && b->buf)
50 void wrbuf_rewind(WRBUF b)
55 int wrbuf_grow(WRBUF b, int minsize)
65 if (b->size && !(b->buf =(char *)xrealloc(b->buf, b->size += togrow)))
67 else if (!b->size && !(b->buf = (char *)xmalloc(b->size = togrow)))
72 int wrbuf_write(WRBUF b, char *buf, int size)
74 if (b->pos + size >= b->size)
76 memcpy(b->buf + b->pos, buf, size);