4 #include "AudioConfig.h"
5 #include "AudioTools/CoreAudio/AudioLogger.h"
29 T* ref =
new (addr) T();
36 if (obj ==
nullptr)
return;
43 T* createArray(
int len) {
44 void* addr =
allocate(
sizeof(T) * len);
47 for (
int j = 0; j < len; j++)
new (addrT+j) T();
53 void removeArray(T* obj,
int len) {
54 if (obj ==
nullptr)
return;
55 for (
int j = 0; j < len; j++) {
63 void* result = do_allocate(size);
64 if (result ==
nullptr) {
65 LOGE(
"Allocateation failed for %zu bytes", size);
68 LOGD(
"Allocated %zu", size);
74 virtual void free(
void* memory) {
75 if (memory !=
nullptr)
::free(memory);
79 virtual void* do_allocate(
size_t size) {
80 return calloc(1, size == 0 ? 1 : size);
92 void* do_allocate(
size_t size) {
93 void* result =
nullptr;
94 if (size == 0) size = 1;
95 #if defined(ESP32) && defined(ARDUINO)
96 result = ps_malloc(size);
98 if (result ==
nullptr) result = malloc(size);
99 if (result ==
nullptr) {
100 LOGE(
"allocateation failed for %zu bytes", size);
104 memset(result, 0, size);
109 #if defined(ESP32) && defined(ARDUINO)
119 class AllocatorPSRAM :
public Allocator {
120 void* do_allocate(
size_t size) {
121 if (size == 0) size = 1;
122 void* result =
nullptr;
123 result = ps_calloc(1, size);
124 if (result ==
nullptr) {
125 LOGE(
"allocateation failed for %zu bytes", size);
134 static AllocatorExt DefaultAllocator;
void stop()
Public generic methods.
Definition: AudioRuntime.h:27