public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
* [PATCH v3 2/2] disas/sparc: Convert malloc/free to g_malloc/g_free
@ 2026-03-15 12:59 Aadhya R
  2026-03-16  7:08 ` Michael Tokarev
  0 siblings, 1 reply; 2+ messages in thread
From: Aadhya R @ 2026-03-15 12:59 UTC (permalink / raw)
  To: mark.cave-ayland; +Cc: qemu-devel, qemu-trivial

Replace standard C memory allocators with GLib functions to safely handle out-of-memory aborts. Resolves GitLab issue #1798.

Signed-off-by: Aadhya R <raghavendraaadhya@gmail.com>
---
 disas/sparc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/disas/sparc.c b/disas/sparc.c
index 40c1164554..702409a118 100644
--- a/disas/sparc.c
+++ b/disas/sparc.c
@@ -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];
-- 
2.43.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 2/2] disas/sparc: Convert malloc/free to g_malloc/g_free
  2026-03-15 12:59 [PATCH v3 2/2] disas/sparc: Convert malloc/free to g_malloc/g_free Aadhya R
@ 2026-03-16  7:08 ` Michael Tokarev
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Tokarev @ 2026-03-16  7:08 UTC (permalink / raw)
  To: Aadhya R, mark.cave-ayland; +Cc: qemu-devel, qemu-trivial

On 15.03.2026 15:59, Aadhya R wrote:
> Replace standard C memory allocators with GLib functions to safely handle out-of-memory aborts. Resolves GitLab issue #1798.
> 

> -  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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-16  7:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-15 12:59 [PATCH v3 2/2] disas/sparc: Convert malloc/free to g_malloc/g_free Aadhya R
2026-03-16  7:08 ` Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox