2 * Copyright (c) 1995-1999, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.5 1999-08-27 09:40:32 adam
8 * Renamed logf function to yaz_log. Removed VC++ project files.
10 * Revision 1.4 1998/02/11 11:53:36 adam
11 * Changed code so that it compiles as C++.
13 * Revision 1.3 1997/05/01 15:08:15 adam
14 * Added log_mask_str_x routine.
16 * Revision 1.2 1995/11/01 13:55:06 quinn
19 * Revision 1.1 1995/10/06 08:51:25 quinn
26 * Growing buffer for writing various stuff.
34 WRBUF wrbuf_alloc(void)
38 if (!(n = (WRBUF)xmalloc(sizeof(*n))))
46 void wrbuf_free(WRBUF b, int free_buf)
48 if (free_buf && b->buf)
53 void wrbuf_rewind(WRBUF b)
58 int wrbuf_grow(WRBUF b, int minsize)
68 if (b->size && !(b->buf =(char *)xrealloc(b->buf, b->size += togrow)))
70 else if (!b->size && !(b->buf = (char *)xmalloc(b->size = togrow)))
75 int wrbuf_write(WRBUF b, const char *buf, int size)
77 if (b->pos + size >= b->size)
79 memcpy(b->buf + b->pos, buf, size);