summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lioncash2019-03-24 16:05:25 -0400
committerGravatar Lioncash2019-03-24 17:08:30 -0400
commitabdb81ccaf9e32c8b605af690922599d974a3ee7 (patch)
treec19fc95fe3c1d4103322afba8e5eedb8d288168f
parentkernel/vm_manager: Remove unused class variables (diff)
downloadyuzu-abdb81ccaf9e32c8b605af690922599d974a3ee7.tar.gz
yuzu-abdb81ccaf9e32c8b605af690922599d974a3ee7.tar.xz
yuzu-abdb81ccaf9e32c8b605af690922599d974a3ee7.zip
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.
-rw-r--r--src/core/hle/kernel/vm_manager.cpp5
1 files changed, 5 insertions, 0 deletions
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<VAddr> VMManager::HeapAllocate(u64 size) {
261 return ERR_OUT_OF_MEMORY; 261 return ERR_OUT_OF_MEMORY;
262 } 262 }
263 263
264 // No need to do any additional work if the heap is already the given size.
265 if (size == GetCurrentHeapSize()) {
266 return MakeResult(heap_region_base);
267 }
268
264 if (heap_memory == nullptr) { 269 if (heap_memory == nullptr) {
265 // Initialize heap 270 // Initialize heap
266 heap_memory = std::make_shared<std::vector<u8>>(size); 271 heap_memory = std::make_shared<std::vector<u8>>(size);