diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2015-10-30 12:09:58 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2015-11-05 09:08:36 +0100 |
commit | 4d1eb5fdb141c9100eb82e1dc7d4547fb1decd8b (patch) | |
tree | f226b0238319ab57fb4f6889682ffb5dce5a3e22 /util | |
parent | 810082d15c244b8b29470d3bb1c6b11fc9a40c25 (diff) |
buffer: add buffer_move_empty
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Daniel Berrange <berrange@redhat.com>
Message-id: 1446203414-4013-4-git-send-email-kraxel@redhat.com
Diffstat (limited to 'util')
-rw-r--r-- | util/buffer.c | 14 |
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; +} |