diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2015-10-30 12:09:57 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2015-11-05 09:08:33 +0100 |
commit | 810082d15c244b8b29470d3bb1c6b11fc9a40c25 (patch) | |
tree | d8ef9bcb6797c108a9479fe08a84d8462ae9d07f /util/buffer.c | |
parent | 5c10dbb7b577370e86ff459973b06d530c3777cf (diff) | |
download | qemu-810082d15c244b8b29470d3bb1c6b11fc9a40c25.zip qemu-810082d15c244b8b29470d3bb1c6b11fc9a40c25.tar.gz qemu-810082d15c244b8b29470d3bb1c6b11fc9a40c25.tar.bz2 |
buffer: add buffer_init
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1446203414-4013-3-git-send-email-kraxel@redhat.com
Diffstat (limited to 'util/buffer.c')
-rw-r--r-- | util/buffer.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/util/buffer.c b/util/buffer.c index 7ddd693..12bf2d7 100644 --- a/util/buffer.c +++ b/util/buffer.c @@ -22,6 +22,15 @@ #define BUFFER_MIN_INIT_SIZE 4096 +void buffer_init(Buffer *buffer, const char *name, ...) +{ + va_list ap; + + va_start(ap, name); + buffer->name = g_strdup_vprintf(name, ap); + va_end(ap); +} + void buffer_reserve(Buffer *buffer, size_t len) { if ((buffer->capacity - buffer->offset) < len) { @@ -49,9 +58,11 @@ void buffer_reset(Buffer *buffer) void buffer_free(Buffer *buffer) { g_free(buffer->buffer); + g_free(buffer->name); buffer->offset = 0; buffer->capacity = 0; buffer->buffer = NULL; + buffer->name = NULL; } void buffer_append(Buffer *buffer, const void *data, size_t len) |