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
memory.

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

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)
-- 
1.7.1


Reply via email to