Patchwork [7/9,v2] Add API to free buf used by creating header, bitmap and page

login
register
mail settings
Submitter Qiao Nuohan
Date May 8, 2013, 2:12 a.m.
Message ID <1367979181-24679-8-git-send-email-qiaonuohan@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/243254/
State New
Headers show

Comments

Qiao Nuohan - May 8, 2013, 2:12 a.m.
From: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>

When calling create_header, create_dump_bitmap and create_pages, some memory spaces
are allocated. The following patch will use this function to free these spaces.

Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
Reviewed-by: Zhang Xiaohe <zhangxh@cn.fujitsu.com>
---
 dump.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

Patch

diff --git a/dump.c b/dump.c
index ebfb190..75ef032 100644
--- a/dump.c
+++ b/dump.c
@@ -1252,6 +1252,25 @@  cleanup:
     return -1;
 }
 
+static void clean_state(DumpState *s)
+{
+    if (s->dh) {
+        g_free(s->dh);
+    }
+
+    if (s->kh) {
+        g_free(s->kh);
+    }
+
+    free_dump_bitmap(s->dump_bitmap1);
+
+    free_dump_bitmap(s->dump_bitmap2);
+
+    free_cache_data(s->page_desc);
+
+    free_cache_data(s->page_data);
+}
+
 void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
                            int64_t begin, bool has_length, int64_t length,
                            Error **errp)