3D Graphics Engine for ESP32
 
Loading...
Searching...
No Matches
Ragot::PSRAMAllocator< T, Flag > Class Template Reference

Custom memory allocator for PSRAM. More...

#include <RamAllocator.hpp>

Inheritance diagram for Ragot::PSRAMAllocator< T, Flag >:
Inheritance graph
Collaboration diagram for Ragot::PSRAMAllocator< T, Flag >:
Collaboration graph

Classes

struct  rebind
 Rebinds the allocator to a different type. This struct allows the PSRAMAllocator to be used with different types while maintaining the same allocation flags. More...
 

Public Types

using value_type = T
 
using pointer = T*
 
using size_type = std::size_t
 

Public Member Functions

 PSRAMAllocator () noexcept
 Default constructor for PSRAMAllocator.
 
template<typename U, uint16_t F2>
 PSRAMAllocator (const PSRAMAllocator< U, F2 > &) noexcept
 Copy constructor for PSRAMAllocator.
 
T * allocate (size_type n)
 Allocates memory for n objects of type T in PSRAM.
 
void deallocate (T *p, size_type) noexcept
 Deallocates memory for n objects of type T in PSRAM.
 

Detailed Description

template<typename T, uint16_t Flag>
class Ragot::PSRAMAllocator< T, Flag >

Custom memory allocator for PSRAM.

This class provides a custom memory allocator that uses PSRAM with specific flags. It can be used with standard containers like std::vector to manage memory in embedded systems.

Member Typedef Documentation

◆ pointer

template<typename T, uint16_t Flag>
using Ragot::PSRAMAllocator< T, Flag >::pointer = T*

◆ size_type

template<typename T, uint16_t Flag>
using Ragot::PSRAMAllocator< T, Flag >::size_type = std::size_t

◆ value_type

template<typename T, uint16_t Flag>
using Ragot::PSRAMAllocator< T, Flag >::value_type = T

Constructor & Destructor Documentation

◆ PSRAMAllocator() [1/2]

template<typename T, uint16_t Flag>
Ragot::PSRAMAllocator< T, Flag >::PSRAMAllocator ( )
inlinenoexcept

Default constructor for PSRAMAllocator.

This constructor initializes the PSRAMAllocator without any specific parameters.

◆ PSRAMAllocator() [2/2]

template<typename T, uint16_t Flag>
template<typename U, uint16_t F2>
Ragot::PSRAMAllocator< T, Flag >::PSRAMAllocator ( const PSRAMAllocator< U, F2 > & )
inlinenoexcept

Copy constructor for PSRAMAllocator.

This constructor allows copying of the PSRAMAllocator, but it does not perform any specific actions. It is designed to be used with standard containers that require copyable allocators.

Template Parameters
UThe type to rebind to.
Parameters
otherThe allocator to copy from.

Member Function Documentation

◆ allocate()

template<typename T, uint16_t Flag>
T * Ragot::PSRAMAllocator< T, Flag >::allocate ( size_type n)
inline

Allocates memory for n objects of type T in PSRAM.

This method allocates memory for n objects of type T using heap_caps_malloc with the specified flags. If the allocation fails, it throws std::bad_alloc.

Parameters
nThe number of objects to allocate memory for.
Returns
T* Pointer to the allocated memory.

◆ deallocate()

template<typename T, uint16_t Flag>
void Ragot::PSRAMAllocator< T, Flag >::deallocate ( T * p,
size_type  )
inlinenoexcept

Deallocates memory for n objects of type T in PSRAM.

This method deallocates memory for n objects of type T using heap_caps_free. It does not throw any exceptions.

Parameters
pPointer to the memory to deallocate.
nThe number of objects to deallocate (not used).

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