From cd34085f2c93441324f86172613a20cd899bddea Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Sat, 6 Sep 2003 11:49:28 +0000 Subject: Fix errno values. Fix MALLOC_GLIBC_COMPAT handling in malloc/malloc.c, which was reversed. Provide more consistancy between implementations. Handle it when people do stupid things like malloc(-1); --- libc/stdlib/malloc/realloc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libc/stdlib/malloc/realloc.c') diff --git a/libc/stdlib/malloc/realloc.c b/libc/stdlib/malloc/realloc.c index d4e0d9cb4..9e6f880fe 100644 --- a/libc/stdlib/malloc/realloc.c +++ b/libc/stdlib/malloc/realloc.c @@ -13,6 +13,7 @@ #include #include +#include #include "malloc.h" #include "heap.h" @@ -25,13 +26,12 @@ realloc (void *mem, size_t new_size) char *base_mem; /* Check for special cases. */ - if (! new_size) - { + if (!mem) + return malloc(new_size); + if (!new_size) { free (mem); - return 0; - } - else if (! mem) - return malloc (new_size); + return (malloc(new_size)); + } /* Normal realloc. */ -- cgit v1.2.3