diff --git a/source/memory_mapping.cpp b/source/memory_mapping.cpp index 4c2aadf..efab512 100644 --- a/source/memory_mapping.cpp +++ b/source/memory_mapping.cpp @@ -433,6 +433,25 @@ void MemoryMapping_free(void *ptr) { } } +uint32_t MemoryMapping_MEMGetAllocatableSize() { + return MemoryMapping_MEMGetAllocatableSizeEx(4); +} + +uint32_t MemoryMapping_MEMGetAllocatableSizeEx(uint32_t align) { + uint32_t res = 0; + for (int32_t i = 0; /* waiting for a break */; i++) { + if (mem_mapping[i].physical_addresses == NULL) { + break; + } + uint32_t curRes = MEMGetAllocatableSizeForExpHeapEx((MEMHeapHandle) mem_mapping[i].effective_start_address, align); + DEBUG_FUNCTION_LINE("heap at %08X MEMGetAllocatableSizeForExpHeapEx: %d KiB", mem_mapping[i].effective_start_address, curRes / 1024); + if (curRes > res) { + res = curRes; + } + } + return res; +} + uint32_t MemoryMapping_GetFreeSpace() { uint32_t res = 0; for (int32_t i = 0; /* waiting for a break */; i++) { diff --git a/source/memory_mapping.h b/source/memory_mapping.h index c5172f5..72d8b15 100644 --- a/source/memory_mapping.h +++ b/source/memory_mapping.h @@ -160,10 +160,14 @@ const memory_values_t mem_vals_heap[] = { // overridden. // {0x28000000 + 0x00000000, 0x28000000 + 0x0A000000}, // - {0, 0} + {0, 0} }; +uint32_t MemoryMapping_MEMGetAllocatableSize(); + +uint32_t MemoryMapping_MEMGetAllocatableSizeEx(uint32_t align); + bool MemoryMapping_isMemoryMapped(); void MemoryMapping_setupMemoryMapping();