[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH qemu v2 04/13] memory: Move FlatView allocation to a
From: |
Alexey Kardashevskiy |
Subject: |
[Qemu-devel] [PATCH qemu v2 04/13] memory: Move FlatView allocation to a helper |
Date: |
Fri, 15 Sep 2017 18:40:21 +1000 |
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.
Signed-off-by: Alexey Kardashevskiy <address@hidden>
---
memory.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/memory.c b/memory.c
index 62b0702d67..a8381a8bc2 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_alloc(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
@@ -706,8 +708,7 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)
{
FlatView *view;
- view = g_new(FlatView, 1);
- flatview_init(view);
+ view = flatview_alloc();
if (mr) {
render_memory_region(view, mr, int128_zero(),
@@ -2665,8 +2666,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_alloc();
as->ioeventfd_nb = 0;
as->ioeventfds = NULL;
QTAILQ_INIT(&as->listeners);
--
2.11.0
- [Qemu-devel] [PATCH qemu v2 00/13] memory: Reduce memory use, Alexey Kardashevskiy, 2017/09/15
- [Qemu-devel] [PATCH qemu v2 03/13] memory: Open code FlatView rendering, Alexey Kardashevskiy, 2017/09/15
- [Qemu-devel] [PATCH qemu v2 04/13] memory: Move FlatView allocation to a helper,
Alexey Kardashevskiy <=
- [Qemu-devel] [PATCH qemu v2 06/13] memory: Remove AddressSpace pointer from AddressSpaceDispatch, Alexey Kardashevskiy, 2017/09/15
- [Qemu-devel] [PATCH qemu v2 08/13] memory: Cleanup after switching to FlatView, Alexey Kardashevskiy, 2017/09/15
- [Qemu-devel] [PATCH qemu v2 09/13] memory: Rename mem_begin/mem_commit/mem_add helpers, Alexey Kardashevskiy, 2017/09/15
- [Qemu-devel] [PATCH qemu v2 10/13] memory: Move root MR from AddressSpace to FlatView, Alexey Kardashevskiy, 2017/09/15
- [Qemu-devel] [PATCH qemu v2 12/13] memory: Get rid of address_space_init_shareable, Alexey Kardashevskiy, 2017/09/15
- [Qemu-devel] [PATCH qemu v2 11/13] memory: Share FlatView's and dispatch trees between address spaces, Alexey Kardashevskiy, 2017/09/15