FastLED 3.9.15
Loading...
Searching...
No Matches
malloc.cpp.hpp
Go to the documentation of this file.
1#include "fl/stl/malloc.h"
2#include "fl/stl/cstring.h"
3// IWYU pragma: begin_keep
4#include <stdlib.h>
5// IWYU pragma: end_keep
6
7namespace fl {
8 // Provide C standard library malloc/free/realloc functions
9 void* malloc(size_t size) {
10 return ::malloc(size);
11 }
12
13 void free(void* ptr) {
14 ::free(ptr);
15 }
16
17 void* calloc(size_t nmemb, size_t size) {
18 size_t total_size = nmemb * size;
19 void* ptr = malloc(total_size);
20 if (ptr != nullptr) {
21 memset(ptr, 0, total_size);
22 }
23 return ptr;
24 }
25
26 void* realloc(void* ptr, size_t new_size) {
27 return ::realloc(ptr, new_size);
28 }
29
30 // Provide abs function
31 // Arduino.h defines abs as a macro, so we need to temporarily hide it
32 #pragma push_macro("abs")
33 #undef abs
34 int abs(int x) {
35 return ::abs(x);
36 }
37 #pragma pop_macro("abs")
38} // namespace fl
void * memset(void *s, int c, size_t n) FL_NOEXCEPT
void * calloc(size_t nmemb, size_t size)
void * malloc(size_t size)
Definition malloc.cpp.hpp:9
void free(void *ptr)
void * realloc(void *ptr, size_t new_size)
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NOEXCEPT
Base definition for an LED controller.
Definition crgb.hpp:179