From 26f2dc3065ea8621b898fe5b98ef19afbf02aaf7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 13 Jun 2014 13:08:23 -0600 Subject: make obstack object allocators more type-safe This changes OBSTACK_ZALLOC and OBSTACK_CALLOC to cast their value to the correct type. This is more type-safe and also is more in line with the other object-allocation macros in libiberty.h. Making this change revealed one trivial error in dwarf2read.c. On the whole that seems pretty good to me. Tested by rebuilding. 2014-06-20 Tom Tromey * dwarf2read.c (dw2_get_real_path): Use correct type in OBSTACK_CALLOC. * gdb_obstack.h (OBSTACK_ZALLOC, OBSTACK_CALLOC): Cast result. --- gdb/gdb_obstack.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gdb/gdb_obstack.h') diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h index 0b39400..ec2dd97 100644 --- a/gdb/gdb_obstack.h +++ b/gdb/gdb_obstack.h @@ -25,11 +25,11 @@ /* Utility macros - wrap obstack alloc into something more robust. */ #define OBSTACK_ZALLOC(OBSTACK,TYPE) \ - (memset (obstack_alloc ((OBSTACK), sizeof (TYPE)), 0, sizeof (TYPE))) + ((TYPE *) memset (obstack_alloc ((OBSTACK), sizeof (TYPE)), 0, sizeof (TYPE))) #define OBSTACK_CALLOC(OBSTACK,NUMBER,TYPE) \ - (memset (obstack_alloc ((OBSTACK), (NUMBER) * sizeof (TYPE)), \ - 0, (NUMBER) * sizeof (TYPE))) + ((TYPE *) memset (obstack_alloc ((OBSTACK), (NUMBER) * sizeof (TYPE)), \ + 0, (NUMBER) * sizeof (TYPE))) /* Unless explicitly specified, GDB obstacks always use xmalloc() and xfree(). */ -- cgit v1.1