aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2003-04-16 14:43:03 +0000
committerAndrew Cagney <cagney@redhat.com>2003-04-16 14:43:03 +0000
commit25d41031648fa41bc108e1a3c6794da69c8bdd0f (patch)
tree5a8cb17676dc81a3f80f8c69ecb9d21558c23644 /gdb/utils.c
parentc50901fda0471af8f5f823b211db41c6724590bc (diff)
downloadbinutils-25d41031648fa41bc108e1a3c6794da69c8bdd0f.zip
binutils-25d41031648fa41bc108e1a3c6794da69c8bdd0f.tar.gz
binutils-25d41031648fa41bc108e1a3c6794da69c8bdd0f.tar.bz2
2003-04-16 Andrew Cagney <cagney@redhat.com>
* utils.c (xmmalloc): Always allocate something, matches libiberty/xmalloc's semantics. (xmrealloc, xmcalloc): Ditto.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c61
1 files changed, 28 insertions, 33 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index e72aec7..3d820de 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1073,16 +1073,15 @@ xmmalloc (void *md, size_t size)
{
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 @@ xmrealloc (void *md, void *ptr, size_t size)
{
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 @@ void *
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;
}