ESPHome  2024.4.0
Public Types | Public Member Functions
esphome::ExternalRAMAllocator< T > Class Template Reference

An STL allocator that uses SPI RAM. More...

#include <helpers.h>

Public Types

enum  Flags { NONE = 0, REFUSE_INTERNAL = 1 << 0, ALLOW_FAILURE = 1 << 1 }
 
using value_type = T
 

Public Member Functions

 ExternalRAMAllocator ()=default
 
 ExternalRAMAllocator (Flags flags)
 
template<class U >
constexpr ExternalRAMAllocator (const ExternalRAMAllocator< U > &other)
 
T * allocate (size_t n)
 
void deallocate (T *p, size_t n)
 

Detailed Description

template<class T>
class esphome::ExternalRAMAllocator< T >

An STL allocator that uses SPI RAM.

By setting flags, it can be configured to don't try main memory if SPI RAM is full or unavailable, and to return nulllptr instead of aborting when no memory is available.

Definition at line 645 of file helpers.h.

Member Typedef Documentation

◆ value_type

template<class T>
using esphome::ExternalRAMAllocator< T >::value_type = T

Definition at line 647 of file helpers.h.

Member Enumeration Documentation

◆ Flags

template<class T>
enum esphome::ExternalRAMAllocator::Flags
Enumerator
NONE 
REFUSE_INTERNAL 

Refuse falling back to internal memory when external RAM is full or unavailable.

ALLOW_FAILURE 

Don't abort when memory allocation fails.

Definition at line 649 of file helpers.h.

Constructor & Destructor Documentation

◆ ExternalRAMAllocator() [1/3]

template<class T>
esphome::ExternalRAMAllocator< T >::ExternalRAMAllocator ( )
default

◆ ExternalRAMAllocator() [2/3]

template<class T>
esphome::ExternalRAMAllocator< T >::ExternalRAMAllocator ( Flags  flags)
inline

Definition at line 656 of file helpers.h.

◆ ExternalRAMAllocator() [3/3]

template<class T>
template<class U >
constexpr esphome::ExternalRAMAllocator< T >::ExternalRAMAllocator ( const ExternalRAMAllocator< U > &  other)
inline

Definition at line 657 of file helpers.h.

Member Function Documentation

◆ allocate()

template<class T>
T* esphome::ExternalRAMAllocator< T >::allocate ( size_t  n)
inline

Definition at line 659 of file helpers.h.

◆ deallocate()

template<class T>
void esphome::ExternalRAMAllocator< T >::deallocate ( T *  p,
size_t  n 
)
inline

Definition at line 672 of file helpers.h.


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