FastLED
3.9.3
Loading...
Searching...
No Matches
allocator.h
1
2
#pragma once
3
4
#include <stddef.h>
5
#include <string.h>
6
7
#include "namespace.h"
8
9
10
FASTLED_NAMESPACE_BEGIN
11
12
void
SetLargeBlockAllocator(
void
*(*alloc)(
size_t
),
void
(*free)(
void
*));
13
void
* LargeBlockAllocate(
size_t
size,
bool
zero =
true
);
14
void
LargeBlockDeallocate(
void
* ptr);
15
16
template
<
typename
T>
17
class
LargeBlockAllocator
{
18
public
:
19
static
T* Alloc(
size_t
n) {
20
void
* ptr = LargeBlockAllocate(
sizeof
(T) * n,
true
);
21
return
reinterpret_cast<
T*
>
(ptr);
22
}
23
24
static
void
Free(T* p,
size_t
n) {
25
(void)n;
26
if
(p ==
nullptr
) {
27
return
;
28
}
29
LargeBlockDeallocate(p);
30
}
31
};
32
33
FASTLED_NAMESPACE_END
LargeBlockAllocator
Definition
allocator.h:17
src
allocator.h
Generated on Thu Nov 14 2024 00:00:34 for FastLED by
1.11.0