cfree should not be used, according to its man page, but if it's
being used then we need to overload it. On systems where it is not
available, simply skip this step to keep heaptrack compiling.
#error unsupported word size
#endif
+#define HAVE_ALIGNED_ALLOC defined(_ISOC11_SOURCE)
+#define HAVE_CFREE (defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || defined(__USE_MISC))
+
namespace {
void overwrite_symbols() noexcept;
}
};
+#if HAVE_CFREE
struct cfree
{
static constexpr auto name = "cfree";
original(ptr);
}
};
+#endif
struct dlopen
{
hook::wrap<free>(),
hook::wrap<realloc>(),
hook::wrap<calloc>(),
+#if HAVE_CFREE
hook::wrap<cfree>(),
+#endif
hook::wrap<posix_memalign>(),
hook::wrap<dlopen>(),
hook::wrap<dlclose>(),
using namespace std;
#define HAVE_ALIGNED_ALLOC defined(_ISOC11_SOURCE)
+#define HAVE_CFREE (defined(_BSD_SOURCE) || defined(_SVID_SOURCE) || defined(__USE_MISC))
namespace {
HOOK(malloc);
HOOK(free);
HOOK(calloc);
+#if HAVE_CFREE
HOOK(cfree);
+#endif
HOOK(realloc);
HOOK(posix_memalign);
HOOK(valloc);
hooks::malloc.init();
hooks::free.init();
hooks::calloc.init();
+#if HAVE_CFREE
hooks::cfree.init();
+#endif
hooks::realloc.init();
hooks::posix_memalign.init();
hooks::valloc.init();
return ret;
}
+#if HAVE_CFREE
void cfree(void* ptr) noexcept
{
if (!hooks::cfree) {
hooks::cfree(ptr);
}
+#endif
int posix_memalign(void **memptr, size_t alignment, size_t size) noexcept
{