// Standard library includes. #include // Unix includes. #include // Local includes. #include "another_memcheck.h" extern "C" { void *malloc(std::size_t size) { std::clog << "attempting to malloc size: " << size << "...\n"; if (SC_AM_Internal::real_malloc == nullptr) { SC_AM_Internal::real_malloc = reinterpret_cast(dlsym(RTLD_NEXT, "malloc")); } if (SC_AM_Internal::stats == nullptr) { SC_AM_Internal::stats = SC_AM_Internal::get_init_stats(); } return SC_AM_Internal::stats->do_malloc(size); } void *calloc(std::size_t n, std::size_t size) { std::clog << "attempting to calloc size: " << size << "...\n"; if (SC_AM_Internal::real_calloc == nullptr) { SC_AM_Internal::real_calloc = reinterpret_cast( dlsym(RTLD_NEXT, "calloc")); } if (SC_AM_Internal::stats == nullptr) { SC_AM_Internal::stats = SC_AM_Internal::get_init_stats(); } return SC_AM_Internal::stats->do_calloc(n, size); } void free(void *ptr) { std::clog << "attempting to free...\n"; if (SC_AM_Internal::real_free == nullptr) { SC_AM_Internal::real_free = reinterpret_cast(dlsym(RTLD_NEXT, "free")); } if (SC_AM_Internal::stats == nullptr) { SC_AM_Internal::stats = SC_AM_Internal::get_init_stats(); } return SC_AM_Internal::stats->do_free(ptr); } } // vim: et sw=2 ts=2 sts=2