aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2001-03-10 01:22:11 +0000
committerKevin Buettner <kevinb@redhat.com>2001-03-10 01:22:11 +0000
commitd7fa9de08de666af5647be3053c6b3f04996277b (patch)
tree0d19d5f8e5adc0fbd1a0ba0b580b5c6dd2956264 /gdb/utils.c
parentf8241bd1436ed7a5e6d387948651b1e9784d77f4 (diff)
downloadgdb-d7fa9de08de666af5647be3053c6b3f04996277b.zip
gdb-d7fa9de08de666af5647be3053c6b3f04996277b.tar.gz
gdb-d7fa9de08de666af5647be3053c6b3f04996277b.tar.bz2
Committed.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index 5ece78d..b81e3fd 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1044,17 +1044,26 @@ xmrealloc (PTR md, PTR ptr, long size)
{
register PTR val;
- if (ptr != NULL)
+ if (size == 0)
{
- val = mrealloc (md, ptr, size);
+ if (ptr != NULL)
+ mfree (md, ptr);
+ val = NULL;
}
else
{
- val = mmalloc (md, size);
- }
- if (val == NULL)
- {
- nomem (size);
+ if (ptr != NULL)
+ {
+ val = mrealloc (md, ptr, size);
+ }
+ else
+ {
+ val = mmalloc (md, size);
+ }
+ if (val == NULL)
+ {
+ nomem (size);
+ }
}
return (val);
}
@@ -1073,9 +1082,16 @@ xmalloc (size_t size)
PTR
xcalloc (size_t number, size_t size)
{
- void *mem = mcalloc (NULL, number, size);
- if (mem == NULL)
- nomem (number * size);
+ void *mem;
+
+ if (number == 0 || size == 0)
+ mem = NULL;
+ else
+ {
+ mem = mcalloc (NULL, number, size);
+ if (mem == NULL)
+ nomem (number * size);
+ }
return mem;
}