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

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