summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc/realloc.c
diff options
context:
space:
mode:
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. */