diff options
author | Andrew Cagney <cagney@redhat.com> | 2005-02-06 16:22:14 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2005-02-06 16:22:14 +0000 |
commit | 5b90c7b5ebca2697d381a2da54383662b47874bb (patch) | |
tree | 66dda1a2effc690828d0cca74c36f86e33d7151c /gdb | |
parent | c4f68ce31b3fc5dc3ef0da5c645573c38489ca21 (diff) | |
download | gdb-5b90c7b5ebca2697d381a2da54383662b47874bb.zip gdb-5b90c7b5ebca2697d381a2da54383662b47874bb.tar.gz gdb-5b90c7b5ebca2697d381a2da54383662b47874bb.tar.bz2 |
2005-02-03 Andrew Cagney <cagney@gnu.org>
* utils.c (xzalloc): New function.
* defs.h (XZALLOC): Use xzalloc.
(xzalloc): Declare.
* value.c (allocate_value): Allocate a zeroed buffer.
* mdebugread.c (xzalloc): Delete.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/defs.h | 5 | ||||
-rw-r--r-- | gdb/mdebugread.c | 11 | ||||
-rw-r--r-- | gdb/utils.c | 6 | ||||
-rw-r--r-- | gdb/value.c | 2 |
5 files changed, 19 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e2e38a2..325de50 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2005-02-03 Andrew Cagney <cagney@gnu.org> + + * utils.c (xzalloc): New function. + * defs.h (XZALLOC): Use xzalloc. + (xzalloc): Declare. + * value.c (allocate_value): Allocate a zeroed buffer. + * mdebugread.c (xzalloc): Delete. + 2005-02-02 Andrew Cagney <cagney@gnu.org> * value.h (value_lazy): Declare. @@ -856,10 +856,13 @@ extern char *savestring (const char *, size_t); "libiberty.h". */ extern void xfree (void *); +/* Like xmalloc, but zero the memory. */ +extern void *xzalloc (size_t); + /* Utility macros to allocate typed memory. Avoids errors like: struct foo *foo = xmalloc (sizeof struct bar); and memset (foo, sizeof (struct foo), 0). */ -#define XZALLOC(TYPE) ((TYPE*) memset (xmalloc (sizeof (TYPE)), 0, sizeof (TYPE))) +#define XZALLOC(TYPE) ((TYPE*) xzalloc (sizeof (TYPE))) #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE))) #define XCALLOC(NMEMB, TYPE) ((TYPE*) xcalloc ((NMEMB), sizeof (TYPE))) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index c179f87..2300e3e 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -297,17 +297,6 @@ static void handle_psymbol_enumerators (struct objfile *, FDR *, int, static char *mdebug_next_symbol_text (struct objfile *); -/* Allocate zeroed memory */ - -static void * -xzalloc (unsigned int size) -{ - void *p = xmalloc (size); - - memset (p, 0, size); - return p; -} - /* Exported procedure: Builds a symtab from the PST partial one. Restores the environment in effect when PST was created, delegates most of the work to an ancillary procedure, and sorts diff --git a/gdb/utils.c b/gdb/utils.c index 1bdcb63..d93e55f 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -947,6 +947,12 @@ xmalloc (size_t size) return (val); } +void * +xzalloc (size_t size) +{ + return xcalloc (1, size); +} + PTR /* OK: PTR */ xrealloc (PTR ptr, size_t size) /* OK: PTR */ { diff --git a/gdb/value.c b/gdb/value.c index 3ff911c..a871df3 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -83,7 +83,7 @@ allocate_value (struct type *type) struct value *val; struct type *atype = check_typedef (type); - val = (struct value *) xmalloc (sizeof (struct value) + TYPE_LENGTH (atype)); + val = (struct value *) xzalloc (sizeof (struct value) + TYPE_LENGTH (atype)); val->next = all_values; all_values = val; val->type = type; |