Pigweed
C/C++ API Reference
|
Public Member Functions | |
ChunkPool (ByteSpan region, const Layout &layout) | |
![]() | |
constexpr | Pool (const Capabilities &capabilities, const Layout &layout) |
constexpr const Layout & | layout () const |
void * | Allocate () |
template<typename T , int &... kExplicitGuard, std::enable_if_t<!std::is_array_v< T >, int > = 0, typename... Args> | |
T * | New (Args &&... args) |
template<typename T , int &... kExplicitGuard, typename ElementType = std::remove_extent_t<T>, std::enable_if_t< is_bounded_array_v< T >, int > = 0> | |
ElementType * | New () |
template<typename T , int &... kExplicitGuard, typename ElementType = std::remove_extent_t<T>, std::enable_if_t< is_unbounded_array_v< T >, int > = 0> | |
ElementType * | New () |
template<typename T , int &... kExplicitGuard, std::enable_if_t<!std::is_array_v< T >, int > = 0, typename... Args> | |
UniquePtr< T > | MakeUnique (Args &&... args) |
template<typename T , int &... kExplicitGuard, std::enable_if_t< is_bounded_array_v< T >, int > = 0> | |
UniquePtr< T > | MakeUnique () |
template<typename T , int &... kExplicitGuard, std::enable_if_t< is_unbounded_array_v< T >, int > = 0> | |
UniquePtr< T > | MakeUnique () |
![]() | |
constexpr const Capabilities & | capabilities () const |
bool | HasCapability (Capability capability) const |
Returns whether a given capability is enabled for this object. | |
void | Deallocate (void *ptr) |
void | Deallocate (void *ptr, Layout layout) |
template<typename ElementType > | |
void | DeleteArray (ElementType *ptr, size_t count) |
StatusWithSize | GetCapacity () const |
bool | IsEqual (const Deallocator &other) const |
template<typename T , int &... kExplicitGuard, std::enable_if_t<!std::is_array_v< T >, int > = 0> | |
void | Delete (T *ptr) |
template<typename T , int &... kExplicitGuard, typename ElementType = std::remove_extent_t<T>, std::enable_if_t< is_bounded_array_v< T >, int > = 0> | |
void | Delete (ElementType *ptr) |
template<typename T , int &... kExplicitGuard, typename ElementType = std::remove_extent_t<T>, std::enable_if_t< is_unbounded_array_v< T >, int > = 0> | |
void | Delete (ElementType *ptr, size_t count) |
Static Public Attributes | |
static constexpr Capabilities | kCapabilities |
static constexpr size_t | kMinSize = sizeof(void*) |
static constexpr size_t | kMinAlignment = alignof(void*) |
Private Member Functions | |
void * | DoAllocate () override |
void | DoDeallocate (void *ptr) override |
Result< Layout > | DoGetInfo (InfoType info_type, const void *ptr) const override |
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 , int &... kExplicitGuard, typename ElementType = std::remove_extent_t<T>, std::enable_if_t< is_unbounded_array_v< T >, int > = 0> | |
UniquePtr< T > | WrapUnique (ElementType *ptr, size_t size) |
![]() | |
template<typename T > | |
static constexpr bool | is_bounded_array_v |
template<typename T > | |
static constexpr bool | is_unbounded_array_v |
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. |
|
overrideprivatevirtual |
Returns a chunk of memory with this object's fixed layout.
Like pw::allocator::Allocate
, returns null if memory is exhausted.
The | allocated memory. |
Implements pw::allocator::Pool.
|
overrideprivate |
Releases a previously-allocated block of memory.
The given pointer must have been previously provided by this memory resource; otherwise the behavior is undefined.
[in] | ptr | Pointer to previously-allocated memory. |
|
overrideprivate |
|
staticconstexpr |