FastLED 3.9.15
Loading...
Searching...
No Matches
allocator.h
Go to the documentation of this file.
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 }
28 }
29};
30
31} // namespace fl
static T * Alloc(size_t n)
Definition allocator.h:18
static void Free(T *p)
Definition allocator.h:23
void SetLargeBlockAllocator(void *(*alloc)(size_t), void(*free)(void *))
Definition allocator.cpp:37
void LargeBlockDeallocate(void *ptr)
Definition allocator.cpp:50
void * LargeBlockAllocate(size_t size, bool zero)
Definition allocator.cpp:42
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
static FASTLED_NAMESPACE_BEGIN uint8_t const p[]
Definition noise.cpp:56