From b4cd7036bea6c6440fbbcdaebe53c864c87a5646 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 28 May 2024 14:56:06 -0400 Subject: integrate jkmalloc/prep for readonly --- src/stdlib/realloc.c | 46 ++-------------------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) (limited to 'src/stdlib/realloc.c') 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 #include "_stdlib.h" -#if 0 -#include -#include -#include -#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); } /*** -- cgit v1.2.1