Blame SOURCES/kvm-memory-Move-FlatView-allocation-to-a-helper.patch

9bac43
From f99aa9de16a53a783a88cb9049ef42977037c935 Mon Sep 17 00:00:00 2001
9bac43
From: David Gibson <dgibson@redhat.com>
9bac43
Date: Thu, 16 Nov 2017 03:07:16 +0100
9bac43
Subject: [PATCH 12/30] memory: Move FlatView allocation to a helper
9bac43
9bac43
RH-Author: David Gibson <dgibson@redhat.com>
9bac43
Message-id: <20171116030732.8560-7-dgibson@redhat.com>
9bac43
Patchwork-id: 77693
9bac43
O-Subject: [PATCH 06/22] memory: Move FlatView allocation to a helper
9bac43
Bugzilla: 1481593
9bac43
RH-Acked-by: Thomas Huth <thuth@redhat.com>
9bac43
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9bac43
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
9bac43
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
9bac43
9bac43
From: Alexey Kardashevskiy <aik@ozlabs.ru>
9bac43
9bac43
This moves a FlatView allocation and initialization to a helper.
9bac43
While we are nere, replace g_new with g_new0 to not to bother if we add
9bac43
new fields in the future.
9bac43
9bac43
This should cause no behavioural change.
9bac43
9bac43
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
9bac43
Message-Id: <20170921085110.25598-4-aik@ozlabs.ru>
9bac43
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9bac43
(cherry picked from commit cc94cd6d36602d976a5e7bc29134d1eaefb4102e)
9bac43
9bac43
Signed-off-by: David Gibson <dgibson@redhat.com>
9bac43
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9bac43
---
9bac43
 memory.c | 16 ++++++++--------
9bac43
 1 file changed, 8 insertions(+), 8 deletions(-)
9bac43
9bac43
diff --git a/memory.c b/memory.c
9bac43
index 8bc1f56..f51e499 100644
9bac43
--- a/memory.c
9bac43
+++ b/memory.c
9bac43
@@ -258,12 +258,14 @@ static bool flatrange_equal(FlatRange *a, FlatRange *b)
9bac43
         && a->readonly == b->readonly;
9bac43
 }
9bac43
 
9bac43
-static void flatview_init(FlatView *view)
9bac43
+static FlatView *flatview_new(void)
9bac43
 {
9bac43
+    FlatView *view;
9bac43
+
9bac43
+    view = g_new0(FlatView, 1);
9bac43
     view->ref = 1;
9bac43
-    view->ranges = NULL;
9bac43
-    view->nr = 0;
9bac43
-    view->nr_allocated = 0;
9bac43
+
9bac43
+    return view;
9bac43
 }
9bac43
 
9bac43
 /* Insert a range into a given position.  Caller is responsible for maintaining
9bac43
@@ -706,8 +708,7 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)
9bac43
 {
9bac43
     FlatView *view;
9bac43
 
9bac43
-    view = g_new(FlatView, 1);
9bac43
-    flatview_init(view);
9bac43
+    view = flatview_new();
9bac43
 
9bac43
     if (mr) {
9bac43
         render_memory_region(view, mr, int128_zero(),
9bac43
@@ -2628,8 +2629,7 @@ void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name)
9bac43
     as->ref_count = 1;
9bac43
     as->root = root;
9bac43
     as->malloced = false;
9bac43
-    as->current_map = g_new(FlatView, 1);
9bac43
-    flatview_init(as->current_map);
9bac43
+    as->current_map = flatview_new();
9bac43
     as->ioeventfd_nb = 0;
9bac43
     as->ioeventfds = NULL;
9bac43
     QTAILQ_INIT(&as->listeners);
9bac43
-- 
9bac43
1.8.3.1
9bac43