summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc-930716
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-08-08 10:30:12 +0000
committerEric Andersen <andersen@codepoet.org>2003-08-08 10:30:12 +0000
commita4ba059034124cbdc0232b805a7fdf07994c8618 (patch)
tree404770803bdcb542f8f5fc82baaf07509e5a06e9 /libc/stdlib/malloc-930716
parentea9f6e1e2d60bac4e2c7f1fb9ee98f581a7c6229 (diff)
Add in a MALLOC_GLIBC_COMPAT option to let people decide if they
want glibc style malloc(0) behavior
Diffstat (limited to 'libc/stdlib/malloc-930716')
-rw-r--r--libc/stdlib/malloc-930716/malloc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/stdlib/malloc-930716/malloc.c b/libc/stdlib/malloc-930716/malloc.c
index 2467da41c..dce32b90b 100644
--- a/libc/stdlib/malloc-930716/malloc.c
+++ b/libc/stdlib/malloc-930716/malloc.c
@@ -160,9 +160,14 @@ void * __malloc_unlocked (size_t size)
size_t log, block, blocks, i, lastblocks, start;
struct list *next;
+#if defined(__MALLOC_GLIBC_COMPAT__)
+ if (size == 0)
+ size++;
+#else
/* Some programs will call malloc (0). Lets be strict and return NULL */
if (size == 0)
return NULL;
+#endif
if (size < sizeof (struct list))
size = sizeof (struct list);