#include #include #include "memory_defs.h" #include "c_retain_vars.h" DECL_FUNCTION(MEMHeapHandle, MEMCreateFrmHeapEx, void* address, uint32_t size, uint16_t flags) { MEMHeapHandle result = real_MEMCreateFrmHeapEx(address,size,flags); for(int i = 0; i 0x3B600000 && (uint32_t) address < 0x11000000){ //We are pretty sure this the MEM2 default heap. //Let's try to increase it's capacity. //uint32_t maximumSize = 0x50000000 - (uint32_t) address; uint32_t maximumSize = 0x80000000; //uint32_t maximumSize = size + 0x500000; maximumSize -= 0x500000; // remove 5MB, just to leave at least _some_ space. uint32_t curSizeTest = maximumSize; do{ if(curSizeTest < oldSize){ break; } result = real_MEMCreateExpHeapEx(address,curSizeTest,flags); if(result == 0){ // On failure: maximumSize -= 0x100000; // reduce by 1MB and try again. }else{ allocated = true; break; } }while(!allocated); // Until the allocation was successful, or we are below default size. }*/ if(!allocated || result == 0) { result = real_MEMCreateExpHeapEx(address,size,flags); } for(int i = 0; i