* 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-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.
"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)))
static char *mdebug_next_symbol_text (struct objfile *);
\f
-/* 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
return (val);
}
+void *
+xzalloc (size_t size)
+{
+ return xcalloc (1, size);
+}
+
PTR /* OK: PTR */
xrealloc (PTR ptr, size_t size) /* OK: PTR */
{
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;