qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-trivial] [PATCH 28/88] disas: use g_new() family of functions


From: Philippe Mathieu-Daudé
Subject: [Qemu-trivial] [PATCH 28/88] disas: use g_new() family of functions
Date: Fri, 6 Oct 2017 20:49:23 -0300

From: Marc-André Lureau <address@hidden>

Signed-off-by: Marc-André Lureau <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
[PMD: fixed const cast, squashed M68K + NiosII + SPARC, renamed subject "disas"]
---
 disas/m68k.c  | 3 +--
 disas/nios2.c | 3 +--
 disas/sparc.c | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/disas/m68k.c b/disas/m68k.c
index 61b689ef3e..31cf6ea5f9 100644
--- a/disas/m68k.c
+++ b/disas/m68k.c
@@ -1886,8 +1886,7 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info)
 
       /* Then create a sorted table of pointers
         that point into the unsorted table.  */
-      opc_pointer[0] = malloc (sizeof (struct m68k_opcode *)
-                               * m68k_numopcodes);
+      opc_pointer[0] = g_new(const struct m68k_opcode *, m68k_numopcodes);
       opcodes[0] = opc_pointer[0];
 
       for (i = 1; i < 16; i++)
diff --git a/disas/nios2.c b/disas/nios2.c
index b342936d21..9e6e1e6a1f 100644
--- a/disas/nios2.c
+++ b/disas/nios2.c
@@ -2625,8 +2625,7 @@ nios2_init_opcode_hash (nios2_disassembler_state *state)
 
        if (bucket)
          {
-           new_hash =
-             (nios2_opcode_hash *) malloc (sizeof (nios2_opcode_hash));
+           new_hash = g_new(nios2_opcode_hash, 1);
            if (new_hash == NULL)
              {
                fprintf (stderr,
diff --git a/disas/sparc.c b/disas/sparc.c
index f120f4e86d..6d0adab8a7 100644
--- a/disas/sparc.c
+++ b/disas/sparc.c
@@ -2684,8 +2684,7 @@ print_insn_sparc (bfd_vma memaddr, disassemble_info *info)
       current_arch_mask = compute_arch_mask (info->mach);
 
       if (!opcodes_initialized)
-        sorted_opcodes =
-          malloc (sparc_num_opcodes * sizeof (sparc_opcode *));
+        sorted_opcodes = g_new(const sparc_opcode *, sparc_num_opcodes);
       /* Reset the sorted table so we can resort it.  */
       for (i = 0; i < sparc_num_opcodes; ++i)
         sorted_opcodes[i] = &sparc_opcodes[i];
-- 
2.14.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]