aboutsummaryrefslogtreecommitdiff
path: root/arch/x86_64/include
diff options
context:
space:
mode:
authorMatteo Gmür <matteo.gmuer1@ost.ch>2025-02-23 10:27:46 +0000
committerMatteo Gmür <matteo.gmuer1@ost.ch>2025-02-23 10:27:46 +0000
commitfcc586a846562e024c1cd77042634494cf380bd8 (patch)
treedf1ae9805ce83ecaefae0cdd52f9c79637a35a7b /arch/x86_64/include
parent93cc8aa1c0e4ba991f0503c609702e1c63a240c7 (diff)
downloadteachos-fcc586a846562e024c1cd77042634494cf380bd8.tar.xz
teachos-fcc586a846562e024c1cd77042634494cf380bd8.zip
Adjust linked list allocator to allow for deallocation without passing size parameter and with arbitrary size
Diffstat (limited to 'arch/x86_64/include')
-rw-r--r--arch/x86_64/include/arch/memory/heap/bump_allocator.hpp15
-rw-r--r--arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp5
-rw-r--r--arch/x86_64/include/arch/memory/heap/heap_allocator.hpp6
-rw-r--r--arch/x86_64/include/arch/memory/heap/linked_list_allocator.hpp21
4 files changed, 13 insertions, 34 deletions
diff --git a/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp b/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp
index d5f4561..74734af 100644
--- a/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp
+++ b/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp
@@ -28,23 +28,14 @@ namespace teachos::arch::memory::heap
// Nothing to do
}
- /**
- * @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 * override;
/**
- * @brief Deallocates heap memory at the specified location.
- *
- * @note Simply does nothing, because this allocator leaks all memory.
+ * @copybrief heap_allocator::deallocate
*
- * @param pointer Pointer to the location which should be deallocated.
- * @param size Size of the underlying memory area we want to deallocate.
+ * @note Simply does nothing, because this allocator leaks all memory
*/
- auto deallocate(void * pointer, std::size_t size) -> void override;
+ auto deallocate(void * pointer) -> void override;
private:
std::size_t heap_start; ///< Start of the allocatable heap area
diff --git a/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp b/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp
index 6719bec..a1621b5 100644
--- a/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp
+++ b/arch/x86_64/include/arch/memory/heap/global_heap_allocator.hpp
@@ -48,13 +48,12 @@ namespace teachos::arch::memory::heap
static auto allocate(std::size_t size) -> void *;
/**
- * @brief Deallocated the given amount of memory starting from the given pointer address.
+ * @brief Deallocated all memory associated with the memory area starting from the given pointer address.
* Simply forwards the call to the deallocate method of the registered heap_allocation implementation
*
* @param pointer Previously allocated memory area, that should now be freed
- * @param size Size of the memory area we want to free
*/
- static auto deallocate(void * pointer, std::size_t size) -> void;
+ static auto deallocate(void * pointer) -> void;
private:
static heap_allocator * allocator_instance; ///< Instance used to actually allocate and deallocate
diff --git a/arch/x86_64/include/arch/memory/heap/heap_allocator.hpp b/arch/x86_64/include/arch/memory/heap/heap_allocator.hpp
index 1519155..01657f2 100644
--- a/arch/x86_64/include/arch/memory/heap/heap_allocator.hpp
+++ b/arch/x86_64/include/arch/memory/heap/heap_allocator.hpp
@@ -31,12 +31,12 @@ namespace teachos::arch::memory::heap
virtual auto allocate(std::size_t size) -> void * = 0;
/**
- * @brief Deallocated the given amount of memory starting from the given pointer address
+ * @brief Deallocates all memory associated with the given pointer address.
+ * Simply deallocates the amount of memory created with the corresponding call to allocate
*
* @param pointer Previously allocated memory area, that should now be freed
- * @param size Size of the memory area we want to free
*/
- virtual auto deallocate(void * pointer, std::size_t size) -> void = 0;
+ virtual auto deallocate(void * pointer) -> void = 0;
};
} // namespace teachos::arch::memory::heap
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 966e28e..d53756d 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,7 +22,7 @@ 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.
+ * @copybrief heap_allocator::allocate
*
* @note The specified size is used to find a free memory block with the exact same size, meaning we can remove that
* free memory block from the free list and simply return its address. Or it has to be big enough to hold the size
@@ -32,21 +32,10 @@ namespace teachos::arch::memory::heap
* they received more memory than wanted. Therefore the memory would simply be unused and because it is neither
* allocated nor deallocated would never be indexed by the free memory list. We would therefore permanently loose
* that memory, to prevent that allocation into free memory blocks like that are impossible.
- *
- * @param size Amount of memory to allocate.
- * @return Address of the first byte to the allocated area
*/
- auto allocate(std::size_t size) -> void *;
+ auto allocate(std::size_t size) -> void * override;
- /**
- * @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(void * pointer, std::size_t size) -> void;
+ auto deallocate(void * pointer) -> void override;
private:
/**
@@ -79,8 +68,8 @@ namespace teachos::arch::memory::heap
*
* @return Previous start address of the memory block we just split, because it can now be used for the allocation.
*/
- auto split_free_memory_block(memory_block * previous_block, memory_block * current_block,
- std::size_t size) -> void *;
+ auto split_free_memory_block(memory_block * previous_block, memory_block * current_block, std::size_t size)
+ -> void *;
/**
* @brief Removes a free memory block from the free list and returns its address so the caller can allocate into it.