diff options
| -rw-r--r-- | buffer.c | 6 | ||||
| -rw-r--r-- | buffer.h | 2 |
2 files changed, 8 insertions, 0 deletions
@@ -52,3 +52,9 @@ bool buffer_append(Buffer *buf, const void *data, size_t len) { buf->len += len; return true; } + +bool buffer_append0(Buffer *buf, const char *data) { + if (buf->len > 0 && buf->data[buf->len-1] == '\0') + buf->len--; + return buffer_append(buf, data, strlen(data)) && buffer_append(buf, "\0", 1); +} @@ -23,5 +23,7 @@ void buffer_truncate(Buffer*); bool buffer_put(Buffer*, const void *data, size_t len); /* append futher content to the end of the buffer data */ bool buffer_append(Buffer*, const void *data, size_t len); +/* append NUl-terminated data */ +bool buffer_append0(Buffer*, const char *data); #endif |
