From 657224ea37d96c5a0c6a33354e83a79309ccff3b Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Wed, 13 Nov 2013 23:34:46 +0100 Subject: [PATCH 31/39] chardev: drop the Memory chardev driver RH-Author: Laszlo Ersek Message-id: <1384385687-11423-5-git-send-email-lersek@redhat.com> Patchwork-id: 55675 O-Subject: [RHEL-6.6 qemu-kvm PATCH 4/5] chardev: drop the Memory chardev driver Bugzilla: 1026903 RH-Acked-by: Markus Armbruster RH-Acked-by: Luiz Capitulino RH-Acked-by: Jeffrey Cody From: Luiz Capitulino It's not used anymore since the last commit. Signed-off-by: Luiz Capitulino Reviewed-by: Eric Blake Acked-by: Gerd Hoffmann (cherry picked from commit 4bf0bb8014ac2ac61b1004f5d92b2a4594d48017) Conflicts: qemu-char.c (upstream patch removes g_*() memory management calls, downstream removes qemu_*() counterparts) Signed-off-by: Laszlo Ersek --- qemu-char.c | 64 ------------------------------------------------------------- 1 file changed, 64 deletions(-) Signed-off-by: Miroslav Rezanina --- qemu-char.c | 64 ----------------------------------------------------------- 1 files changed, 0 insertions(+), 64 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 2f6e914..fe7708c 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2531,70 +2531,6 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) return NULL; } -/***********************************************************/ -/* Memory chardev */ -typedef struct { - size_t outbuf_size; - size_t outbuf_capacity; - uint8_t *outbuf; -} MemoryDriver; - -static int mem_chr_write(CharDriverState *chr, const uint8_t *buf, int len) -{ - MemoryDriver *d = chr->opaque; - - /* TODO: the QString implementation has the same code, we should - * introduce a generic way to do this in cutils.c */ - if (d->outbuf_capacity < d->outbuf_size + len) { - /* grow outbuf */ - d->outbuf_capacity += len; - d->outbuf_capacity *= 2; - d->outbuf = qemu_realloc(d->outbuf, d->outbuf_capacity); - } - - memcpy(d->outbuf + d->outbuf_size, buf, len); - d->outbuf_size += len; - - return len; -} - -void qemu_chr_init_mem(CharDriverState *chr) -{ - MemoryDriver *d; - - d = qemu_malloc(sizeof(*d)); - d->outbuf_size = 0; - d->outbuf_capacity = 4096; - d->outbuf = qemu_mallocz(d->outbuf_capacity); - - memset(chr, 0, sizeof(*chr)); - chr->opaque = d; - chr->chr_write = mem_chr_write; -} - -QString *qemu_chr_mem_to_qs(CharDriverState *chr) -{ - MemoryDriver *d = chr->opaque; - return qstring_from_substr((char *) d->outbuf, 0, d->outbuf_size - 1); -} - -/* NOTE: this driver can not be closed with qemu_chr_delete()! */ -void qemu_chr_close_mem(CharDriverState *chr) -{ - MemoryDriver *d = chr->opaque; - - qemu_free(d->outbuf); - qemu_free(chr->opaque); - chr->opaque = NULL; - chr->chr_write = NULL; -} - -size_t qemu_chr_mem_osize(const CharDriverState *chr) -{ - const MemoryDriver *d = chr->opaque; - return d->outbuf_size; -} - QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename) { char host[65], port[33], width[8], height[8]; -- 1.7.1