* [commit] add xzalloc()
@ 2005-02-06 16:23 Andrew Cagney
2005-02-07 2:43 ` Andrew Cagney
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cagney @ 2005-02-06 16:23 UTC (permalink / raw)
To: gdb-patches
Fills in a gap,
Andrew
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.
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.179
diff -p -u -r1.179 defs.h
--- defs.h 14 Jan 2005 21:34:35 -0000 1.179
+++ defs.h 6 Feb 2005 15:01:12 -0000
@@ -856,10 +856,13 @@ extern char *savestring (const char *, s
"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)))
Index: mdebugread.c
===================================================================
RCS file: /cvs/src/src/gdb/mdebugread.c,v
retrieving revision 1.72
diff -p -u -r1.72 mdebugread.c
--- mdebugread.c 14 Jan 2005 00:59:31 -0000 1.72
+++ mdebugread.c 6 Feb 2005 15:01:13 -0000
@@ -297,17 +297,6 @@ static void handle_psymbol_enumerators (
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
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.148
diff -p -u -r1.148 utils.c
--- utils.c 21 Jan 2005 13:14:01 -0000 1.148
+++ utils.c 6 Feb 2005 15:01:13 -0000
@@ -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 */
{
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.10
diff -p -u -r1.10 value.c
--- value.c 2 Feb 2005 22:34:36 -0000 1.10
+++ value.c 6 Feb 2005 15:01:13 -0000
@@ -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;
From me@cgf.cx Sun Feb 06 17:34:00 2005
From: Christopher Faylor <me@cgf.cx>
To: overseers@sources.redhat.com, gdb-patches@sources.redhat.com, Andrew Cagney <cagney@gnu.org>
Subject: Re: GDB CVS ok; was CVS outage
Date: Sun, 06 Feb 2005 17:34:00 -0000
Message-id: <20050206173456.GE13306@trixie.casa.cgf.cx>
References: <42064372.3090708@gnu.org>
X-SW-Source: 2005-02/msg00013.html
Content-length: 332
On Sun, Feb 06, 2005 at 11:18:58AM -0500, Andrew Cagney wrote:
>FYI,
>
>GDB's CVS repository looks ok, thanks!
Thanks. I should have mentioned that we were pretty sure that gdb's cvs
was ok. I track the gdb-cvs mailing list so we could tell that it was
restored properly.
But getting independent verification is a relief.
cgf
^ permalink raw reply [flat|nested] 2+ messages in thread* [commit] add xzalloc()
2005-02-06 16:23 [commit] add xzalloc() Andrew Cagney
@ 2005-02-07 2:43 ` Andrew Cagney
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cagney @ 2005-02-07 2:43 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 23 bytes --]
Fills in a gap,
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 2928 bytes --]
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.
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.179
diff -p -u -r1.179 defs.h
--- defs.h 14 Jan 2005 21:34:35 -0000 1.179
+++ defs.h 6 Feb 2005 15:01:12 -0000
@@ -856,10 +856,13 @@ extern char *savestring (const char *, s
"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)))
Index: mdebugread.c
===================================================================
RCS file: /cvs/src/src/gdb/mdebugread.c,v
retrieving revision 1.72
diff -p -u -r1.72 mdebugread.c
--- mdebugread.c 14 Jan 2005 00:59:31 -0000 1.72
+++ mdebugread.c 6 Feb 2005 15:01:13 -0000
@@ -297,17 +297,6 @@ static void handle_psymbol_enumerators (
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
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.148
diff -p -u -r1.148 utils.c
--- utils.c 21 Jan 2005 13:14:01 -0000 1.148
+++ utils.c 6 Feb 2005 15:01:13 -0000
@@ -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 */
{
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.10
diff -p -u -r1.10 value.c
--- value.c 2 Feb 2005 22:34:36 -0000 1.10
+++ value.c 6 Feb 2005 15:01:13 -0000
@@ -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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-02-06 16:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-06 16:23 [commit] add xzalloc() Andrew Cagney
2005-02-07 2:43 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox