summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc/realloc.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-09-06 11:49:28 +0000
committerEric Andersen <andersen@codepoet.org>2003-09-06 11:49:28 +0000
commitcd34085f2c93441324f86172613a20cd899bddea (patch)
tree8a4a3dcc3b092904ea5f93ec49e600cc451d42bb /libc/stdlib/malloc/realloc.c
parentb9c0292271ea5e4dc583137d6c74dda605d1ae04 (diff)
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);
Diffstat (limited to 'libc/stdlib/malloc/realloc.c')
-rw-r--r--libc/stdlib/malloc/realloc.c12
1 files changed, 6 insertions, 6 deletions
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 <stdlib.h>
#include <string.h>
+#include <errno.h>
#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. */