From 2a052b4ee01b3c413cef2ef49cb780cde17d4ba1 Mon Sep 17 00:00:00 2001 From: Suraj Shirvankar Date: Tue, 3 Oct 2023 14:45:14 +0200 Subject: contrib/elf2dmp: Use g_malloc(), g_new() and g_free() QEMU coding style uses the glib memory allocation APIs, not the raw libc malloc/free. Switch the allocation and free calls in elf2dmp to use these functions (dropping the now-unneeded checks for failure). Signed-off-by: Suraj Shirvankar Message-id: 169753938460.23804.11418813007617535750-1@git.sr.ht [PMM: also remove NULL checks from g_malloc() calls; beef up commit message] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- contrib/elf2dmp/qemu_elf.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'contrib/elf2dmp/qemu_elf.c') diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c index de6ad744c6..055e6f8792 100644 --- a/contrib/elf2dmp/qemu_elf.c +++ b/contrib/elf2dmp/qemu_elf.c @@ -94,10 +94,7 @@ static int init_states(QEMU_Elf *qe) printf("%zu CPU states has been found\n", cpu_nr); - qe->state = malloc(sizeof(*qe->state) * cpu_nr); - if (!qe->state) { - return 1; - } + qe->state = g_new(QEMUCPUState*, cpu_nr); cpu_nr = 0; @@ -115,7 +112,7 @@ static int init_states(QEMU_Elf *qe) static void exit_states(QEMU_Elf *qe) { - free(qe->state); + g_free(qe->state); } static bool check_ehdr(QEMU_Elf *qe) -- cgit 1.4.1