31 T* ref =
new (addr) T();
38 if (obj ==
nullptr)
return;
46 void* addr =
allocate(
sizeof(T) * len);
49#ifndef NO_INPLACE_INIT_SUPPORT
50 for (
int j = 0; j < len; j++)
new (addrT + j) T();
53 for (
int j = 0; j < len; j++) {
54 memcpy((uint8_t*)addr + (j *
sizeof(T)), &default_value,
sizeof(T));
63 if (obj ==
nullptr)
return;
64 for (
int j = 0; j < len; j++) {
73 if (result ==
nullptr) {
74 LOGE(
"Allocateation failed for %zu bytes", size);
77 LOGD(
"Allocated %zu", size);
83 virtual void free(
void* memory) {
84 if (memory !=
nullptr)
::free(memory);
89 return calloc(1, size == 0 ? 1 : size);
101 void* do_allocate(
size_t size) {
102 void* result =
nullptr;
103 if (size == 0) size = 1;
104#if defined(USE_PSRAM) && defined(ARDUINO)
105 result = ps_malloc(size);
107 if (result ==
nullptr) result = malloc(size);
108 if (result ==
nullptr) {
109 LOGE(
"allocateation failed for %zu bytes", size);
113 memset(result, 0, size);
118#if (defined(ESP32)) && defined(ARDUINO)
130 AllocatorESP32(
int caps = MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL) {
133 void* do_allocate(
size_t size) {
134 void* result =
nullptr;
135 if (size == 0) size = 1;
136 result = heap_caps_calloc(1, size, caps);
137 if (result ==
nullptr) {
138 LOGE(
"alloc failed for %zu bytes", size);
148static AllocatorESP32 DefaultESP32AllocatorRAM;
152#if defined(USE_PSRAM) && defined(ARDUINO)
162class AllocatorPSRAM :
public Allocator {
163 void* do_allocate(
size_t size) {
164 if (size == 0) size = 1;
165 void* result =
nullptr;
166 result = ps_calloc(1, size);
167 if (result ==
nullptr) {
168 LOGE(
"allocateation failed for %zu bytes", size);
177#if defined(IS_ZEPHYR)
178#include <zephyr/kernel.h>
188 if (size == 0) size = 1;
189 void* result = k_malloc(size);
190 if (result !=
nullptr) memset(result, 0, size);
194 void free(
void* memory)
override {
195 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