diff options
| -rw-r--r-- | buffer.c | 7 | ||||
| -rw-r--r-- | buffer.h | 3 |
2 files changed, 10 insertions, 0 deletions
@@ -168,3 +168,10 @@ const char *buffer_content0(Buffer *buf) { return ""; return buf->data; } + +char *buffer_move(Buffer *buf) { + char *data = buf->data; + buffer_clear(buf); + buf->data = NULL; + return data; +} @@ -57,5 +57,8 @@ size_t buffer_capacity(Buffer*); const char *buffer_content0(Buffer*); /* pointer to buffer data, might be NULL if empty, might not be NUL terminated */ const char *buffer_content(Buffer*); +/* steal underlying buffer data, caller is responsible to free(3) it, + * similar to move semantics in some programming languages */ +char *buffer_move(Buffer*); #endif |
