FastLED 3.10.6
Loading...
Searching...
No Matches

◆ allocate()

template<typename T>
T * fl::allocator< T >::allocate ( fl::size n)
inline

Definition at line 220 of file allocator.h.

220 {
221 if (n == 0) {
222 return nullptr; // Handle zero allocation
223 }
224 fl::size size = sizeof(T) * n;
225 void *ptr = Malloc(size);
226 if (ptr == nullptr) {
227 return nullptr; // Handle allocation failure
228 }
229 fl::memset(ptr, 0, sizeof(T) * n); // Zero-initialize the memory
230 return static_cast<T*>(ptr);
231 }
void * memset(void *s, int c, size_t n) FL_NO_EXCEPT
void * Malloc(fl::size size)

Referenced by fl::allocator_slab< T, SLAB_SIZE >::allocate(), and fl::allocator< U >::allocate_at_least().

+ Here is the caller graph for this function: