diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/buffer.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/util/buffer.c b/util/buffer.c index c7a39ec5da..e8f798e620 100644 --- a/util/buffer.c +++ b/util/buffer.c @@ -91,3 +91,19 @@ void buffer_move_empty(Buffer *to, Buffer *from) from->capacity = 0; from->buffer = NULL; } + +void buffer_move(Buffer *to, Buffer *from) +{ + if (to->offset == 0) { + buffer_move_empty(to, from); + return; + } + + buffer_reserve(to, from->offset); + buffer_append(to, from->buffer, from->offset); + + g_free(from->buffer); + from->offset = 0; + from->capacity = 0; + from->buffer = NULL; +} |