diff options
-rw-r--r-- | Eigen/src/Core/util/Memory.h | 2 | ||||
-rw-r--r-- | test/dynalloc.cpp | 31 |
2 files changed, 33 insertions, 0 deletions
diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 38990566d..810ee786b 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -703,6 +703,8 @@ template<typename T> class aligned_stack_memory_handler } \ void operator delete(void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \ void operator delete[](void * ptr) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \ + void operator delete(void * ptr, std::size_t /* sz */) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \ + void operator delete[](void * ptr, std::size_t /* sz */) throw() { Eigen::internal::conditional_aligned_free<NeedsToAlign>(ptr); } \ /* in-place new and delete. since (at least afaik) there is no actual */ \ /* memory allocated we can safely let the default implementation handle */ \ /* this particular case. */ \ diff --git a/test/dynalloc.cpp b/test/dynalloc.cpp index c98cc80f0..4f53ea6f0 100644 --- a/test/dynalloc.cpp +++ b/test/dynalloc.cpp @@ -93,6 +93,32 @@ template<typename T> void check_dynaligned() } } +template<typename T> void check_custom_new_delete() +{ + { + T* t = new T; + delete t; + } + + { + std::size_t N = internal::random<std::size_t>(1,10); + T* t = new T[N]; + delete[] t; + } + +#ifdef EIGEN_ALIGN + { + T* t = static_cast<T *>((T::operator new)(sizeof(T))); + (T::operator delete)(t, sizeof(T)); + } + + { + T* t = static_cast<T *>((T::operator new)(sizeof(T))); + (T::operator delete)(t); + } +#endif +} + void test_dynalloc() { // low level dynamic memory allocation @@ -109,6 +135,11 @@ void test_dynalloc() CALL_SUBTEST(check_dynaligned<Vector4d>() ); CALL_SUBTEST(check_dynaligned<Vector4i>() ); CALL_SUBTEST(check_dynaligned<Vector8f>() ); + + CALL_SUBTEST( check_custom_new_delete<Vector4f>() ); + CALL_SUBTEST( check_custom_new_delete<Vector2f>() ); + CALL_SUBTEST( check_custom_new_delete<Matrix4f>() ); + CALL_SUBTEST( check_custom_new_delete<MatrixXi>() ); } // check static allocation, who knows ? |