FastLED 3.9.7
Loading...
Searching...
No Matches
allocator.h
1
2#pragma once
3
4#include <stddef.h>
5#include <string.h>
6
7
8
9namespace fl {
10
11void SetLargeBlockAllocator(void *(*alloc)(size_t), void (*free)(void *));
12void* LargeBlockAllocate(size_t size, bool zero = true);
13void LargeBlockDeallocate(void* ptr);
14
15template<typename T>
17public:
18 static T* Alloc(size_t n) {
19 void* ptr = LargeBlockAllocate(sizeof(T) * n, true);
20 return reinterpret_cast<T*>(ptr);
21 }
22
23 static void Free(T* p) {
24 if (p == nullptr) {
25 return;
26 }
27 LargeBlockDeallocate(p);
28 }
29};
30
31} // namespace fl
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16