This commit is contained in:
parent
1d5d1daa57
commit
779fda307a
@ -7,6 +7,7 @@
|
||||
#include <luna/Alignment.h>
|
||||
#include <luna/LinkedList.h>
|
||||
#include <luna/SafeArithmetic.h>
|
||||
#include <luna/ScopeGuard.h>
|
||||
#include <luna/String.h>
|
||||
#include <luna/SystemError.h>
|
||||
|
||||
@ -36,7 +37,9 @@ static DoublyLinkedList<HeapBlock> heap;
|
||||
static Result<HeapBlock*> allocate_pages(usize count)
|
||||
{
|
||||
u64 virt = TRY(KernelVM::alloc_several_pages(count));
|
||||
auto vm_guard = make_scope_guard([&] { KernelVM::free_several_pages(virt, count).value(); });
|
||||
void* const ptr = (void*)TRY(MemoryManager::alloc_at(virt, count, MMU::ReadWrite | MMU::NoExecute));
|
||||
vm_guard.deactivate();
|
||||
return (HeapBlock*)ptr;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace Scheduler
|
||||
auto thread_guard = make_scope_guard([&] { delete thread; });
|
||||
|
||||
u64 thread_stack_vm = TRY(KernelVM::alloc_several_pages(4));
|
||||
auto vm_guard = make_scope_guard([&] { KernelVM::free_several_pages(thread_stack_vm, 4); });
|
||||
auto vm_guard = make_scope_guard([&] { KernelVM::free_several_pages(thread_stack_vm, 4).value(); });
|
||||
|
||||
TRY(MemoryManager::alloc_at(thread_stack_vm, 4, MMU::NoExecute | MMU::ReadWrite));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user