summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/buffer.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/util/buffer.c b/util/buffer.c
index c7a39ec..e8f798e 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;
+}
OpenPOWER on IntegriCloud