28 T* ref =
new (addr) T();
35 if (obj ==
nullptr)
return;
43 void* addr =
allocate(
sizeof(T) * len);
46 for (
int j = 0; j < len; j++)
new (addrT + j) T();
53 if (obj ==
nullptr)
return;
54 for (
int j = 0; j < len; j++) {
63 if (result ==
nullptr) {
73 while (
true) delay(1000);
77 virtual void free(
void* memory) {
78 if (memory !=
nullptr)
::free(memory);
83 return calloc(1, size == 0 ? 1 : size);
95 void* do_allocate(
size_t size) {
96 void* result =
nullptr;
97 if (size == 0) size = 1;
98 #if defined(ESP32) && defined(ARDUINO)
99 result = ps_malloc(size);
101 if (result ==
nullptr) result = malloc(size);
102 if (result ==
nullptr) {
107 memset(result, 0, size);
112 #if defined(ESP32) && defined(ARDUINO)
122 class AllocatorPSRAM :
public Allocator {
123 void* do_allocate(
size_t size) {
124 if (size == 0) size = 1;
125 void* result =
nullptr;
126 result = ps_calloc(1, size);
127 if (result ==
nullptr) {
137 static AllocatorExt DefaultAllocator;
Memory allocateator which uses ps_malloc (on the ESP32) and if this fails it resorts to malloc.
Definition: Allocator.h:94
Memory allocateator which uses malloc.
Definition: Allocator.h:21
void remove(T *obj)
deletes an object
Definition: Allocator.h:34
void removeArray(T *obj, int len)
Definition: Allocator.h:52
virtual void * do_allocate(size_t size)
Definition: Allocator.h:82
T * create()
Definition: Allocator.h:25
T * createArray(int len)
Definition: Allocator.h:42
virtual void * allocate(size_t size)
Allocates memory.
Definition: Allocator.h:61
virtual void free(void *memory)
frees memory
Definition: Allocator.h:77
void stop()
Definition: Allocator.h:72
void log(DlnaLogLevel current_level, const char *fmt...)
Print log message.
Definition: Logger.h:40
Definition: Allocator.h:6
@ DlnaDebug
Definition: Logger.h:16
@ DlnaError
Definition: Logger.h:16
LoggerClass DlnaLogger
Definition: Logger.cpp:5