Files
meshtastic_firmware/variants/native/portduino/malloc.h
T
00f5fa80be 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>
2026-06-25 20:48:38 -05:00

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