This commit reduces our romsize by 3KB by optimizing away libc's malloc() function

The problem was that our custom_malloc was not marking these functions as extern "C".
Therefore libc's malloc function and everything linked to it was still getting pulled into our
rom.

Fix: mark these functions as extern "C". This ensures that these functions aren't getting pulled in
from libc. This reduces our rom size by 3KB
This commit is contained in:
Philippe Symons
2026-02-17 16:24:06 +01:00
parent bcc890f0f2
commit 3a5366e0af
2 changed files with 5 additions and 996 deletions

View File

@@ -201,6 +201,9 @@ void malloc_init_default_pool(void)
memset(g_alloc_map, 0, sizeof(g_alloc_map)); // Clear bitmap
}
extern "C"
{
/// @brief The custom implementation of the bitmap allocator described at the top of this module.
void* malloc(size_t size)
{
@@ -333,6 +336,8 @@ void _free_r(struct _reent *r, void* ptr) {
return free(ptr);
}
}
#else
void malloc_init_default_pool(void)