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

◆ allocate()

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

Definition at line 219 of file allocator.h.

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