summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2004-01-07 19:36:39 +0000
committerPaul Smith <psmith@gnu.org>2004-01-07 19:36:39 +0000
commita35db9027526a8cad59c4e139ab224946245a7f7 (patch)
tree010e38117617a73053a9ac5fbecf3316b2eff705 /misc.c
parentee3d37a591cf2db3dd1444b2c1e2fcb041f68d33 (diff)
downloadgunmake-a35db9027526a8cad59c4e139ab224946245a7f7.tar.gz
Fix order-only prerequisites for pattern rules. (Savannah patch #2349).
Add a regression test for this. Older libraries don't allow *alloc(0), so make sure we don't ever do that.
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/misc.c b/misc.c
index ef754e5..9e5a516 100644
--- a/misc.c
+++ b/misc.c
@@ -357,7 +357,8 @@ pfatal_with_name (const char *name)
char *
xmalloc (unsigned int size)
{
- char *result = (char *) malloc (size);
+ /* Make sure we don't allocate 0, for pre-ANSI libraries. */
+ char *result = (char *) malloc (size ? size : 1);
if (result == 0)
fatal (NILF, _("virtual memory exhausted"));
return result;
@@ -370,6 +371,8 @@ xrealloc (char *ptr, unsigned int size)
char *result;
/* Some older implementations of realloc() don't conform to ANSI. */
+ if (! size)
+ size = 1;
result = ptr ? realloc (ptr, size) : malloc (size);
if (result == 0)
fatal (NILF, _("virtual memory exhausted"));