diff options
Diffstat (limited to 'arch/x86_64/include')
| -rw-r--r-- | arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp b/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp index a742018..da7fc37 100644 --- a/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp +++ b/arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp @@ -22,12 +22,42 @@ namespace teachos::arch::memory::heap linked_list_allocator(std::size_t heap_start, std::size_t heap_end); /** + * @brief Allocates the specified amount of memory in the heap. + * + * @param size Amount of memory to allocate. + * @return Address of the first byte to the allocated area + */ + auto allocate(std::size_t size) -> void *; + + /** + * @brief Deallocates heap memory at the specified location. + * + * @note Simply does nothing, because this allocator leaks all memory. + * + * @param pointer Pointer to the location which should be deallocated. + * @param size Size of the underlying memory area we want to deallocate. + */ + auto deallocate(uint8_t * pointer, std::size_t size) -> void; + + private: + /** * @brief Returns the smallest allocatable block of heap memory. * * @return Smallest allocatable block of heap memory. */ auto constexpr min_allocatable_size() -> std::size_t { return sizeof(memory_hole); } + /** + * @brief Splits the given hole into two, where the latter block keeps beeing free and the first part will be used + * for the allocation. + * + * @param current_hole Hole we want to split. + * @param new_hole New hole created by the split. + * + * @return Address of the hole we just split. + */ + auto split_hole(memory_hole & current_hole, memory_hole *& new_hole) -> void *; + std::size_t heap_start; ///< Start of the allocatable heap area std::size_t heap_end; ///< End of the allocatable heap area memory_hole first; ///< First free entry in our memory |
