Committed.

This commit is contained in:
Kevin Buettner 2001-03-10 01:22:11 +00:00
parent f8241bd143
commit d7fa9de08d
2 changed files with 30 additions and 10 deletions

View File

@ -1,3 +1,7 @@
2001-03-09 Kevin Buettner <kevinb@redhat.com>
* utils.c (xmrealloc, xcalloc): Return NULL for zero-sized requests.
2001-03-09 Andrew Cagney <ac131313@redhat.com> 2001-03-09 Andrew Cagney <ac131313@redhat.com>
* MAINTAINERS (Write After Approval): Update Philip Blundell. * MAINTAINERS (Write After Approval): Update Philip Blundell.

View File

@ -1044,17 +1044,26 @@ xmrealloc (PTR md, PTR ptr, long size)
{ {
register PTR val; register PTR val;
if (ptr != NULL) if (size == 0)
{ {
val = mrealloc (md, ptr, size); if (ptr != NULL)
mfree (md, ptr);
val = NULL;
} }
else else
{ {
val = mmalloc (md, size); if (ptr != NULL)
} {
if (val == NULL) val = mrealloc (md, ptr, size);
{ }
nomem (size); else
{
val = mmalloc (md, size);
}
if (val == NULL)
{
nomem (size);
}
} }
return (val); return (val);
} }
@ -1073,9 +1082,16 @@ xmalloc (size_t size)
PTR PTR
xcalloc (size_t number, size_t size) xcalloc (size_t number, size_t size)
{ {
void *mem = mcalloc (NULL, number, size); void *mem;
if (mem == NULL)
nomem (number * size); if (number == 0 || size == 0)
mem = NULL;
else
{
mem = mcalloc (NULL, number, size);
if (mem == NULL)
nomem (number * size);
}
return mem; return mem;
} }