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 621 of file allocator.h.

621 {
622 if (n == 0) {
623 return nullptr;
624 }
625
626 // Try to allocate from slab first
627 void* ptr = allocateFromSlab(n);
628 if (ptr) {
629 fl::memset(ptr, 0, sizeof(T) * n);
630 return static_cast<T*>(ptr);
631 }
632
633 // Fall back to regular malloc for large allocations
634 ptr = Malloc(sizeof(T) * n);
635 if (ptr) {
636 fl::memset(ptr, 0, sizeof(T) * n);
637 }
638 return static_cast<T*>(ptr);
639 }
void * allocateFromSlab(fl::size n=1) FL_NOEXCEPT
Definition allocator.h:513
void * memset(void *s, int c, size_t n) FL_NOEXCEPT
void * Malloc(fl::size size)

References allocateFromSlab(), FL_NOEXCEPT, fl::Malloc(), and fl::memset().

+ Here is the call graph for this function: