mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-11-02 05:17:52 +00:00
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.
This commit is contained in:
parent
9f63acac0f
commit
abdb81ccaf
1 changed files with 5 additions and 0 deletions
|
@ -261,6 +261,11 @@ ResultVal<VAddr> VMManager::HeapAllocate(u64 size) {
|
||||||
return ERR_OUT_OF_MEMORY;
|
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) {
|
if (heap_memory == nullptr) {
|
||||||
// Initialize heap
|
// Initialize heap
|
||||||
heap_memory = std::make_shared<std::vector<u8>>(size);
|
heap_memory = std::make_shared<std::vector<u8>>(size);
|
||||||
|
|
Loading…
Reference in a new issue