From 1a9d3e3e5438f2800e6e5ce0b22d1b4ac6745e00 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 28 Jun 2021 13:46:59 +0200 Subject: [PATCH] Kernel: Add a sanity check for CHUNK_SIZE Also fixes a spelling mistake in the same file. --- Kernel/Heap/Heap.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Kernel/Heap/Heap.h b/Kernel/Heap/Heap.h index 58f55db983..794568bd8a 100644 --- a/Kernel/Heap/Heap.h +++ b/Kernel/Heap/Heap.h @@ -27,6 +27,8 @@ class Heap { u8 data[0]; }; + static_assert(CHUNK_SIZE >= sizeof(AllocationHeader)); + static size_t calculate_chunks(size_t memory_size) { return (sizeof(u8) * memory_size) / (sizeof(u8) * CHUNK_SIZE + 1); @@ -61,7 +63,7 @@ public: Optional first_chunk; - // Choose the right politic for allocation. + // Choose the right policy for allocation. constexpr u32 best_fit_threshold = 128; if (chunks_needed < best_fit_threshold) { first_chunk = m_bitmap.find_first_fit(chunks_needed);