#include <buddy_allocator.h>
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. | |
![]() | |
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 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 constexpr size_t | kAlignment |
static constexpr size_t | kBlockOverhead |
static constexpr size_t | kMinOuterSize |
![]() | |
constexpr bool | DoCheckInvariants (bool strict) const |
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.
StatusWithSize pw::allocator::internal::BuddyBlock::CanAlloc | ( | Layout | layout | ) | const |
Simplified version of Allocatable::CanAlloc
, as needed for UnorderedBucket::Remove
.