diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | gawkmisc.c | 5 | ||||
-rw-r--r-- | xalloc.h | 2 |
3 files changed, 13 insertions, 3 deletions
@@ -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: @@ -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; } @@ -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; |