diff --git a/AK/BumpAllocator.h b/AK/BumpAllocator.h index 94af3b251cb..9f67fe46278 100644 --- a/AK/BumpAllocator.h +++ b/AK/BumpAllocator.h @@ -13,15 +13,15 @@ namespace AK { -template +template class BumpAllocator { public: BumpAllocator() { if constexpr (use_mmap) - m_chunk_size = 4 * MiB; + m_chunk_size = chunk_size; else - m_chunk_size = kmalloc_good_size(4 * KiB); + m_chunk_size = kmalloc_good_size(chunk_size); } ~BumpAllocator() @@ -137,8 +137,10 @@ protected: // size_t m_allocations_in_previous_chunk { 0 }; }; -template -class UniformBumpAllocator : protected BumpAllocator { +template +class UniformBumpAllocator : protected BumpAllocator { + using Allocator = BumpAllocator; + public: UniformBumpAllocator() = default; ~UniformBumpAllocator() @@ -148,19 +150,19 @@ public: T* allocate() { - return BumpAllocator::template allocate(); + return Allocator::template allocate(); } void deallocate_all() { destroy_all(); - BumpAllocator::deallocate_all(); + Allocator::deallocate_all(); } void destroy_all() { this->for_each_chunk([&](auto chunk) { - auto base_ptr = align_up_to(chunk + sizeof(typename BumpAllocator::ChunkHeader), alignof(T)); + auto base_ptr = align_up_to(chunk + sizeof(typename Allocator::ChunkHeader), alignof(T)); FlatPtr end_offset = this->m_chunk_size; if (chunk == this->m_current_chunk) end_offset = this->m_byte_offset_into_current_chunk;