From a35db9027526a8cad59c4e139ab224946245a7f7 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Wed, 7 Jan 2004 19:36:39 +0000 Subject: 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. --- misc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'misc.c') 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")); -- cgit v1.2.3