A specialized block used by the BuddyAllocator.
Buddy blocks have outer sizes that are powers of two. When smaller blocks are needed, a block is split into left and right halves of equal size. These half-blocks are "buddies", and when both are freed they are merged back into a single block.
Public Member Functions | |
| BuddyBlock (size_t outer_size) | |
| StatusWithSize | CanAlloc (Layout layout) const |
| BuddyBlock * | Split () |
| Splits a block in half and returns the new block. | |
Public Member Functions inherited from pw::allocator::BasicBlock< BuddyBlock > | |
| BasicBlock (const BasicBlock &other)=delete | |
| BasicBlock & | operator= (const BasicBlock &other)=delete |
| constexpr std::byte * | UsableSpace () |
| constexpr const std::byte * | UsableSpace () const |
| constexpr std::byte * | UsableSpaceUnchecked () |
| constexpr const std::byte * | UsableSpaceUnchecked () const |
| constexpr size_t | OuterSize () const |
| constexpr size_t | InnerSize () const |
| constexpr size_t | InnerSizeUnchecked () const |
| constexpr bool | IsValid () const |
| constexpr bool | CheckInvariants () const |
Like IsValid, but crashes if invalid. | |
Static Public Member Functions | |
| static BuddyBlock * | Merge (BuddyBlock *&&left, BuddyBlock *&&right) |
| Merges two blocks together. | |
Static Public Member Functions inherited from pw::allocator::BasicBlock< BuddyBlock > | |
| static constexpr Result< BuddyBlock * > | Init (ByteSpan region) |
| Creates the first block for a given memory region. | |
| static constexpr internal::copy_const_ptr_t< Ptr, BuddyBlock * > | FromUsableSpace (Ptr usable_space) |
| static constexpr size_t | OuterSizeFromInnerSize (size_t inner_size) |
| static constexpr size_t | InnerSizeFromOuterSize (size_t outer_size) |
Additional Inherited Members | |
Static Public Attributes inherited from pw::allocator::BasicBlock< BuddyBlock > | |
| static constexpr size_t | kAlignment |
| static constexpr size_t | kBlockOverhead |
| static constexpr size_t | kMinOuterSize |
Protected Member Functions inherited from pw::allocator::BasicBlock< BuddyBlock > | |
| constexpr bool | DoCheckInvariants (bool strict) const |
| StatusWithSize pw::allocator::internal::BuddyBlock::CanAlloc | ( | Layout | layout | ) | const |
Simplified version of Allocatable::CanAlloc, as needed for UnorderedBucket::Remove.