Custom memory allocator for PSRAM. More...
#include <RamAllocator.hpp>
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. | |
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.
using Ragot::PSRAMAllocator< T, Flag >::pointer = T* |
using Ragot::PSRAMAllocator< T, Flag >::size_type = std::size_t |
using Ragot::PSRAMAllocator< T, Flag >::value_type = T |
|
inlinenoexcept |
Default constructor for PSRAMAllocator.
This constructor initializes the PSRAMAllocator without any specific parameters.
|
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.
U | The type to rebind to. |
other | The allocator to copy from. |
|
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.
n | The number of objects to allocate memory for. |
|
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.
p | Pointer to the memory to deallocate. |
n | The number of objects to deallocate (not used). |