1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:07:44 +00:00

LibJS: Make Heap aware of all CellAllocators

Also add a link from HeapBlock to their owning CellAllocator.
This fixes an issue where the Heap would skip over non-size-based
cell allocators.
This commit is contained in:
Andreas Kling 2023-12-23 15:13:51 +01:00
parent a31b988473
commit 11c968fa1f
6 changed files with 40 additions and 22 deletions

View file

@ -19,8 +19,11 @@ CellAllocator::CellAllocator(size_t cell_size)
Cell* CellAllocator::allocate_cell(Heap& heap)
{
if (!m_list_node.is_in_list())
heap.register_cell_allocator({}, *this);
if (m_usable_blocks.is_empty()) {
auto block = HeapBlock::create_with_cell_size(heap, m_cell_size);
auto block = HeapBlock::create_with_cell_size(heap, *this, m_cell_size);
m_usable_blocks.append(*block.leak_ptr());
}