Patchwork [10/13] dmg: Use g_free instead of free

login
register
mail settings
Submitter Stefan Hajnoczi
Date Feb. 1, 2013, 2:28 p.m.
Message ID <1359728884-19422-11-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/217482/
State New
Headers show

Comments

Stefan Hajnoczi - Feb. 1, 2013, 2:28 p.m.
From: Kevin Wolf <kwolf@redhat.com>

The buffers are allocated with g_(re)alloc, so use g_free to free them.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/dmg.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Patch

diff --git a/block/dmg.c b/block/dmg.c
index 53be25d..6d85801 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -355,15 +355,15 @@  static coroutine_fn int dmg_co_read(BlockDriverState *bs, int64_t sector_num,
 static void dmg_close(BlockDriverState *bs)
 {
     BDRVDMGState *s = bs->opaque;
-    if(s->n_chunks>0) {
-	free(s->types);
-	free(s->offsets);
-	free(s->lengths);
-	free(s->sectors);
-	free(s->sectorcounts);
-    }
-    free(s->compressed_chunk);
-    free(s->uncompressed_chunk);
+
+    g_free(s->types);
+    g_free(s->offsets);
+    g_free(s->lengths);
+    g_free(s->sectors);
+    g_free(s->sectorcounts);
+    g_free(s->compressed_chunk);
+    g_free(s->uncompressed_chunk);
+
     inflateEnd(&s->zstream);
 }