32 T* ref =
new (addr) T();
39 if (obj ==
nullptr)
return;
47 void* addr =
allocate(
sizeof(T) * len);
50#ifndef NO_INPLACE_INIT_SUPPORT
51 for (
int j = 0; j < len; j++)
new (addrT + j) T();
54 for (
int j = 0; j < len; j++) {
55 memcpy((uint8_t*)addr + (j *
sizeof(T)), &default_value,
sizeof(T));
64 if (obj ==
nullptr)
return;
65 for (
int j = 0; j < len; j++) {
74 if (result ==
nullptr) {
75 LOGE(
"Allocateation failed for %zu bytes", size);
78 LOGD(
"Allocated %zu", size);
84 virtual void free(
void* memory) {
85 if (memory !=
nullptr)
::free(memory);
90 return calloc(1, size == 0 ? 1 : size);
102 void* do_allocate(
size_t size) {
103 void* result =
nullptr;
104 if (size == 0) size = 1;
105#if defined(USE_PSRAM) && defined(ARDUINO)
106 result = ps_malloc(size);
108 if (result ==
nullptr) result = malloc(size);
109 if (result ==
nullptr) {
110 LOGE(
"allocateation failed for %zu bytes", size);
114 memset(result, 0, size);
119#if (defined(ESP32)) && defined(ARDUINO)
131 AllocatorESP32(
int caps = MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL) {
134 void* do_allocate(
size_t size) {
135 void* result =
nullptr;
136 if (size == 0) size = 1;
137 result = heap_caps_calloc(1, size, caps);
138 if (result ==
nullptr) {
139 LOGE(
"alloc failed for %zu bytes", size);
149static AllocatorESP32 DefaultESP32AllocatorRAM;
153#if defined(USE_PSRAM) && defined(ARDUINO)
163class AllocatorPSRAM :
public Allocator {
164 void* do_allocate(
size_t size) {
165 if (size == 0) size = 1;
166 void* result =
nullptr;
167 result = ps_calloc(1, size);
168 if (result ==
nullptr) {
169 LOGE(
"allocateation failed for %zu bytes", size);
178#if defined(IS_ZEPHYR)
179#include <zephyr/kernel.h>
189 if (size == 0) size = 1;
190 void* result = k_malloc(size);
191 if (result !=
nullptr) memset(result, 0, size);
195 void free(
void* memory)
override {
196 if (memory !=
nullptr) k_free(memory);
#define LOGD(...)
Definition AudioLoggerIDF.h:27
#define LOGE(...)
Definition AudioLoggerIDF.h:30
void stop()
stops any further processing by spinning in an endless loop
Definition AudioRuntime.h:71