5#include <esp_heap_caps.h>
8namespace tinyrobotics {
11
12
13
14
15
16
17
18
19
25 using const_pointer =
const T*;
27 using const_reference =
const T&;
32
33
37
38
39
40
45
46
47
48
49
54 assert(n <= std::numeric_limits<size_type>::max() /
sizeof(T));
58 p =
static_cast<pointer>(
59 heap_caps_malloc(n *
sizeof(T), MALLOC_CAP_SPIRAM));
61#if defined(ARDUINO_ARCH_RP2040) && defined(RP2350_PSRAM_CS)
62 p = pmalloc(n *
sizeof(T));
66 p =
static_cast<pointer>(malloc(n *
sizeof(T)));
78
79
80
81
100
101
102
103 template <
typename U>
Custom allocator that uses ESP32's PSRAM for memory allocation.
Definition: AllocatorPSRAM.h:21
void deallocate(pointer p, size_type) noexcept
Deallocate memory.
Definition: AllocatorPSRAM.h:82
pointer allocate(size_type n)
Allocate memory from PSRAM.
Definition: AllocatorPSRAM.h:50
AllocatorPSRAM() noexcept
Default constructor.
Definition: AllocatorPSRAM.h:34
AllocatorPSRAM(const AllocatorPSRAM< U > &) noexcept
Copy constructor from another allocator type.
Definition: AllocatorPSRAM.h:42
Rebind allocator to another type.
Definition: AllocatorPSRAM.h:104