Browse Source

add support for __MALLOC_GLIBC_COMPAT__ (malloc(0) == NULL) so the malloc test wont fail

Mike Frysinger 19 years ago
parent
commit
629ec28ed6
1 changed files with 4 additions and 0 deletions
  1. 4 0
      libc/stdlib/malloc-standard/malloc.c

+ 4 - 0
libc/stdlib/malloc-standard/malloc.c

@@ -827,6 +827,10 @@ void* malloc(size_t bytes)
     mchunkptr       bck;              /* misc temp for linking */
     void *          sysmem;
 
+#if !defined(__MALLOC_GLIBC_COMPAT__)
+    if (!bytes) return NULL;
+#endif
+
     LOCK;
     av = get_malloc_state();
     /*