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

Method allocate

tests/fl/stl/allocator_move.cpp:121–134  ·  view source on GitHub ↗

Allocate memory for n objects of type T

Source from the content-addressed store, hash-verified

119
120 // Allocate memory for n objects of type T
121 T* allocate(fl::size n) {
122 if (n == 0) {
123 return nullptr;
124 }
125 if (stats) {
126 stats->allocations++;
127 }
128 fl::size size = sizeof(T) * n;
129 void* ptr = fl::Malloc(size);
130 if (ptr) {
131 fl::memset(ptr, 0, sizeof(T) * n);
132 }
133 return static_cast<T*>(ptr);
134 }
135
136 // Deallocate memory for n objects of type T
137 void deallocate(T* p, fl::size n) {

Callers

nothing calls this directly

Calls 2

MallocFunction · 0.85
memsetFunction · 0.85

Tested by

no test coverage detected