* 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>
22 lines
446 B
C
22 lines
446 B
C
#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
|