Wed, 09 May 2018 15:04:15 +0200
adds ucx_buffer_to_sstr() macro
src/ucx/buffer.h | file | annotate | diff | comparison | revisions |
--- a/src/ucx/buffer.h Thu May 03 10:44:33 2018 +0200 +++ b/src/ucx/buffer.h Wed May 09 15:04:15 2018 +0200 @@ -165,8 +165,8 @@ * * @param buffer the buffer to be cleared */ -#define ucx_buffer_clear(buffer) memset(buffer->space, 0, buffer->size); \ - buffer->size = 0; buffer->pos = 0; +#define ucx_buffer_clear(buffer) memset((buffer)->space, 0, (buffer)->size); \ + (buffer)->size = 0; (buffer)->pos = 0; /** * Tests, if the buffer position has exceeded the buffer capacity. @@ -262,6 +262,14 @@ */ size_t ucx_buffer_puts(UcxBuffer *buffer, char *str); +/** + * Returns the complete buffer content as sstr_t. + * @param buffer the buffer + * @return the result of <code>sstrn()</code> with the buffer space and size + * as arguments + */ +#define ucx_buffer_to_sstr(buffer) sstrn((buffer)->space, (buffer)->size) + #ifdef __cplusplus } #endif