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
7namespace fl {
8
9void SetLargeBlockAllocator(void *(*alloc)(size_t), void (*free)(void *));
10void *LargeBlockAllocate(size_t size, bool zero = true);
11void LargeBlockDeallocate(void *ptr);
12
13template <typename T> class LargeBlockAllocator {
14 public:
15 static T *Alloc(size_t n) {
16 void *ptr = LargeBlockAllocate(sizeof(T) * n, true);
17 return reinterpret_cast<T *>(ptr);
18 }
19
20 static void Free(T *p) {
21 if (p == nullptr) {
22 return;
23 }
25 }
26};
27
28} // namespace fl
static T * Alloc(size_t n)
Definition allocator.h:15
static void Free(T *p)
Definition allocator.h:20
void SetLargeBlockAllocator(void *(*alloc)(size_t), void(*free)(void *))
Definition allocator.cpp:36
void LargeBlockDeallocate(void *ptr)
Definition allocator.cpp:49
void * LargeBlockAllocate(size_t size, bool zero)
Definition allocator.cpp:41
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:30