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

Method allocate

src/fl/stl/allocator.h:621–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

619 }
620
621 T* allocate(fl::size n = 1) FL_NOEXCEPT {
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 }
640
641 void deallocate(T* ptr, fl::size n = 1) FL_NOEXCEPT {
642 if (!ptr) {

Callers

nothing calls this directly

Calls 2

memsetFunction · 0.85
MallocFunction · 0.85

Tested by

no test coverage detected