summary refs log tree commit diff stats
path: root/util/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/buffer.c')
-rw-r--r--util/buffer.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/util/buffer.c b/util/buffer.c
index 12bf2d788b..c7a39ec5da 100644
--- a/util/buffer.c
+++ b/util/buffer.c
@@ -77,3 +77,17 @@ void buffer_advance(Buffer *buffer, size_t len)
             (buffer->offset - len));
     buffer->offset -= len;
 }
+
+void buffer_move_empty(Buffer *to, Buffer *from)
+{
+    assert(to->offset == 0);
+
+    g_free(to->buffer);
+    to->offset = from->offset;
+    to->capacity = from->capacity;
+    to->buffer = from->buffer;
+
+    from->offset = 0;
+    from->capacity = 0;
+    from->buffer = NULL;
+}