using namespace std;
+#define HAVE_ALIGNED_ALLOC defined(_ISOC11_SOURCE)
+
namespace {
namespace hooks {
HOOK(realloc);
HOOK(posix_memalign);
HOOK(valloc);
+#if HAVE_ALIGNED_ALLOC
HOOK(aligned_alloc);
+#endif
HOOK(dlopen);
HOOK(dlclose);
hooks::realloc.init();
hooks::posix_memalign.init();
hooks::valloc.init();
+#if HAVE_ALIGNED_ALLOC
hooks::aligned_alloc.init();
+#endif
// cleanup environment to prevent tracing of child apps
unsetenv("LD_PRELOAD");
return ret;
}
+#if HAVE_ALIGNED_ALLOC
void* aligned_alloc(size_t alignment, size_t size) noexcept
{
if (!hooks::aligned_alloc) {
return ret;
}
+#endif
void* valloc(size_t size) noexcept
{
#include <cstdlib>
#include <cstdio>
+#define HAVE_ALIGNED_ALLOC defined(_ISOC11_SOURCE)
+
struct Foo {
Foo()
: i(new int)
printf("calloc: %p\n", buf);
cfree(buf);
+#if HAVE_ALIGNED_ALLOC
buf = aligned_alloc(16, 160);
printf("aligned_alloc: %p\n", buf);
free(buf);
+#endif
buf = valloc(32);
printf("valloc: %p\n", buf);