1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

LibC: Switch ChunkedBlock to IntrusiveList from InlineLinkedList

This commit is contained in:
Brian Gianforcaro 2021-06-03 02:23:11 -07:00 committed by Andreas Kling
parent 48da8a568d
commit e37f39d980
2 changed files with 21 additions and 22 deletions

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/InlineLinkedList.h>
#include <AK/IntrusiveList.h>
#include <AK/Types.h>
#define MAGIC_PAGE_HEADER 0x42657274 // 'Bert'
@ -45,9 +45,7 @@ struct FreelistEntry {
FreelistEntry* next;
};
struct ChunkedBlock
: public CommonHeader
, public InlineLinkedListNode<ChunkedBlock> {
struct ChunkedBlock : public CommonHeader {
static constexpr size_t block_size = 64 * KiB;
static constexpr size_t block_mask = ~(block_size - 1);
@ -59,8 +57,7 @@ struct ChunkedBlock
m_free_chunks = chunk_capacity();
}
ChunkedBlock* m_prev { nullptr };
ChunkedBlock* m_next { nullptr };
IntrusiveListNode<ChunkedBlock> m_list_node;
size_t m_next_lazy_freelist_index { 0 };
FreelistEntry* m_freelist { nullptr };
size_t m_free_chunks { 0 };
@ -75,4 +72,6 @@ struct ChunkedBlock
size_t free_chunks() const { return m_free_chunks; }
size_t used_chunks() const { return chunk_capacity() - m_free_chunks; }
size_t chunk_capacity() const { return (block_size - sizeof(ChunkedBlock)) / m_size; }
using List = IntrusiveList<ChunkedBlock, RawPtr<ChunkedBlock>, &ChunkedBlock::m_list_node>;
};