From abdb81ccaf9e32c8b605af690922599d974a3ee7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 24 Mar 2019 16:05:25 -0400 Subject: kernel/vm_manager: Handle case of identical calls to HeapAllocate In cases where HeapAllocate is called with the same size of the current heap, we can simply do nothing and return successfully. This avoids doing work where we otherwise don't have to. This is also what the kernel itself does in this scenario. --- src/core/hle/kernel/vm_manager.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 04d58bbf7..16f48471e 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -261,6 +261,11 @@ ResultVal 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>(size); -- cgit v1.2.3