diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-12-03 09:13:53 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-12-03 09:13:53 +0000 |
| commit | 05fe50cefb12a7333a320a3d101dccdd13b8034a (patch) | |
| tree | d8857629506a93536eee255cbc8cd303473a81f5 /arch/x86_64/include | |
| parent | 6dff0ff5bcdd63de4a68f9c361acd0bace39b5ca (diff) | |
| download | teachos-05fe50cefb12a7333a320a3d101dccdd13b8034a.tar.xz teachos-05fe50cefb12a7333a320a3d101dccdd13b8034a.zip | |
Clear old memory in contructor
Diffstat (limited to 'arch/x86_64/include')
| -rw-r--r-- | arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp | 10 | ||||
| -rw-r--r-- | arch/x86_64/include/arch/memory/heap/memory_block.hpp | 15 |
2 files changed, 12 insertions, 13 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 5ff13ca..03b8828 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 @@ -121,16 +121,6 @@ namespace teachos::arch::memory::heap auto coalesce_free_memory_block(memory_block * previous_block, memory_block * current_block, void * pointer, std::size_t size) -> void; - /** - * @brief Clears the memory of the previous memory block header. - * - * @note Done so the given pointer can be reused to construct other classes into, without having the old values. - * Required because we cannot call delete, because it causes "undefined reference to `sbrk`". - * - * @param pointer Address we want to clear the memory block header at (16 bytes). - */ - auto clear_memory_block_header(void * pointer) -> void; - std::size_t heap_start; ///< Start of the allocatable heap area. std::size_t heap_end; ///< End of the allocatable heap area. memory_block * first; ///< First free entry in our memory. diff --git a/arch/x86_64/include/arch/memory/heap/memory_block.hpp b/arch/x86_64/include/arch/memory/heap/memory_block.hpp index c48d0cd..c62dd57 100644 --- a/arch/x86_64/include/arch/memory/heap/memory_block.hpp +++ b/arch/x86_64/include/arch/memory/heap/memory_block.hpp @@ -12,15 +12,24 @@ namespace teachos::arch::memory::heap struct memory_block { /** - * @brief Constructor, + * @brief Constructor. Clears all memory from the place it was allocated until the end (address + + * size). * * @param size Amount of free memory of this specific hole. * @param next Optional pointer to the next free memory. */ memory_block(std::size_t size, memory_block * next); - std::size_t size; ///< Amount of free memory this hole contains, has to always be atleast 16 bytes to hold the size - ///< variable and the pointer to the next hole. + /** + * @brief Destructor. Clears all internal memory. + * + * @note Used so the memory can be reused to construct other classes into, without having the old values. + * Required because we cannot call delete, because it causes "undefined reference to `sbrk`". + */ + ~memory_block(); + + std::size_t size; ///< Amount of free memory this hole contains, has to always be atleast 16 bytes to hold the + ///< size variable and the pointer to the next hole. memory_block * next; ///< Optional pointer to the next free memory, holds nullptr if there is none. }; } // namespace teachos::arch::memory::heap |
