Pigweed
|
#include <chunk_pool.h>
Public Member Functions | |
ChunkPool (ByteSpan region, const Layout &layout) | |
![]() | |
constexpr | Pool (const Capabilities &capabilities, const Layout &layout) |
const Layout & | layout () const |
void * | Allocate () |
![]() | |
const Capabilities & | capabilities () const |
bool | HasCapability (Capability capability) const |
Returns whether a given capabilityis enabled for this object. | |
void | Deallocate (void *ptr) |
void | Deallocate (void *ptr, Layout layout) |
template<typename T > | |
void | Delete (T *ptr) |
StatusWithSize | GetCapacity () const |
bool | IsEqual (const Deallocator &other) const |
Static Public Attributes | |
static constexpr Capabilities | kCapabilities |
static constexpr size_t | kMinSize = sizeof(void*) |
static constexpr size_t | kMinAlignment = alignof(void*) |
Additional Inherited Members | |
![]() | |
using | Capabilities = allocator::Capabilities |
using | Capability = allocator::Capability |
using | Layout = allocator::Layout |
![]() | |
constexpr | Deallocator ()=default |
TODO(b/326509341): Remove when downstream consumers migrate. | |
constexpr | Deallocator (const Capabilities &capabilities) |
template<typename T > | |
UniquePtr< T > | WrapUnique (T *ptr) |
Implementation of Pool
that uses a list of free chunks.
The first sizeof(void*)
bytes of each free chunk is used to store a pointer to the next free chunk, or null for the last free chunk.
pw::allocator::ChunkPool::ChunkPool | ( | ByteSpan | region, |
const Layout & | layout | ||
) |
Construct a Pool
that allocates from a region of memory.
region | The memory to allocate from. Must be large enough to allocate at least one chunk with the given layout. |
layout | The size and alignment of the memory to be returned from this pool. |
|
staticconstexpr |