summaryrefslogtreecommitdiffstats
path: root/hw/xtensa/sim.c
diff options
context:
space:
mode:
authorMax Filippov2017-05-08 20:00:56 +0200
committerMichael Tokarev2017-06-04 17:42:55 +0200
commitbb0b6f39c032c18e3a72c5ebef4e4968a9dcb4d0 (patch)
treeca7bb80856a302b8848064b1a05628dc801f9a06 /hw/xtensa/sim.c
parenttarget/arm: add data cache invalidation cp15 instruction to cortex-r5 (diff)
downloadqemu-bb0b6f39c032c18e3a72c5ebef4e4968a9dcb4d0.tar.gz
qemu-bb0b6f39c032c18e3a72c5ebef4e4968a9dcb4d0.tar.xz
qemu-bb0b6f39c032c18e3a72c5ebef4e4968a9dcb4d0.zip
hw/xtensa: sim: use g_string/g_new
Replace malloc/free/sprintf with g_string/g_string_printf/g_string_free. Replace g_malloc with g_new when allocating the MemoryRegion to get more type safety. Suggested-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'hw/xtensa/sim.c')
-rw-r--r--hw/xtensa/sim.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/hw/xtensa/sim.c b/hw/xtensa/sim.c
index d2d1d3a6fd..b27e28d802 100644
--- a/hw/xtensa/sim.c
+++ b/hw/xtensa/sim.c
@@ -41,21 +41,21 @@ static void xtensa_create_memory_regions(const XtensaMemory *memory,
const char *name)
{
unsigned i;
- char *num_name = malloc(strlen(name) + sizeof(i) * 3 + 1);
+ GString *num_name = g_string_new(NULL);
for (i = 0; i < memory->num; ++i) {
MemoryRegion *m;
- sprintf(num_name, "%s%u", name, i);
- m = g_malloc(sizeof(*m));
- memory_region_init_ram(m, NULL, num_name,
+ g_string_printf(num_name, "%s%u", name, i);
+ m = g_new(MemoryRegion, 1);
+ memory_region_init_ram(m, NULL, num_name->str,
memory->location[i].size,
&error_fatal);
vmstate_register_ram_global(m);
memory_region_add_subregion(get_system_memory(),
memory->location[i].addr, m);
}
- free(num_name);
+ g_string_free(num_name, true);
}
static uint64_t translate_phys_addr(void *opaque, uint64_t addr)