19#include "pw_allocator/block/detailed_block.h"
20#include "pw_allocator/block_allocator.h"
21#include "pw_allocator/bucket/fast_sorted.h"
22#include "pw_allocator/bucket/sorted.h"
23#include "pw_allocator/config.h"
25namespace pw::allocator {
30template <
typename OffsetType>
42template <
typename BlockType = WorstFitBlock<u
intptr_t>>
64 const BlockType* largest = large_bucket_.
empty()
67 return largest ==
nullptr ? 0 : largest->InnerSize();
73 if (block !=
nullptr) {
74 return BlockType::AllocFirst(std::move(block), layout);
77 if (block !=
nullptr) {
78 return BlockType::AllocFirst(std::move(block), layout);
86 if (!large_bucket_.
Remove(block)) {
87 std::ignore = small_bucket_.
Remove(block);
94 std::ignore = small_bucket_.
Add(block);
96 std::ignore = large_bucket_.
Add(block);
100 SmallBucket small_bucket_;
101 LargeBucket large_bucket_;
Definition: block_allocator.h:106
void Init(ByteSpan region)
Definition: block_allocator.h:310
Definition: detailed_block.h:88
Definition: fast_sorted.h:35
Definition: fast_sorted.h:151
Definition: worst_fit.h:43
constexpr WorstFitAllocator()=default
Constexpr constructor. Callers must explicitly call Init.
WorstFitAllocator(ByteSpan region)
Definition: worst_fit.h:59
size_t DoGetMaxAllocatable() override
Definition: worst_fit.h:63
BlockResult< BlockType > ChooseBlock(Layout layout) override
Definition: worst_fit.h:71
void ReserveBlock(BlockType &block) override
Definition: worst_fit.h:84
void RecycleBlock(BlockType &block) override
Definition: worst_fit.h:92
bool Remove(BlockType &block)
Definition: base.h:118
const BlockType * FindLargest() const
Definition: base.h:103
bool Add(BlockType &block)
Definition: base.h:89
constexpr bool empty() const
Returns whether this buckets contains any free blocks.
Definition: base.h:70
BlockType * RemoveCompatible(Layout layout)
Definition: base.h:129