From 00f5fa80be6531e6501b38b8a3f93c20bb718cda Mon Sep 17 00:00:00 2001 From: Clive Blackledge Date: Thu, 25 Jun 2026 18:48:38 -0700 Subject: [PATCH] Add native Portduino malloc shim (#10677) * Add native Portduino malloc shim * Taking copilots advice Honestly I don't think it matters that much, but if it makes copilot happy, return ret if something weird happens. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Ben Meadors Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- variants/native/portduino/malloc.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 variants/native/portduino/malloc.h 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