diff --git a/includes/pcsx2/memalloc.c b/includes/pcsx2/memalloc.c index 811338e..bc5ec7d 100644 --- a/includes/pcsx2/memalloc.c +++ b/includes/pcsx2/memalloc.c @@ -25,7 +25,7 @@ typedef struct { #define PMPA_POINTER_IS_IN_POOL(a) PMPA_POINTER_IS_IN_RANGE(a, PMPA_FIRST_VALID_ADDRESS_IN_POOL, master_memory_block_size) #ifndef MEM_CUSTOM_TOTAL_SIZE -#define MEM_CUSTOM_TOTAL_SIZE 1000000 +#define MEM_CUSTOM_TOTAL_SIZE 100000 #endif static pmpa_memory_block master_memory_block[MEM_CUSTOM_TOTAL_SIZE] = { 0 }; @@ -53,7 +53,7 @@ static void concat_sequential_blocks(pmpa_memory_block *memory_block, bool is_al static pmpa_memory_block *find_first_block(bool is_allocated, pmpa_memory_int min_size) { - pmpa_memory_block *memory_block = master_memory_block; + pmpa_memory_block *memory_block = PMPA_FIRST_VALID_ADDRESS_IN_POOL; while (PMPA_POINTER_IS_IN_POOL(memory_block + sizeof(pmpa_memory_block))) { /* If we're trying to find an block, then defragment the pool as we go along. @@ -202,4 +202,24 @@ void operator delete(void* p) { FreeMemBlock(p); } -#endif \ No newline at end of file +#endif + +void* __wrap_malloc(size_t size) +{ + return pmpa_malloc(size); +} + +void* __wrap_calloc(size_t n, size_t size) +{ + return pmpa_calloc(n, size); +} + +void* __wrap_realloc(void* p, size_t size) +{ + return pmpa_realloc(p, size); +} + +void __wrap_free(void* ptr) +{ + return pmpa_free(ptr); +} diff --git a/includes/pcsx2/pcsx2f_api.h b/includes/pcsx2/pcsx2f_api.h index e29f650..323e715 100644 --- a/includes/pcsx2/pcsx2f_api.h +++ b/includes/pcsx2/pcsx2f_api.h @@ -29,7 +29,6 @@ struct PluginInfo uint32_t CLEOScriptsAddr; uint32_t CLEOScriptsSize; - uint32_t ps2sdk_libc_init; uint32_t ps2sdk_libcpp_init; uint32_t __cxa_atexit; diff --git a/makefile.lua b/makefile.lua index 3864fdf..701db56 100644 --- a/makefile.lua +++ b/makefile.lua @@ -18,7 +18,7 @@ ASFLAGS = $(CFLAGS) BASE_ADDRESS = %s EE_LINKFILE = linkfile EE_LIBS += %s -EE_LDFLAGS = -Wl,--entry=init -Wl,--no-relax -Wl,-Map,../data/%s.map -Wl,'--defsym=BASE_ADDRESS=$(BASE_ADDRESS)' +EE_LDFLAGS = -Wl,--entry=init -Wl,--wrap,malloc -Wl,--wrap,calloc -Wl,--wrap,realloc -Wl,--wrap,free -Wl,--no-relax -Wl,--no-relax -Wl,-Map,../data/%s.map -Wl,'--defsym=BASE_ADDRESS=$(BASE_ADDRESS)' all: clean main-build diff --git a/source/makefile b/source/makefile index 4b6c5fe..373e6ce 100644 --- a/source/makefile +++ b/source/makefile @@ -8,7 +8,7 @@ ASFLAGS = $(CFLAGS) BASE_ADDRESS = 0x05000000 EE_LINKFILE = linkfile EE_LIBS += -l:libstdc++.a -l:libm.a -EE_LDFLAGS = -Wl,--entry=init -Wl,--no-relax -Wl,-Map,../data/PLUGINS/cleo.map -Wl,'--defsym=BASE_ADDRESS=$(BASE_ADDRESS)' +EE_LDFLAGS = -Wl,--entry=init -Wl,--wrap,malloc -Wl,--wrap,calloc -Wl,--wrap,realloc -Wl,--wrap,free -Wl,--no-relax -Wl,--no-relax -Wl,-Map,../data/PLUGINS/cleo.map -Wl,'--defsym=BASE_ADDRESS=$(BASE_ADDRESS)' all: clean main-build