commit 1a027c525a55598699d5117e6fe79e6ce6d8a5ba
parent 74baa0d17070e41260cd2c26ed16ed2e47ba1457
Author: Fabian Wermelinger <fabianw@mavt.ethz.ch>
Date: Sun, 25 Sep 2016 15:07:55 +0200
revert common.h to previous commit
Current common.h generates issues with posix memalign
Diffstat:
| M | common.h | | | 32 | +++++++++----------------------- |
1 file changed, 9 insertions(+), 23 deletions(-)
diff --git a/common.h b/common.h
@@ -53,7 +53,7 @@ struct State
s[i] = rhs.s[i];
return *this;
}
- inline State& operator=(const Real c)
+ inline State& operator=(const double c)
{
for (int i = 0; i < _SIZE; ++i)
s[i] = c;
@@ -133,29 +133,17 @@ typedef State<Real,2> State2;
template <typename T, int _SS=0, int _SE=0>
class LightVector
{
- bool _bAllocated;
- size_t _N;
+ const size_t _N;
T* _data;
inline T* _alloc(const size_t n)
{
- if (!_data)
- {
- void* pmem;
- posix_memalign(&pmem, _ALIGN_, n*sizeof(T));
- _bAllocated = true;
- return (T*)pmem;
- }
- else
- return _data;
+ void* pmem;
+ posix_memalign(&pmem, _ALIGN_, n*sizeof(T));
+ return (T*)pmem;
}
- inline void _dealloc()
- {
- if (_data) free(_data);
- _bAllocated = false;
- _data = nullptr;
- }
+ inline void _dealloc() { free(_data); _data=0; }
inline void _copy(const T* const src)
{
@@ -172,9 +160,8 @@ class LightVector
}
public:
- LightVector() : _bAllocated(false), _N(0), _data(nullptr) {}
- LightVector(const int n) : _bAllocated(false), _N(n), _data(_alloc(n+(_SE-_SS))) { _clear(); }
- LightVector(const LightVector& rhs) : _bAllocated(false), _N(rhs._N), _data(_alloc(rhs._N+(_SE-_SS))) { _copy(rhs._data); }
+ LightVector(const int n) : _N(n), _data(_alloc(n+(_SE-_SS))) { _clear(); }
+ LightVector(const LightVector& rhs) : _N(rhs._N), _data(_alloc(rhs._N+(_SE-_SS))) { _copy(rhs._data); }
virtual ~LightVector() { _dealloc(); }
static const int SS = _SS;
@@ -215,7 +202,6 @@ public:
return *this;
}
- inline void allocate(const size_t n) { _N=n; _alloc(n+(_SE-_SS)); _clear(); }
inline size_t size() const { return _N; }
inline size_t size_all() const { return _N+_SE-_SS; }
inline void clear() { _clear(); }
@@ -269,7 +255,7 @@ public:
if (this != &rhs) _copy(rhs);
return *this;
}
- StateVector& operator=(Real const rhs)
+ StateVector& operator=(double const rhs)
{
for (size_t i = 0; i < m_state.size(); ++i)
m_state[i] = rhs;