aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/src
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2024-12-01 10:21:17 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2024-12-01 10:21:17 +0000
commit318fbff1717b291c81db8f9c4d5a84019fe2b4b9 (patch)
treea8302fd057bec7d91b77002e5acf80d4d0b4b31b /arch/x86_64/src
parentc1e7edabc1dfbe387546297720fc495837d38d33 (diff)
downloadteachos-318fbff1717b291c81db8f9c4d5a84019fe2b4b9.tar.xz
teachos-318fbff1717b291c81db8f9c4d5a84019fe2b4b9.zip
Adjust allocate
Diffstat (limited to 'arch/x86_64/src')
-rw-r--r--arch/x86_64/src/memory/heap/linked_list_allocator.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/arch/x86_64/src/memory/heap/linked_list_allocator.cpp b/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
index f4ba5e2..a2a8c79 100644
--- a/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
+++ b/arch/x86_64/src/memory/heap/linked_list_allocator.cpp
@@ -22,8 +22,8 @@ namespace teachos::arch::memory::heap
auto linked_list_allocator::allocate(std::size_t size) -> void *
{
- memory_hole * previous = nullptr;
- auto current = first;
+ auto & previous = first;
+ auto & current = first;
while (current != nullptr)
{
if (current->size > size)
@@ -32,10 +32,14 @@ namespace teachos::arch::memory::heap
}
else if (current->size == size)
{
- if (previous != nullptr)
+ if (previous != current)
{
previous->next = current->next;
}
+ else
+ {
+ current = current->next;
+ }
delete current;
return static_cast<void *>(current);
}