aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-01-09 21:28:53 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-01-09 21:28:53 +0000
commit265ab860056bade3d4dc1c35b7c73820a76db55d (patch)
tree49f9f770e518d004b2267872c77cc221aa9e04f2 /Eigen
parentb3d580dec7af716e4e384dae0f7bb5c05278a0a1 (diff)
overloaded operator delete should call ei_conditinal_aligned_free, not
ei_aligned_free
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/src/Core/Matrix.h4
-rw-r--r--Eigen/src/Core/MatrixStorage.h19
-rw-r--r--Eigen/src/Core/util/Memory.h4
3 files changed, 25 insertions, 2 deletions
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index d16cae031..893b765ef 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -25,6 +25,8 @@
#ifndef EIGEN_MATRIX_H
#define EIGEN_MATRIX_H
+struct ei_select_matrix_constructor_doing_absolutely_nothing {};
+
/** \class Matrix
*
* \brief The matrix class, also used for vectors and row-vectors
@@ -131,6 +133,8 @@ class Matrix
protected:
ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime, Options> m_storage;
+ Matrix(ei_select_matrix_constructor_doing_absolutely_nothing) // this ctor does not even do an assertion
+ : m_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing) {}
public:
enum { NeedsToAlign = (Options&AutoAlign) == AutoAlign
diff --git a/Eigen/src/Core/MatrixStorage.h b/Eigen/src/Core/MatrixStorage.h
index 9806dc6b2..b02c47a60 100644
--- a/Eigen/src/Core/MatrixStorage.h
+++ b/Eigen/src/Core/MatrixStorage.h
@@ -26,6 +26,9 @@
#ifndef EIGEN_MATRIXSTORAGE_H
#define EIGEN_MATRIXSTORAGE_H
+struct ei_select_matrix_storage_constructor_doing_absolutely_nothing {};
+struct ei_select_matrix_array_constructor_doing_absolutely_nothing {};
+
/** \internal
* Static array automatically aligned if the total byte size is a multiple of 16 and the matrix options require auto alignment
*/
@@ -42,6 +45,8 @@ template <typename T, int Size, int MatrixOptions,
&& "this assertion is explained here: http://eigen.tuxfamily.org/api/UnalignedArrayAssert.html **** READ THIS WEB PAGE !!! ****");
#endif
}
+
+ ei_matrix_array(ei_select_matrix_array_constructor_doing_absolutely_nothing) {}
};
template <typename T, int Size, int MatrixOptions> struct ei_matrix_array<T,Size,MatrixOptions,false>
@@ -68,6 +73,8 @@ template<typename T, int Size, int _Rows, int _Cols, int _Options> class ei_matr
ei_matrix_array<T,Size,_Options> m_data;
public:
inline explicit ei_matrix_storage() {}
+ inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing)
+ : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing) {}
inline ei_matrix_storage(int,int,int) {}
inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); }
inline static int rows(void) {return _Rows;}
@@ -85,6 +92,8 @@ template<typename T, int Size, int _Options> class ei_matrix_storage<T, Size, Dy
int m_cols;
public:
inline explicit ei_matrix_storage() : m_rows(0), m_cols(0) {}
+ inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing)
+ : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing) {}
inline ei_matrix_storage(int, int rows, int cols) : m_rows(rows), m_cols(cols) {}
inline ~ei_matrix_storage() {}
inline void swap(ei_matrix_storage& other)
@@ -107,6 +116,8 @@ template<typename T, int Size, int _Cols, int _Options> class ei_matrix_storage<
int m_rows;
public:
inline explicit ei_matrix_storage() : m_rows(0) {}
+ inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing)
+ : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing) {}
inline ei_matrix_storage(int, int rows, int) : m_rows(rows) {}
inline ~ei_matrix_storage() {}
inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
@@ -127,6 +138,8 @@ template<typename T, int Size, int _Rows, int _Options> class ei_matrix_storage<
int m_cols;
public:
inline explicit ei_matrix_storage() : m_cols(0) {}
+ inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing)
+ : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing) {}
inline ei_matrix_storage(int, int, int cols) : m_cols(cols) {}
inline ~ei_matrix_storage() {}
inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
@@ -148,6 +161,8 @@ template<typename T, int _Options> class ei_matrix_storage<T, Dynamic, Dynamic,
int m_cols;
public:
inline explicit ei_matrix_storage() : m_data(0), m_rows(0), m_cols(0) {}
+ inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing)
+ : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing) {}
inline ei_matrix_storage(int size, int rows, int cols)
: m_data(ei_aligned_new<T>(size)), m_rows(rows), m_cols(cols) {}
inline ~ei_matrix_storage() { ei_aligned_delete(m_data, m_rows*m_cols); }
@@ -176,6 +191,8 @@ template<typename T, int _Rows, int _Options> class ei_matrix_storage<T, Dynamic
int m_cols;
public:
inline explicit ei_matrix_storage() : m_data(0), m_cols(0) {}
+ inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing)
+ : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing) {}
inline ei_matrix_storage(int size, int, int cols) : m_data(ei_aligned_new<T>(size)), m_cols(cols) {}
inline ~ei_matrix_storage() { ei_aligned_delete(m_data, _Rows*m_cols); }
inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
@@ -201,6 +218,8 @@ template<typename T, int _Cols, int _Options> class ei_matrix_storage<T, Dynamic
int m_rows;
public:
inline explicit ei_matrix_storage() : m_data(0), m_rows(0) {}
+ inline ei_matrix_storage(ei_select_matrix_storage_constructor_doing_absolutely_nothing)
+ : m_data(ei_select_matrix_array_constructor_doing_absolutely_nothing) {}
inline ei_matrix_storage(int size, int rows, int) : m_data(ei_aligned_new<T>(size)), m_rows(rows) {}
inline ~ei_matrix_storage() { ei_aligned_delete(m_data, _Cols*m_rows); }
inline void swap(ei_matrix_storage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h
index 4a60da58b..e833d4294 100644
--- a/Eigen/src/Core/util/Memory.h
+++ b/Eigen/src/Core/util/Memory.h
@@ -293,8 +293,8 @@ inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset)
void *operator new[](size_t size) throw() { \
return Eigen::ei_conditional_aligned_malloc<NeedsToAlign>(size); \
} \
- void operator delete(void * ptr) { Eigen::ei_aligned_free(ptr); } \
- void operator delete[](void * ptr) { Eigen::ei_aligned_free(ptr); } \
+ void operator delete(void * ptr) { Eigen::ei_conditinal_aligned_free<NeedsToAlign>(ptr); } \
+ void operator delete[](void * ptr) { Eigen::ei_conditinal_aligned_free<NeedsToAlign>(ptr); } \
EIGEN_WORKAROUND_FOR_QT_BUG_CALLING_WRONG_OPERATOR_NEW
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(true)