mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-22 09:39:34 +08:00
overloaded operator delete should call ei_conditinal_aligned_free, not
ei_aligned_free
This commit is contained in:
parent
b3d580dec7
commit
265ab86005
@ -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
|
||||
|
@ -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); }
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user