aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-cmds.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2014-05-19 13:10:21 -0600
committerTom Tromey <tromey@redhat.com>2014-05-19 14:17:16 -0600
commitc4e54771f84f3acd02c6da80a6f62603eb3e8505 (patch)
tree26082a646b87994a2b307aeed39d6bf30592bf3f /gdb/mi/mi-cmds.c
parent8832e7e38ec3596b4e584cfadca060567a7e8bc3 (diff)
downloadgdb-c4e54771f84f3acd02c6da80a6f62603eb3e8505.zip
gdb-c4e54771f84f3acd02c6da80a6f62603eb3e8505.tar.gz
gdb-c4e54771f84f3acd02c6da80a6f62603eb3e8505.tar.bz2
fix two latent type errors
I'm checking this in as obvious. I was looking at instances of "alloc.*sizeof" and noticed a couple where the types in question are incorrect. In gdbtypes, the code allocates sizeof(int) to represent a struct rank. In mi-cmds, the code uses "struct mi_cmd **" -- one "*" too many. In both cases the problems are latent because in practice the sizes are the same as the sizes of the correct types. Still, it's better to be correct. I think gdb would be improved by a wholesale change from explicit sizeofs to using the libiberty.h allocation macros. In most cases they are both shorter and have better type safety. However, the resulting patch is rather large. Built and regtested on x86-64 Fedora 20. 2014-05-19 Tom Tromey <tromey@redhat.com> * gdbtypes.c (rank_function): Use XNEWVEC. * mi/mi-cmds.c (build_table): Use XCNEWVEC.
Diffstat (limited to 'gdb/mi/mi-cmds.c')
-rw-r--r--gdb/mi/mi-cmds.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 87a536f..68f97f6 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -247,10 +247,8 @@ build_table (struct mi_cmd *commands)
int nr_rehash = 0;
int nr_entries = 0;
struct mi_cmd *command;
- int sizeof_table = sizeof (struct mi_cmd **) * MI_TABLE_SIZE;
- mi_table = xmalloc (sizeof_table);
- memset (mi_table, 0, sizeof_table);
+ mi_table = XCNEWVEC (struct mi_cmd *, MI_TABLE_SIZE);
for (command = commands; command->name != 0; command++)
{
struct mi_cmd **entry = lookup_table (command->name);