X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=include%2Fyaz%2Fwrbuf.h;h=f5ebf1df84e762af2cf56e34fb0d6a61c8fd541f;hp=e7629d063c52e3d32a373206719c3253abd7a9e4;hb=a6b61b9f8b6576e8159a4e7e6aee88bba7e5d07d;hpb=053367cbe356fb3ce0def34b065dae589d700daf diff --git a/include/yaz/wrbuf.h b/include/yaz/wrbuf.h index e7629d0..f5ebf1d 100644 --- a/include/yaz/wrbuf.h +++ b/include/yaz/wrbuf.h @@ -242,14 +242,23 @@ YAZ_EXPORT int wrbuf_grow(WRBUF b, size_t minsize); #define wrbuf_buf(b) ((b)->buf) /** \brief returns WRBUF content as C-string - \param b WRBUF + \param b WRBUF (may not be NULL) \returns C-string */ YAZ_EXPORT const char *wrbuf_cstr(WRBUF b); +/** \brief returns WRBUF content as C-string or NULL + \param b WRBUF + \returns C-string or NULL + + This function returns NULL if either b is NULL or length of buffer is 0 +*/ +YAZ_EXPORT +const char *wrbuf_cstr_null(WRBUF b); + #define wrbuf_putc(b, c) \ ((void) ((b)->pos >= (b)->size ? wrbuf_grow(b, 1) : 0), \ - (b)->buf[(b)->pos++] = (c), 0) + (b)->buf[(b)->pos++] = (c)) /** \brief writes JSON text to WRBUF with escaping