[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/32] memory: Move FlatView allocation to a helper
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 08/32] memory: Move FlatView allocation to a helper |
Date: |
Fri, 22 Sep 2017 01:16:16 +0200 |
From: Alexey Kardashevskiy <address@hidden>
This moves a FlatView allocation and initialization to a helper.
While we are nere, replace g_new with g_new0 to not to bother if we add
new fields in the future.
This should cause no behavioural change.
Signed-off-by: Alexey Kardashevskiy <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
memory.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/memory.c b/memory.c
index 3241e44..eec668e 100644
--- a/memory.c
+++ b/memory.c
@@ -258,12 +258,14 @@ static bool flatrange_equal(FlatRange *a, FlatRange *b)
&& a->readonly == b->readonly;
}
-static void flatview_init(FlatView *view)
+static FlatView *flatview_new(void)
{
+ FlatView *view;
+
+ view = g_new0(FlatView, 1);
view->ref = 1;
- view->ranges = NULL;
- view->nr = 0;
- view->nr_allocated = 0;
+
+ return view;
}
/* Insert a range into a given position. Caller is responsible for maintaining
@@ -707,8 +709,7 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)
{
FlatView *view;
- view = g_new(FlatView, 1);
- flatview_init(view);
+ view = flatview_new();
if (mr) {
render_memory_region(view, mr, int128_zero(),
@@ -2629,8 +2630,7 @@ void address_space_init(AddressSpace *as, MemoryRegion
*root, const char *name)
as->ref_count = 1;
as->root = root;
as->malloced = false;
- as->current_map = g_new(FlatView, 1);
- flatview_init(as->current_map);
+ as->current_map = flatview_new();
as->ioeventfd_nb = 0;
as->ioeventfds = NULL;
QTAILQ_INIT(&as->listeners);
--
1.8.3.1
- [Qemu-devel] [PULL 00/32] Misc changes for 2017-09-22, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 04/32] atomic: update documentation, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 06/32] exec: Explicitly export target AS from address_space_translate_internal, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 08/32] memory: Move FlatView allocation to a helper,
Paolo Bonzini <=
- [Qemu-devel] [PULL 07/32] memory: Open code FlatView rendering, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 01/32] virtio-serial: add enable_backend callback, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 02/32] kvm: drop wrong assertion creating problems with pflash, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 03/32] memory: avoid a name clash with access macro, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 05/32] memory: avoid "resurrection" of dead FlatViews, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 10/32] memory: Remove AddressSpace pointer from AddressSpaceDispatch, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 09/32] memory: Move AddressSpaceDispatch from AddressSpace to FlatView, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 13/32] memory: Rename mem_begin/mem_commit/mem_add helpers, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 12/32] memory: Cleanup after switching to FlatView, Paolo Bonzini, 2017/09/21
- [Qemu-devel] [PULL 14/32] memory: Store physical root MR in FlatView, Paolo Bonzini, 2017/09/21