From: ellson Date: Tue, 18 Oct 2005 21:06:26 +0000 (+0000) Subject: Change our malloc routines to return NULL when the argument is 0. X-Git-Tag: LAST_LIBGRAPH~32^2~7092 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f21d62fb9eac814855234c05b1baebf0d68151d8;p=graphviz Change our malloc routines to return NULL when the argument is 0. --- diff --git a/lib/common/memory.c b/lib/common/memory.c index a1d24f40e..8713081d5 100644 --- a/lib/common/memory.c +++ b/lib/common/memory.c @@ -24,13 +24,10 @@ void *zmalloc(size_t nbytes) { - char *rv = malloc(nbytes); + char *rv; if (nbytes == 0) return 0; - if (rv == NULL) { - fprintf(stderr, "out of memory\n"); - abort(); - } + rv = gmalloc(nbytes); memset(rv, 0, nbytes); return rv; } @@ -51,7 +48,7 @@ void *gmalloc(size_t nbytes) { char *rv; if (nbytes == 0) - return (char *)1; /* NB Return an invalid pointer - since nobody seems to check for NULL */ + return NULL; rv = malloc(nbytes); if (rv == NULL) { fprintf(stderr, "out of memory\n");