aboutsummaryrefslogtreecommitdiff
path: root/cris-dis.c
diff options
context:
space:
mode:
authorStefan Weil <sw@weilnetz.de>2012-01-09 19:23:42 +0100
committerEdgar E. Iglesias <edgar.iglesias@gmail.com>2012-01-10 09:36:43 +0100
commit520a02f8b844152929817b686113aed27229d3a9 (patch)
tree1097f88a17859c30e1aea881437edc5ddbf25368 /cris-dis.c
parentcd9244e48a6643752fccecd344d85d1c4de5cbad (diff)
downloadqemu-520a02f8b844152929817b686113aed27229d3a9.zip
qemu-520a02f8b844152929817b686113aed27229d3a9.tar.gz
qemu-520a02f8b844152929817b686113aed27229d3a9.tar.bz2
cris-dis: Clean memory allocation
The old code used sizeof(const struct cris_opcode **) where it should have used sizeof(const struct cris_opcode *). As both sizes give the same value, the resulting binary was ok, but static code analyzers like coverity and clang complained. This is fixed here, and the code is also simplified by using g_new0. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Diffstat (limited to 'cris-dis.c')
-rw-r--r--cris-dis.c34
1 files changed, 6 insertions, 28 deletions
diff --git a/cris-dis.c b/cris-dis.c
index 5b8e90b..1d174ba 100644
--- a/cris-dis.c
+++ b/cris-dis.c
@@ -1396,34 +1396,12 @@ get_opcode_entry (unsigned int insn,
/* Allocate and clear the opcode-table. */
if (opc_table == NULL)
{
- opc_table = g_malloc (65536 * sizeof (opc_table[0]));
-
- memset (opc_table, 0, 65536 * sizeof (const struct cris_opcode *));
-
- dip_prefixes
- = g_malloc (65536 * sizeof (const struct cris_opcode **));
-
- memset (dip_prefixes, 0, 65536 * sizeof (dip_prefixes[0]));
-
- bdapq_m1_prefixes
- = g_malloc (65536 * sizeof (const struct cris_opcode **));
-
- memset (bdapq_m1_prefixes, 0, 65536 * sizeof (bdapq_m1_prefixes[0]));
-
- bdapq_m2_prefixes
- = g_malloc (65536 * sizeof (const struct cris_opcode **));
-
- memset (bdapq_m2_prefixes, 0, 65536 * sizeof (bdapq_m2_prefixes[0]));
-
- bdapq_m4_prefixes
- = g_malloc (65536 * sizeof (const struct cris_opcode **));
-
- memset (bdapq_m4_prefixes, 0, 65536 * sizeof (bdapq_m4_prefixes[0]));
-
- rest_prefixes
- = g_malloc (65536 * sizeof (const struct cris_opcode **));
-
- memset (rest_prefixes, 0, 65536 * sizeof (rest_prefixes[0]));
+ opc_table = g_new0(const struct cris_opcode *, 65536);
+ dip_prefixes = g_new0(const struct cris_opcode *, 65536);
+ bdapq_m1_prefixes = g_new0(const struct cris_opcode *, 65536);
+ bdapq_m2_prefixes = g_new0(const struct cris_opcode *, 65536);
+ bdapq_m4_prefixes = g_new0(const struct cris_opcode *, 65536);
+ rest_prefixes = g_new0(const struct cris_opcode *, 65536);
}
/* Get the right table if this is a prefix.