Skip to content

Commit

Permalink
Fix MallocCount for MinGW (#2884)
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 authored Sep 16, 2024
1 parent c79add6 commit 3cb6f28
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 3cb6f28

Please sign in to comment.