mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 08:35:34 +00:00
memory: Move assignment to ram_block to memory_region_init_*
We don't force "const" qualifiers with pointers in QEMU, but it's still good to keep a clean function interface. Assigning to mr->ram_block is in this sense ugly - one initializer mutating its owning object's state. Move it to memory_region_init_*, where mr->ram_addr is assigned. Backports commit 0a75601853c00f3729fa62c49ec0d4bb1e3d9bc1 from qemu
This commit is contained in:
parent
aa80edbef0
commit
4b8c428494
|
@ -1192,7 +1192,6 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ram_addr_t max_size,
|
|||
error_propagate(errp, local_err);
|
||||
return NULL;
|
||||
}
|
||||
mr->ram_block = new_block;
|
||||
return new_block;
|
||||
}
|
||||
|
||||
|
|
|
@ -1174,6 +1174,7 @@ void memory_region_init_ram(struct uc_struct *uc, MemoryRegion *mr,
|
|||
mr->terminates = true;
|
||||
mr->destructor = memory_region_destructor_ram;
|
||||
ram_block = qemu_ram_alloc(size, mr, errp);
|
||||
mr->ram_block = ram_block;
|
||||
mr->ram_addr = ram_block->offset;
|
||||
mr->dirty_log_mask = tcg_enabled(uc) ? (1 << DIRTY_MEMORY_CODE) : 0;
|
||||
}
|
||||
|
@ -1194,6 +1195,7 @@ void memory_region_init_ram_ptr(struct uc_struct *uc, MemoryRegion *mr,
|
|||
/* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL. */
|
||||
assert(ptr != NULL);
|
||||
ram_block = qemu_ram_alloc_from_ptr(size, ptr, mr, &error_abort);
|
||||
mr->ram_block = ram_block;
|
||||
mr->ram_addr = ram_block->offset;
|
||||
}
|
||||
|
||||
|
@ -1215,6 +1217,7 @@ void memory_region_init_resizeable_ram(struct uc_struct *uc,
|
|||
mr->terminates = true;
|
||||
mr->destructor = memory_region_destructor_ram;
|
||||
ram_block = qemu_ram_alloc_resizeable(size, max_size, resized, mr, errp);
|
||||
mr->ram_block = ram_block;
|
||||
mr->ram_addr = ram_block->offset;
|
||||
mr->dirty_log_mask = tcg_enabled(uc) ? (1 << DIRTY_MEMORY_CODE) : 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue