diff --git a/variants/native/portduino/malloc.h b/variants/native/portduino/malloc.h new file mode 100644 index 000000000..3c4d7a25a --- /dev/null +++ b/variants/native/portduino/malloc.h @@ -0,0 +1,21 @@ +#pragma once + +#if defined(__APPLE__) +#include +#include +#include + +// LovyanGFX includes the Linux header name; bridge it for Darwin native builds. +static inline void *memalign(size_t alignment, size_t size) +{ + void *ptr = NULL; + int ret = posix_memalign(&ptr, alignment, size); + if (ret != 0) { + errno = ret; + return NULL; + } + return ptr; +} +#else +#include_next +#endif