aboutsummaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-03-16 13:55:09 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-03-16 13:55:09 +0100
commit72a54c9eb186735cad3f9e0b98cc2b2385220fee (patch)
tree000e9605e5ef84f9956fac3c06f18d6c2afb7a6c /kernel/include
parent5c251debfbef98360f2e00c938ef88d652469493 (diff)
downloadteachos-72a54c9eb186735cad3f9e0b98cc2b2385220fee.tar.xz
teachos-72a54c9eb186735cad3f9e0b98cc2b2385220fee.zip
kernel/heap: improve large alignment handling
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/kernel/memory/block_list_allocator.hpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/kernel/include/kernel/memory/block_list_allocator.hpp b/kernel/include/kernel/memory/block_list_allocator.hpp
index 977ce89..5e81c44 100644
--- a/kernel/include/kernel/memory/block_list_allocator.hpp
+++ b/kernel/include/kernel/memory/block_list_allocator.hpp
@@ -42,12 +42,21 @@ namespace kernel::memory
private:
struct block_header final
{
- std::size_t size;
+ std::size_t usable_size;
bool free;
block_header * next;
block_header * prev;
};
+ //! The size of the metadata required for each allocated block.
+ //!
+ //! Each allocated block carries a block header, like any unallocated one, but in addition also has a back-pointer
+ //! to the block header to support padding due to alignment.
+ constexpr auto static allocated_metadata_size = sizeof(block_header) + sizeof(block_header *);
+
+ //! The minimum number of bytes for an allocation.
+ constexpr auto static minimum_allocation_size = 16uz;
+
//! Try to expand the heap to accommodate the given size.
//!
//! @param delta The size to expand the heap by.