From 26031da0f83a2a3ed52190077931ee6c18dfd689 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 20 Feb 2011 16:16:33 -0500 Subject: 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. --- src/malloc/__simple_malloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/malloc/__simple_malloc.c') diff --git a/src/malloc/__simple_malloc.c b/src/malloc/__simple_malloc.c index c029342c..c8293908 100644 --- a/src/malloc/__simple_malloc.c +++ b/src/malloc/__simple_malloc.c @@ -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