From: Adam Dickmeiss Date: Sat, 19 Apr 2014 09:17:22 +0000 (+0200) Subject: wrbuf_buf: make it always return non-NULL X-Git-Tag: v5.1.1~3 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=f9bc1d0850c92394c8dd3f8d05691e71811baf95;ds=sidebyside wrbuf_buf: make it always return non-NULL Also, wrbuf_buf will return same buffer as previous call to wrbuf_cstr. --- diff --git a/src/wrbuf.c b/src/wrbuf.c index fa42894..6d9b145 100644 --- a/src/wrbuf.c +++ b/src/wrbuf.c @@ -31,6 +31,7 @@ WRBUF wrbuf_alloc(void) n->buf = 0; n->size = 0; n->pos = 0; + wrbuf_grow(n, 1); return n; } @@ -262,9 +263,7 @@ void wrbuf_iconv_reset(WRBUF b, yaz_iconv_t cd) const char *wrbuf_cstr(WRBUF b) { - if (b->pos == 0) - return ""; - assert(b->pos <= b->size); + assert(b && b->pos <= b->size); b->buf[b->pos] = '\0'; return b->buf; }