aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--gawkmisc.c5
-rw-r--r--xalloc.h2
3 files changed, 13 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index fddd2879..bf1461d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-11-20 Paul Eggert <eggert@cs.ucla.edu>
+
+ Port to systems where malloc (0) and/or realloc(P, 0) returns NULL.
+ * gawkmisc.c (xmalloc):
+ * xalloc.h (realloc):
+ Do not fail if malloc(0) or realloc(P, 0) returns NULL.
+ Fail only when the allocator returns null when attempting to
+ allocate a nonzero number of bytes.
+
2014-11-19 Arnold D. Robbins <arnold@skeeve.com>
Infrastructure upgrades:
diff --git a/gawkmisc.c b/gawkmisc.c
index a729d88d..fff5cc56 100644
--- a/gawkmisc.c
+++ b/gawkmisc.c
@@ -51,7 +51,8 @@ extern pointer xmalloc(size_t bytes); /* get rid of gcc warning */
pointer
xmalloc(size_t bytes)
{
- pointer p;
- emalloc(p, pointer, bytes, "xmalloc");
+ pointer p = malloc(bytes);
+ if (!p && bytes)
+ xalloc_die ();
return p;
}
diff --git a/xalloc.h b/xalloc.h
index 0d169cf9..5ee45164 100644
--- a/xalloc.h
+++ b/xalloc.h
@@ -156,7 +156,7 @@ void *
xrealloc(void *p, size_t size)
{
void *new_p = realloc(p, size);
- if (new_p == 0)
+ if (!new_p && size)
xalloc_die ();
return new_p;