diff options
Diffstat (limited to 'arch/x86_64/src/memory')
| -rw-r--r-- | arch/x86_64/src/memory/heap/global_heap_allocator.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/arch/x86_64/src/memory/heap/global_heap_allocator.cpp b/arch/x86_64/src/memory/heap/global_heap_allocator.cpp index 11848ed..4e3a274 100644 --- a/arch/x86_64/src/memory/heap/global_heap_allocator.cpp +++ b/arch/x86_64/src/memory/heap/global_heap_allocator.cpp @@ -5,13 +5,17 @@ namespace teachos::arch::memory::heap { - static global_heap_allocator::allocator = linked_list_allocator{HEAP_START, HEAP_START + HEAP_SIZE}; - - auto global_heap_allocator::allocate(std::size_t size) -> void * { return allocator.allocate(size); } + auto global_heap_allocator::allocate(std::size_t size) -> void * { return get_underlying_allocator().allocate(size); } auto global_heap_allocator::deallocate(void * pointer, std::size_t size) -> void { - allocator.deallocate(pointer, size); + get_underlying_allocator().deallocate(pointer, size); + } + + auto global_heap_allocator::get_underlying_allocator() -> linked_list_allocator & + { + static linked_list_allocator allocator{HEAP_START, HEAP_START + HEAP_SIZE}; + return allocator; } } // namespace teachos::arch::memory::heap |
