summaryrefslogtreecommitdiff
path: root/src/stdlib/realloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/realloc.c')
-rw-r--r--src/stdlib/realloc.c46
1 files changed, 2 insertions, 44 deletions
diff --git a/src/stdlib/realloc.c b/src/stdlib/realloc.c
index 12729f87..17696bbf 100644
--- a/src/stdlib/realloc.c
+++ b/src/stdlib/realloc.c
@@ -1,28 +1,6 @@
-#if ((!defined _POSIX_C_SOURCE) || (_POSIX_C_SOURCE < 199309L))
-#undef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 199309L /* force mmap() constants */
-#define POSIX_FORCED
-#endif
-
#include <stdlib.h>
#include "_stdlib.h"
-#if 0
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#endif
-
-#ifdef POSIX_FORCED
-#include "_syscall.h"
-#define mmap(_a, _l, _p, _fl, _fd, _o) __scall6(mmap, _a, _l, _p, _fl, _fd, _o)
-#define open(_p, _a, _m) __scall3(open, _p, _a, _m)
-#endif
-
-#define O_RDWR 02
-#define PROT_READ 0x1
-#define PROT_WRITE 0x2
-#define MAP_PRIVATE 0x02
-#define MAP_FAILED (void*)(-1)
+#include "_jkmalloc.h"
/** change the amount of memory allocated **/
@@ -30,27 +8,7 @@ void * realloc(void * ptr, size_t size)
{
SIGNAL_SAFE(0);
- /* FIXME: forward dependency on POSIX.1b-1993, non-std /dev/zero */
- static int backing = -1;
-
- if (backing == -1) {
- backing = open("/dev/zero", O_RDWR /* | O_CLOEXEC */, 0);
- }
-
- if (ptr == NULL) {
- /* malloc() */
- ptr = (void*)(long)mmap(NULL, size, PROT_READ | PROT_WRITE,
- MAP_PRIVATE, backing, 0);
- if (ptr == MAP_FAILED) {
- return NULL;
- }
- } else if (size == 0) {
- /* free() */
- }
-
- /* TODO: reallocate */
-
- return ptr;
+ return __jkmalloc(NULL, NULL, 0, ptr, 1, size, 0);
}
/***