disas/sparc: Convert malloc/free to g_malloc/g_free
PATCH v3 2/2 disas/sparc: Convert malloc/free to g_malloc/g_free
Replace standard C memory allocators with GLib functions to safely handle out-of-memory aborts. Resolves GitLab issue #1798.
Signed-off-by Aadhya R <[email protected]>
--- disas/sparc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
disas/sparc.c +2 -2
@@ -2623,7 +2623,7 @@ build_hash_table (const sparc_opcode **opcode_table,memset (hash_table,0 ,HASH_SIZE *sizeof (hash_table[0 ]));memset (hash_count,0 ,HASH_SIZE *sizeof (hash_count[0 ]));free (hash_buf); - hash_buf =malloc (sizeof (* hash_buf) * num_opcodes); + hash_buf =g_malloc (sizeof (*hash_buf) * num_opcodes);for (i = num_opcodes -1 ; i >=0 ; --i) {int hash =HASH_INSN (opcode_table[i]->match);
@@ -2685,7 +2685,7 @@ print_insn_sparc (bfd_vma memaddr, disassemble_info *info)if (!opcodes_initialized) sorted_opcodes = -malloc (sparc_num_opcodes *sizeof (sparc_opcode *)); +g_malloc (sparc_num_opcodes *sizeof (sparc_opcode *));/* Reset the sorted table so we can resort it. */ for (i =0 ; i < sparc_num_opcodes; ++i) sorted_opcodes[i] = &sparc_opcodes[i];
Signature · 1 line
2.43.0
disas/sparc.c build_hash_table (const sparc_opcode **opcode_table, · line 2626
Quoted 5 lines · Aadhya R
Replace standard C memory allocators with GLib functions to safely handle out-of-memory aborts. Resolves GitLab issue #1798.
disas/sparc.c +1
-1- hash_buf =malloc (sizeof (* hash_buf) * num_opcodes); + hash_buf =g_malloc (sizeof (*hash_buf) * num_opcodes);
This one is a good candicate for g_new(), not g_malloc(). FWIW.
/mjt