Pigweed
C/C++ API Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Friends | List of all members
pw::allocator::ContiguousBlock< Derived > Class Template Reference
Inheritance diagram for pw::allocator::ContiguousBlock< Derived >:
pw::allocator::internal::ContiguousBase

Public Member Functions

constexpr Derived * Prev () const
 
constexpr Derived * Next () const
 

Protected Member Functions

constexpr Derived * DoSplitFirst (size_t new_inner_size)
 
constexpr Derived * DoSplitLast (size_t new_inner_size)
 
constexpr void DoMergeNext ()
 
constexpr bool DoCheckInvariants (bool strict) const
 Performs the ContiguousBlock invariant checks.
 

Friends

template<typename >
class PoisonableBlock
 

Detailed Description

template<typename Derived>
class pw::allocator::ContiguousBlock< Derived >

Mix-in for blocks that collectively represent a contiguous region of memory.

Contiguous blocks can be split into smaller blocks and merged when adjacent.

Block mix-ins are stateless and trivially constructible. See BasicBlock for details on how mix-ins can be combined to implement blocks.

This mix-in requires its derived type also derive from BasicBlock, and provide the following symbols:

Member Function Documentation

◆ DoMergeNext()

template<typename Derived >
constexpr void pw::allocator::ContiguousBlock< Derived >::DoMergeNext
constexprprotected

Merges this block with next block.

This method is static in order to consume and replace the given block pointer with a pointer to the new, larger block.

Precondition
The blocks must not be in use.

◆ DoSplitFirst()

template<typename Derived >
constexpr Derived * pw::allocator::ContiguousBlock< Derived >::DoSplitFirst ( size_t  new_inner_size)
constexprprotected

Split a block into two smaller blocks.

This method splits a block into a leading block of the given new_inner_size and a trailing block, and returns the trailing space as a new block.

Precondition
The block must not be in use.
The block must have enough usable space for the requested size.
The space remaining after a split can hold a new block.

◆ DoSplitLast()

template<typename Derived >
constexpr Derived * pw::allocator::ContiguousBlock< Derived >::DoSplitLast ( size_t  new_inner_size)
constexprprotected

Split a block into two smaller blocks.

This method splits a block into a leading block and a trailing block of the given new_inner_size, and returns the trailing space is returned as a new block.

Precondition
The block must not be in use.
The block must have enough usable space for the requested size.
The space remaining after a split can hold a new block.

◆ Next()

template<typename Derived >
constexpr Derived * pw::allocator::ContiguousBlock< Derived >::Next
constexpr
Returns
the block immediately after this one, or null if this is the last block.

◆ Prev()

template<typename Derived >
constexpr Derived * pw::allocator::ContiguousBlock< Derived >::Prev
constexpr
Returns
the block immediately before this one, or null if this is the first block.

The documentation for this class was generated from the following file: