diff options
author | Corentin Chary <corentincj@iksaif.net> | 2010-05-19 09:24:07 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2010-06-01 12:53:09 -0500 |
commit | 5d418e3ba96cfa810e00885a52b55f19cac8f9a6 (patch) | |
tree | a8b0a99dd90b5258930e0e5e22f2f992e5ad08e7 /vnc.c | |
parent | 78c98c78705452e439f5b2ef5447ada23de9988e (diff) |
vnc: add buffer_free()
Add a buffer_free() helper to free vnc buffers and
remove some duplicated code in vnc_disconnect_finish().
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vnc.c')
-rw-r--r-- | vnc.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -508,6 +508,14 @@ void buffer_reset(Buffer *buffer) buffer->offset = 0; } +void buffer_free(Buffer *buffer) +{ + qemu_free(buffer->buffer); + buffer->offset = 0; + buffer->capacity = 0; + buffer->buffer = NULL; +} + void buffer_append(Buffer *buffer, const void *data, size_t len) { memcpy(buffer->buffer + buffer->offset, data, len); @@ -961,14 +969,8 @@ static void vnc_disconnect_finish(VncState *vs) { vnc_qmp_event(vs, QEVENT_VNC_DISCONNECTED); - if (vs->input.buffer) { - qemu_free(vs->input.buffer); - vs->input.buffer = NULL; - } - if (vs->output.buffer) { - qemu_free(vs->output.buffer); - vs->output.buffer = NULL; - } + buffer_free(&vs->input); + buffer_free(&vs->output); qobject_decref(vs->info); |