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

Method allocate

src/fl/stl/allocator.h:219–230  ·  view source on GitHub ↗

Use this to allocate large blocks of memory for T. This is useful for large arrays or objects that need to be allocated in a single block.

Source from the content-addressed store, hash-verified

217 // This is useful for large arrays or objects that need to be allocated
218 // in a single block.
219 T* allocate(fl::size n) FL_NOEXCEPT {
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 }
231
232 void deallocate(T* p, fl::size n) FL_NOEXCEPT {
233 FASTLED_UNUSED(n);

Callers 14

ensure_capacityMethod · 0.45
shrink_to_fitMethod · 0.45
allocateMethod · 0.45
allocateMethod · 0.45
trivial_swapMethod · 0.45
grow_toMethod · 0.45
shrink_to_fit_implMethod · 0.45
swap_implMethod · 0.45
init_sentinelMethod · 0.45
create_nodeMethod · 0.45
emplace_backMethod · 0.45
emplace_frontMethod · 0.45

Calls 2

MallocFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected