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.0.24~1 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=4abfaced88baccb1cb16a1c77002c1a606a9c425;p=yaz-moved-to-github.git 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 21401c7..69586e0 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; }