qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dave Airlie <airlied@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] virtio-gpu: use glib alloc/free routines
Date: Tue, 10 Dec 2013 14:57:20 +1000	[thread overview]
Message-ID: <1386651440-9218-1-git-send-email-airlied@gmail.com> (raw)

From: Dave Airlie <airlied@redhat.com>

Oh I forgot to fix these up previously.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 hw/display/virtio-gpu.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 7bf2fbb..28dcd1e 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -137,7 +137,7 @@ static void virtgpu_resource_create_2d(VirtIOGPU *g,
     pixman_format_code_t pformat;
     struct virtgpu_simple_resource *res;
 
-    res = calloc(1, sizeof(struct virtgpu_simple_resource));
+    res = g_new0(struct virtgpu_simple_resource, 1);
     if (!res)
 	return;
 
@@ -159,7 +159,7 @@ static void virtgpu_resource_destroy(struct virtgpu_simple_resource *res)
 {
     pixman_image_unref(res->image);
     QLIST_REMOVE(res, next);
-    free(res);
+    g_free(res);
 }
 
 static void virtgpu_resource_unref(VirtIOGPU *g,
@@ -310,12 +310,10 @@ static void virtgpu_resource_attach_backing(VirtIOGPU *g,
     if (!res)
 	return;
     
-    res_iovs = malloc(att_rb->nr_entries * sizeof(struct iovec));
-    if (!res_iovs)
-	return;
+    res_iovs = g_new0(struct iovec, att_rb->nr_entries);
 
     if (iov_cnt > 1) {
-	data = malloc(gsize);
+	data = g_malloc(gsize);
 	iov_to_buf(iov, iov_cnt, 0, data, gsize);
     } else
 	data = iov[0].iov_base;
@@ -337,7 +335,7 @@ static void virtgpu_resource_attach_backing(VirtIOGPU *g,
     res->iov_cnt = att_rb->nr_entries;
 
     if (iov_cnt > 1)
-	free(data);
+        g_free(data);
 }
 
 static void virtgpu_resource_inval_backing(VirtIOGPU *g,
@@ -354,7 +352,7 @@ static void virtgpu_resource_inval_backing(VirtIOGPU *g,
     for (i = 0; i < res->iov_cnt; i++) {
 	cpu_physical_memory_unmap(res->iov[i].iov_base, res->iov[i].iov_len, 1, res->iov[i].iov_len);
     }
-    free(res->iov);
+    g_free(res->iov);
     res->iov_cnt = 0;
     res->iov = NULL;
 }
-- 
1.8.3.1

                 reply	other threads:[~2013-12-10  4:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386651440-9218-1-git-send-email-airlied@gmail.com \
    --to=airlied@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).