FastLED 3.9.15
Loading...
Searching...
No Matches

◆ allocate()

template<typename T, fl::size SLAB_SIZE = FASTLED_DEFAULT_SLAB_SIZE>
T * fl::SlabAllocator< T, SLAB_SIZE >::allocate ( fl::size n = 1)
inline

Definition at line 346 of file allocator.h.

346 {
347 if (n == 0) {
348 return nullptr;
349 }
350
351 // Try to allocate from slab first
352 void* ptr = allocateFromSlab(n);
353 if (ptr) {
354 fl::memfill(ptr, 0, sizeof(T) * n);
355 return static_cast<T*>(ptr);
356 }
357
358 // Fall back to regular malloc for large allocations
359 ptr = malloc(sizeof(T) * n);
360 if (ptr) {
361 fl::memfill(ptr, 0, sizeof(T) * n);
362 }
363 return static_cast<T*>(ptr);
364 }
void * allocateFromSlab(fl::size n=1)
Definition allocator.h:236
void * memfill(void *ptr, int value, fl::size num)
Definition memfill.h:11

References allocateFromSlab(), and fl::memfill().

+ Here is the call graph for this function: