X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=util%2Fwrbuf.c;h=4cfc8d8244f7357dbf4f86a26736516d5012f258;hp=446b6d5d4f9f56d545c0d5776ffcbc4458eec9ec;hb=b440dce0831a72bebe4f4821ab7771cc05e8facb;hpb=b22117b182e372c6d1adc77c7da6a1de508e8594 diff --git a/util/wrbuf.c b/util/wrbuf.c index 446b6d5..4cfc8d8 100644 --- a/util/wrbuf.c +++ b/util/wrbuf.c @@ -1,10 +1,22 @@ /* - * Copyright (c) 1995, Index Data. + * Copyright (c) 1995-1999, Index Data. * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * $Log: wrbuf.c,v $ - * Revision 1.1 1995-10-06 08:51:25 quinn + * Revision 1.5 1999-08-27 09:40:32 adam + * Renamed logf function to yaz_log. Removed VC++ project files. + * + * Revision 1.4 1998/02/11 11:53:36 adam + * Changed code so that it compiles as C++. + * + * Revision 1.3 1997/05/01 15:08:15 adam + * Added log_mask_str_x routine. + * + * Revision 1.2 1995/11/01 13:55:06 quinn + * Minor adjustments + * + * Revision 1.1 1995/10/06 08:51:25 quinn * Added Write-buffer. * * @@ -15,6 +27,7 @@ */ #include +#include #include @@ -22,7 +35,7 @@ WRBUF wrbuf_alloc(void) { WRBUF n; - if (!(n = malloc(sizeof(*n)))) + if (!(n = (WRBUF)xmalloc(sizeof(*n)))) abort(); n->buf = 0; n->size = 0; @@ -33,8 +46,8 @@ WRBUF wrbuf_alloc(void) void wrbuf_free(WRBUF b, int free_buf) { if (free_buf && b->buf) - free(b->buf); - free(b); + xfree(b->buf); + xfree(b); } void wrbuf_rewind(WRBUF b) @@ -52,14 +65,14 @@ int wrbuf_grow(WRBUF b, int minsize) togrow = b->size; if (togrow < minsize) togrow = minsize; - if (b->size && !(b->buf = realloc(b->buf, b->size += togrow))) + if (b->size && !(b->buf =(char *)xrealloc(b->buf, b->size += togrow))) abort(); - else if (!b->size && !(b->buf = malloc(b->size = togrow))) + else if (!b->size && !(b->buf = (char *)xmalloc(b->size = togrow))) abort(); return 0; } -int wrbuf_write(WRBUF b, char *buf, int size) +int wrbuf_write(WRBUF b, const char *buf, int size) { if (b->pos + size >= b->size) wrbuf_grow(b, size);