Skip to content

Commit

Permalink
Fix MallocCount for MinGW
Browse files Browse the repository at this point in the history
MinGW defines aliases in stdlib.h for `realloc` and `free` which require wrapping.
  • Loading branch information
mikee47 committed Sep 16, 2024
1 parent 1e39a56 commit 727baa0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sming/Components/malloc_count/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ MC_WRAP_FUNCS += \
pvPortZallocIram \
vPortFree
endif
ifeq ($(SMING_ARCH)$(UNAME),HostWindows)
MC_WRAP_FUNCS += \
__mingw_realloc \
__mingw_free
endif

EXTRA_LDFLAGS := $(call UndefWrap,$(MC_WRAP_FUNCS))

Expand Down
5 changes: 5 additions & 0 deletions Sming/Components/malloc_count/malloc_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@ extern "C" void WRAP(free)(void*) __attribute__((alias("mc_free")));

using namespace MallocCount;

#ifdef __WIN32
extern "C" void* WRAP(__mingw_realloc)(void*, size_t) __attribute__((alias("mc_realloc")));
extern "C" void WRAP(__mingw_free)(void*) __attribute__((alias("mc_free")));
#endif

#ifdef ARCH_ESP8266

extern "C" void* WRAP(pvPortMalloc)(size_t) __attribute__((alias("mc_malloc")));
Expand Down

0 comments on commit 727baa0

Please sign in to comment.