MCPcopy Create free account
hub / github.com/FastLED/FastLED / DefaultAlloc

Function DefaultAlloc

src/fl/stl/allocator.cpp.hpp:40–52  ·  view source on GitHub ↗

On esp32, attempt to always allocate in psram first.

Source from the content-addressed store, hash-verified

38#ifdef FL_IS_ESP32
39// On esp32, attempt to always allocate in psram first.
40void *DefaultAlloc(fl::size size) {
41#ifdef FL_VECTOR_PSRAM_ALWAYS_SRAM
42 // FL_VECTOR_PSRAM_ALWAYS_SRAM: skip PSRAM, use default (SRAM) only.
43 void *out = heap_caps_malloc(size, MALLOC_CAP_DEFAULT);
44#else
45 void *out = heap_caps_malloc(size, MALLOC_CAP_SPIRAM);
46 if (out == nullptr) {
47 // Fallback to default allocator.
48 out = heap_caps_malloc(size, MALLOC_CAP_DEFAULT);
49 }
50#endif
51 return out;
52}
53void DefaultFree(void *ptr) { heap_caps_free(ptr); }
54#else
55void *DefaultAlloc(fl::size size) { return malloc(size); }

Callers

nothing calls this directly

Calls 1

mallocFunction · 0.70

Tested by

no test coverage detected