mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-08-03 23:41:16 +00:00
memory: Move FlatView allocation to a helper
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. Backports commit de7e6815b84c797cbda56dc96fcacaf5f37d3a20 from qemu
This commit is contained in:
parent
e723b8dd49
commit
75afdffa45
|
@ -288,12 +288,14 @@ static bool flatrange_equal(FlatRange *a, FlatRange *b)
|
||||||
&& a->readonly == b->readonly;
|
&& 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->ref = 1;
|
||||||
view->ranges = NULL;
|
|
||||||
view->nr = 0;
|
return view;
|
||||||
view->nr_allocated = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert a range into a given position. Caller is responsible for maintaining
|
/* Insert a range into a given position. Caller is responsible for maintaining
|
||||||
|
@ -664,8 +666,7 @@ static FlatView *generate_memory_topology(MemoryRegion *mr)
|
||||||
{
|
{
|
||||||
FlatView *view;
|
FlatView *view;
|
||||||
|
|
||||||
view = g_new(FlatView, 1);
|
view = flatview_new();
|
||||||
flatview_init(view);
|
|
||||||
|
|
||||||
if (mr) {
|
if (mr) {
|
||||||
render_memory_region(view, mr, int128_zero(),
|
render_memory_region(view, mr, int128_zero(),
|
||||||
|
@ -1804,8 +1805,7 @@ void address_space_init(struct uc_struct *uc, AddressSpace *as, MemoryRegion *ro
|
||||||
as->uc = uc;
|
as->uc = uc;
|
||||||
as->root = root;
|
as->root = root;
|
||||||
as->malloced = false;
|
as->malloced = false;
|
||||||
as->current_map = g_new(FlatView, 1);
|
as->current_map = flatview_new();
|
||||||
flatview_init(as->current_map);
|
|
||||||
QTAILQ_INIT(&as->listeners);
|
QTAILQ_INIT(&as->listeners);
|
||||||
QTAILQ_INSERT_TAIL(&uc->address_spaces, as, address_spaces_link);
|
QTAILQ_INSERT_TAIL(&uc->address_spaces, as, address_spaces_link);
|
||||||
as->name = g_strdup(name ? name : "anonymous");
|
as->name = g_strdup(name ? name : "anonymous");
|
||||||
|
|
Loading…
Reference in a new issue