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:
parent
598a0147cd
commit
26031da0f8
2 changed files with 10 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue