* make WithAlignedOperatorNew always align even when vectorization is disabled

* make ei_aligned_malloc and ei_aligned_free honor custom operator new and delete
This commit is contained in:
Benoit Jacob
2008-12-30 14:11:35 +00:00
parent a2782964c1
commit 164f410bb5
4 changed files with 46 additions and 50 deletions

View File

@@ -127,7 +127,7 @@ template<typename T> class ei_matrix_storage<T, Dynamic, Dynamic, Dynamic>
inline explicit ei_matrix_storage() : m_data(0), m_rows(0), m_cols(0) {}
inline ei_matrix_storage(int size, int rows, int cols)
: m_data(ei_aligned_malloc<T>(size)), m_rows(rows), m_cols(cols) {}
inline ~ei_matrix_storage() { ei_aligned_free(m_data); }
inline ~ei_matrix_storage() { ei_aligned_free(m_data, m_rows*m_cols); }
inline void swap(ei_matrix_storage& other)
{ std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }
inline int rows(void) const {return m_rows;}
@@ -136,7 +136,7 @@ template<typename T> class ei_matrix_storage<T, Dynamic, Dynamic, Dynamic>
{
if(size != m_rows*m_cols)
{
ei_aligned_free(m_data);
ei_aligned_free(m_data, m_rows*m_cols);
m_data = ei_aligned_malloc<T>(size);
}
m_rows = rows;
@@ -154,7 +154,7 @@ template<typename T, int _Rows> class ei_matrix_storage<T, Dynamic, _Rows, Dynam
public:
inline explicit ei_matrix_storage() : m_data(0), m_cols(0) {}
inline ei_matrix_storage(int size, int, int cols) : m_data(ei_aligned_malloc<T>(size)), m_cols(cols) {}
inline ~ei_matrix_storage() { ei_aligned_free(m_data); }
inline ~ei_matrix_storage() { ei_aligned_free(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); }
inline static int rows(void) {return _Rows;}
inline int cols(void) const {return m_cols;}
@@ -162,7 +162,7 @@ template<typename T, int _Rows> class ei_matrix_storage<T, Dynamic, _Rows, Dynam
{
if(size != _Rows*m_cols)
{
ei_aligned_free(m_data);
ei_aligned_free(m_data, _Rows*m_cols);
m_data = ei_aligned_malloc<T>(size);
}
m_cols = cols;
@@ -179,7 +179,7 @@ template<typename T, int _Cols> class ei_matrix_storage<T, Dynamic, Dynamic, _Co
public:
inline explicit ei_matrix_storage() : m_data(0), m_rows(0) {}
inline ei_matrix_storage(int size, int rows, int) : m_data(ei_aligned_malloc<T>(size)), m_rows(rows) {}
inline ~ei_matrix_storage() { ei_aligned_free(m_data); }
inline ~ei_matrix_storage() { ei_aligned_free(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); }
inline int rows(void) const {return m_rows;}
inline static int cols(void) {return _Cols;}
@@ -187,7 +187,7 @@ template<typename T, int _Cols> class ei_matrix_storage<T, Dynamic, Dynamic, _Co
{
if(size != m_rows*_Cols)
{
ei_aligned_free(m_data);
ei_aligned_free(m_data, _Cols*m_rows);
m_data = ei_aligned_malloc<T>(size);
}
m_rows = rows;