Allocator implementations that don’t allocate memory directly and instead rely on other allocators while providing additional behaviors.
Learn more: Forwarding allocator concept
Classes | |
class | pw::allocator::AllocatorAsPool |
Implementation of Pool that satisfies requests using an Allocator . More... | |
class | pw::allocator::FallbackAllocator |
class | pw::allocator::GuardedAllocator< BlockAllocatorType, LockType > |
class | pw::allocator::PmrAllocator |
class | pw::allocator::SynchronizedAllocator< LockType > |
struct | pw::allocator::AddTrackingAllocatorAsChild |
class | pw::allocator::TrackingAllocator< MetricsType > |
Typedefs | |
using | pw::allocator::NoSync = pw::sync::NoLock |
template<typename MetricsType > | |
using | pw::allocator::TrackingAllocatorImpl = TrackingAllocator< MetricsType > |
Functions | |
void * | pw::allocator::TrackingAllocator< MetricsType >::DoAllocate (Layout layout) override |
void | pw::allocator::TrackingAllocator< MetricsType >::DoDeallocate (void *ptr) override |
bool | pw::allocator::TrackingAllocator< MetricsType >::DoResize (void *ptr, size_t new_size) override |
void * | pw::allocator::TrackingAllocator< MetricsType >::DoReallocate (void *ptr, Layout new_layout) override |
Variables | |
static constexpr struct pw::allocator::AddTrackingAllocatorAsChild | pw::allocator::kAddTrackingAllocatorAsChild = {} |
using pw::allocator::NoSync = typedef pw::sync::NoLock |
Tag type used to indicate synchronization is NOT desired.
This can be useful with allocator parameters for module configuration, e.g. PW_MALLOC_LOCK_TYPE.
|
overrideprivatevirtual |
Allocates a block of memory with the specified size and alignment.
Returns nullptr
if the allocation cannot be made, or the layout
has a size of 0.
[in] | layout | Describes the memory to be allocated. |
Implements pw::Allocator.
|
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. |
|
overrideprivatevirtual |
Modifies the size of a previously-allocated block of memory.
Returns pointer to the modified block of memory, or nullptr
if the memory could not be modified.
The data stored by the memory being modified must be trivially copyable. If it is not, callers should themselves attempt to Resize
, then Allocate
, move the data, and Deallocate
as needed.
If nullptr
is returned, the block of memory is unchanged. In particular, if the new_layout
has a size of 0, the given pointer will NOT be deallocated.
TODO(b/331290408): This error condition needs to be better communicated to module users, who may assume the pointer is freed.
Unlike Resize
, providing a null pointer will return a new allocation.
If the request can be satisfied using Resize
, the alignment
parameter may be ignored.
[in] | ptr | Pointer to previously-allocated memory. |
[in] | new_layout | Describes the memory to be allocated. |
Reimplemented from pw::Allocator.
|
overrideprivatevirtual |
Modifies the size of an previously-allocated block of memory without copying any data.
Returns true if its size was changed without copying data to a new allocation; otherwise returns false.
In particular, it always returns true if the old_layout.size()
equals new_size
, and always returns false if the given pointer is null, the old_layout.size()
is 0, or the new_size
is 0.
[in] | ptr | Pointer to previously-allocated memory. |
[in] | new_size | Requested new size for the memory allocation. |
Reimplemented from pw::Allocator.