* [patch rfc] Make GDB's xmalloc match liberties
@ 2003-04-12 0:42 Andrew Cagney
2003-04-13 14:12 ` Daniel Jacobowitz
2003-04-16 14:43 ` Andrew Cagney
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Cagney @ 2003-04-12 0:42 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 122 bytes --]
Per recent discussion, this modifies GDB's xmalloc (actually xmmalloc)
so that the behavior matches libiberty's.
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 1958 bytes --]
2003-04-11 Andrew Cagney <cagney@redhat.com>
* utils.c (xmmalloc): Always allocate something, matches
libiberty/xmalloc's semantics.
(xmrealloc, xmcalloc): Ditto.
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.100
diff -u -r1.100 utils.c
--- utils.c 10 Apr 2003 02:18:40 -0000 1.100
+++ utils.c 12 Apr 2003 00:40:30 -0000
@@ -1073,16 +1073,15 @@
{
void *val;
+ /* See libiberty/xmalloc.c. This function need's to match that's
+ semantics. It never returns NULL. */
if (size == 0)
- {
- val = NULL;
- }
- else
- {
- val = mmalloc (md, size);
- if (val == NULL)
- nomem (size);
- }
+ size = 1;
+
+ val = mmalloc (md, size);
+ if (val == NULL)
+ nomem (size);
+
return (val);
}
@@ -1091,27 +1090,18 @@
{
void *val;
+ /* See libiberty/xmalloc.c. This function need's to match that's
+ semantics. It never returns NULL. */
if (size == 0)
- {
- if (ptr != NULL)
- mfree (md, ptr);
- val = NULL;
- }
+ size = 1;
+
+ if (ptr != NULL)
+ val = mrealloc (md, ptr, size);
else
- {
- if (ptr != NULL)
- {
- val = mrealloc (md, ptr, size);
- }
- else
- {
- val = mmalloc (md, size);
- }
- if (val == NULL)
- {
- nomem (size);
- }
- }
+ val = mmalloc (md, size);
+ if (val == NULL)
+ nomem (size);
+
return (val);
}
@@ -1119,14 +1109,19 @@
xmcalloc (void *md, size_t number, size_t size)
{
void *mem;
+
+ /* See libiberty/xmalloc.c. This function need's to match that's
+ semantics. It never returns NULL. */
if (number == 0 || size == 0)
- mem = NULL;
- else
{
- mem = mcalloc (md, number, size);
- if (mem == NULL)
- nomem (number * size);
+ number = 1;
+ size = 1;
}
+
+ mem = mcalloc (md, number, size);
+ if (mem == NULL)
+ nomem (number * size);
+
return mem;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch rfc] Make GDB's xmalloc match liberties
2003-04-12 0:42 [patch rfc] Make GDB's xmalloc match liberties Andrew Cagney
@ 2003-04-13 14:12 ` Daniel Jacobowitz
2003-04-16 14:43 ` Andrew Cagney
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2003-04-13 14:12 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Fri, Apr 11, 2003 at 08:42:30PM -0400, Andrew Cagney wrote:
> Per recent discussion, this modifies GDB's xmalloc (actually xmmalloc)
> so that the behavior matches libiberty's.
Seems reasonable to me, on its own. However, is it a bug that we were
calling malloc (0) in the first place via NUM_REGS?
I know that call has been discussed before but damned if I can remember
what the discussion said.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch rfc] Make GDB's xmalloc match liberties
2003-04-12 0:42 [patch rfc] Make GDB's xmalloc match liberties Andrew Cagney
2003-04-13 14:12 ` Daniel Jacobowitz
@ 2003-04-16 14:43 ` Andrew Cagney
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2003-04-16 14:43 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
> Per recent discussion, this modifies GDB's xmalloc (actually xmmalloc) so that the behavior matches libiberty's.
>
> Andrew
>
>
>
> 2003-04-11 Andrew Cagney <cagney@redhat.com>
>
> * utils.c (xmmalloc): Always allocate something, matches
> libiberty/xmalloc's semantics.
> (xmrealloc, xmcalloc): Ditto.
>
I've checked this in.
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-04-16 14:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-12 0:42 [patch rfc] Make GDB's xmalloc match liberties Andrew Cagney
2003-04-13 14:12 ` Daniel Jacobowitz
2003-04-16 14: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