Pigweed
Loading...
Searching...
No Matches
pw::allocator::internal::GenericBlockAllocator Class Reference

#include <block_allocator.h>

Public Member Functions

 GenericBlockAllocator (const GenericBlockAllocator &)=delete
 
GenericBlockAllocatoroperator= (const GenericBlockAllocator &)=delete
 
 GenericBlockAllocator (GenericBlockAllocator &&)=delete
 
GenericBlockAllocatoroperator= (GenericBlockAllocator &&)=delete
 
- Public Member Functions inherited from pw::Allocator
void * Allocate (Layout layout)
 
template<typename T , int &... ExplicitGuard, typename... Args>
T * New (Args &&... args)
 
template<typename T , int &... ExplicitGuard, typename... Args>
UniquePtr< T > MakeUnique (Args &&... args)
 
bool Resize (void *ptr, size_t new_size)
 
bool Resize (void *ptr, Layout layout, size_t new_size)
 
void * Reallocate (void *ptr, Layout new_layout)
 
void * Reallocate (void *ptr, Layout old_layout, size_t new_size)
 
allocator::AsPmrAllocator as_pmr ()
 
- Public Member Functions inherited from pw::Deallocator
const Capabilitiescapabilities () 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 Protected Member Functions

static void CrashOnAllocated (void *allocated)
 
static void CrashOnInvalidFree (void *freed)
 
static void CrashOnDoubleFree (void *freed)
 Crashes with an informational message that a given block was freed twice.
 

Additional Inherited Members

- Public Types inherited from pw::Deallocator
using Capabilities = allocator::Capabilities
 
using Capability = allocator::Capability
 
using Layout = allocator::Layout
 
- Protected Member Functions inherited from pw::Allocator
constexpr Allocator ()=default
 TODO(b/326509341): Remove when downstream consumers migrate.
 
constexpr Allocator (const Capabilities &capabilities)
 
- Protected Member Functions inherited from pw::Deallocator
constexpr Deallocator ()=default
 TODO(b/326509341): Remove when downstream consumers migrate.
 
constexpr Deallocator (const Capabilities &capabilities)
 
template<typename T >
UniquePtr< T > WrapUnique (T *ptr)
 

Detailed Description

Block-independent base class of BlockAllocator.

This class contains static methods which do not depend on the template parameters of BlockAllocator that are used to determine block/ type. This allows the methods to be defined in a separate source file and use macros that cannot be used in headers, e.g. PW_CHECK.

This class should not be used directly. Instead, use BlockAllocator or one of its specializations.

Member Function Documentation

◆ CrashOnAllocated()

static void pw::allocator::internal::GenericBlockAllocator::CrashOnAllocated ( void *  allocated)
staticprotected

Crashes with an informational message that a given block is allocated.

This method is meant to be called by SplitFreeListAllocators destructor. There must not be any outstanding allocations from an when it is destroyed.

◆ CrashOnInvalidFree()

static void pw::allocator::internal::GenericBlockAllocator::CrashOnInvalidFree ( void *  freed)
staticprotected

Crashes with an informational message that a given pointer does not belong to this allocator.

Member Data Documentation

◆ kCapabilities

constexpr Capabilities pw::allocator::internal::GenericBlockAllocator::kCapabilities
staticconstexpr
Initial value:
=
kImplementsGetRequestedLayout | kImplementsGetUsableLayout |
kImplementsGetAllocatedLayout | kImplementsGetCapacity |
kImplementsRecognizes

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