From a0904a2297183e491d205cb9f902e729e2017bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radovan=20=C4=8Cerven=C3=BD?= <radovan.cerveny@gmail.com> Date: Tue, 9 Feb 2016 19:07:39 +0100 Subject: [PATCH] custom operator new gets linked only in debug build --- alib2measure/src/debug/New.cpp | 15 +++++++++++++++ alib2measure/src/measurements/MeasurementNew.cpp | 8 -------- alib2measure/src/measurements/MeasurementNew.hpp | 4 ---- 3 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 alib2measure/src/debug/New.cpp diff --git a/alib2measure/src/debug/New.cpp b/alib2measure/src/debug/New.cpp new file mode 100644 index 0000000000..c23d74728c --- /dev/null +++ b/alib2measure/src/debug/New.cpp @@ -0,0 +1,15 @@ +/* + * Author: Radovan Cerveny + */ + +#include <cstdlib> +#include <new> +#include "../measurements/MeasurementNew.hpp" + +void * operator new( std::size_t n ) { + return operator new( n, true ); +} + +void operator delete( void * ptr ) noexcept { + operator delete( ptr, true ); +} diff --git a/alib2measure/src/measurements/MeasurementNew.cpp b/alib2measure/src/measurements/MeasurementNew.cpp index b2d53fbc5b..8207ddd7b1 100644 --- a/alib2measure/src/measurements/MeasurementNew.cpp +++ b/alib2measure/src/measurements/MeasurementNew.cpp @@ -37,10 +37,6 @@ void * operator new( std::size_t n, bool measure ) { } } -void * operator new( std::size_t n ) { - return operator new( n, true ); -} - void operator delete( void * ptr, bool measure ) noexcept { std::size_t * sptr = static_cast < std::size_t * > ( ptr ); @@ -52,7 +48,3 @@ void operator delete( void * ptr, bool measure ) noexcept { std::free ( sptr ); } - -void operator delete( void * ptr ) noexcept { - operator delete( ptr, false ); -} diff --git a/alib2measure/src/measurements/MeasurementNew.hpp b/alib2measure/src/measurements/MeasurementNew.hpp index d8f1b18e41..aa2437d821 100644 --- a/alib2measure/src/measurements/MeasurementNew.hpp +++ b/alib2measure/src/measurements/MeasurementNew.hpp @@ -7,10 +7,6 @@ void * operator new( std::size_t n, bool measure ); -void * operator new( std::size_t n ); - void operator delete( void * ptr, bool measure ) noexcept; -void operator delete( void * ptr ) noexcept; - #endif /* MEASUREMENT_NEW_HPP_ */ -- GitLab