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 <benmmeadors@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Clive Blackledge
2026-06-25 20:48:38 -05:00
committed by GitHub
co-authored by GitHub Ben Meadors Copilot Autofix powered by AI
parent 98fa4a67db
commit 00f5fa80be
+21
View File
@@ -0,0 +1,21 @@
#pragma once
#if defined(__APPLE__)
#include <malloc/malloc.h>
#include <stdlib.h>
#include <errno.h>
// 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 <malloc.h>
#endif