qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] virtio-gpu: use glib alloc/free routines


From: Dave Airlie
Subject: [Qemu-devel] [PATCH] virtio-gpu: use glib alloc/free routines
Date: Tue, 10 Dec 2013 14:57:20 +1000

From: Dave Airlie <address@hidden>

Oh I forgot to fix these up previously.

Signed-off-by: Dave Airlie <address@hidden>
---
 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 via email to

[Prev in Thread] Current Thread [Next in Thread]