mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-22 05:21:10 +00:00
g_free() can handle NULL pointer
This commit is contained in:
parent
909bf43e77
commit
74986cc59a
|
@ -69,9 +69,7 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
|
|||
//shift remainder of array down over deleted pointer
|
||||
memcpy(&uc->mapped_blocks[i], &uc->mapped_blocks[i + 1], sizeof(MemoryRegion*) * (uc->mapped_block_count - i));
|
||||
mr->destructor(mr);
|
||||
if((char *)mr->name)
|
||||
g_free((char *)mr->name);
|
||||
if(mr->ioeventfds)
|
||||
g_free(mr->ioeventfds);
|
||||
break;
|
||||
}
|
||||
|
@ -81,12 +79,14 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
|
|||
int memory_free(struct uc_struct *uc)
|
||||
{
|
||||
int i;
|
||||
|
||||
get_system_memory(uc)->enabled = false;
|
||||
for (i = 0; i < uc->mapped_block_count; i++) {
|
||||
uc->mapped_blocks[i]->enabled = false;
|
||||
memory_region_del_subregion(get_system_memory(uc), uc->mapped_blocks[i]);
|
||||
g_free(uc->mapped_blocks[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue