ESPHome  2025.2.0
Public Types | Public Member Functions
esphome::RAMAllocator< T > Class Template Reference

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

#include <helpers.h>

Public Types

enum  Flags { NONE = 0, ALLOC_EXTERNAL = 1 << 0, ALLOC_INTERNAL = 1 << 1, ALLOW_FAILURE = 1 << 2 }
 
using value_type = T
 

Public Member Functions

 RAMAllocator ()=default
 
 RAMAllocator (uint8_t flags)
 
template<class U >
constexpr RAMAllocator (const RAMAllocator< U > &other)
 
T * allocate (size_t n)
 
void deallocate (T *p, size_t n)
 
size_t get_free_heap_size () const
 Return the total heap space available via this allocator. More...
 
size_t get_max_free_block_size () const
 Return the maximum size block this allocator could allocate. More...
 

Detailed Description

template<class T>
class esphome::RAMAllocator< T >

An STL allocator that uses SPI or internal RAM.

Returns nullptr in case no memory is available.

By setting flags, it can be configured to:

Definition at line 683 of file helpers.h.

Member Typedef Documentation

◆ value_type

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

Definition at line 685 of file helpers.h.

Member Enumeration Documentation

◆ Flags

template<class T>
enum esphome::RAMAllocator::Flags
Enumerator
NONE 
ALLOC_EXTERNAL 
ALLOC_INTERNAL 
ALLOW_FAILURE 

Definition at line 687 of file helpers.h.

Constructor & Destructor Documentation

◆ RAMAllocator() [1/3]

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

◆ RAMAllocator() [2/3]

template<class T>
esphome::RAMAllocator< T >::RAMAllocator ( uint8_t  flags)
inline

Definition at line 695 of file helpers.h.

◆ RAMAllocator() [3/3]

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

Definition at line 701 of file helpers.h.

Member Function Documentation

◆ allocate()

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

Definition at line 703 of file helpers.h.

◆ deallocate()

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

Definition at line 720 of file helpers.h.

◆ get_free_heap_size()

template<class T>
size_t esphome::RAMAllocator< T >::get_free_heap_size ( ) const
inline

Return the total heap space available via this allocator.

Definition at line 727 of file helpers.h.

◆ get_max_free_block_size()

template<class T>
size_t esphome::RAMAllocator< T >::get_max_free_block_size ( ) const
inline

Return the maximum size block this allocator could allocate.

This may be an approximation on some platforms

Definition at line 748 of file helpers.h.


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