Skip to content

VERY experimental Nintendo Switch 2 emulator

C++

kernel/vm_manager: Handle case of identical calls to HeapAllocate

Lioncash5d0d85ba5504
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp
index 04d58bbf73..16f48471e8 100644
--- a/src/core/hle/kernel/vm_manager.cpp
+++ b/src/core/hle/kernel/vm_manager.cpp
@@ -261,6 +261,11 @@ ResultVal<VAddr> VMManager::HeapAllocate(u64 size) {
return ERR_OUT_OF_MEMORY;
}
+ // No need to do any additional work if the heap is already the given size.
+ if (size == GetCurrentHeapSize()) {
+ return MakeResult(heap_region_base);
+ }
+
if (heap_memory == nullptr) {
// Initialize heap
heap_memory = std::make_shared<std::vector<u8>>(size);