make malloc(0) return unique pointers rather than NULL

this change is made with some reluctance, but i think it's for the
best. correct programs must handle either behavior, so there is little
advantage to having malloc(0) return NULL. and i managed to actually
make the malloc code slightly smaller with this change.
This commit is contained in:
Rich Felker 2011-02-20 16:16:33 -05:00
commit 26031da0f8
2 changed files with 10 additions and 6 deletions

View file

@ -15,7 +15,7 @@ void *__simple_malloc(size_t n)
static int lock;
size_t align=1;
if (!n) return 0;
if (!n) n++;
if (n > SIZE_MAX/2) goto toobig;
while (align<n && align<ALIGN)