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 {
28template <
typename OffsetType>
29using WorstFitBlock = DetailedBlock<OffsetType, GenericFastSortedItem>;
40template <
typename BlockType = WorstFitBlock<u
intptr_t>>
58 BlockType* block = large_bucket_.RemoveCompatible(layout);
59 if (block !=
nullptr) {
60 return BlockType::AllocFirst(std::move(block), layout);
62 block = small_bucket_.RemoveCompatible(layout);
63 if (block !=
nullptr) {
64 return BlockType::AllocFirst(std::move(block), layout);
72 if (!large_bucket_.Remove(block)) {
73 std::ignore = small_bucket_.Remove(block);
80 std::ignore = small_bucket_.Add(block);
82 std::ignore = large_bucket_.Add(block);
Definition: block_allocator.h:104
void Init(ByteSpan region)
Definition: block_allocator.h:281
Definition: fast_sorted.h:142
Definition: worst_fit.h:41
constexpr WorstFitAllocator()=default
Constexpr constructor. Callers must explicitly call Init.
WorstFitAllocator(ByteSpan region)
Definition: worst_fit.h:53
BlockResult< BlockType > ChooseBlock(Layout layout) override
Definition: worst_fit.h:57
void ReserveBlock(BlockType &block) override
Definition: worst_fit.h:70
void RecycleBlock(BlockType &block) override
Definition: worst_fit.h:78