Commit 63985edd authored by Hans-Christian Ebke's avatar Hans-Christian Ebke
Browse files

Fixed allocation bug.

parent 8ece0770
Pipeline #686 passed with stage
......@@ -648,7 +648,7 @@ protected: //------------------------------------------- synchronize properties
void vprops_reserve(size_t _n) const { vprops_.reserve(_n); }
void vprops_resize(size_t _n) const { vprops_.resize(_n); }
void vprops_resize_if_smaller(size_t _n) const { if (vprops_.size() < _n) vprops_.resize(_n); }
void vprops_resize_if_smaller(size_t _n) const { vprops_.resize_if_smaller(_n); }
void vprops_clear() {
vprops_.clear();
}
......
......@@ -211,6 +211,11 @@ public:
[_n](BaseProperty* p) { if (p) p->resize(_n); });
}
void resize_if_smaller(size_t _n) const {
std::for_each(properties_.begin(), properties_.end(),
[_n](BaseProperty* p) { if (p && p->n_elements() < _n) p->resize(_n); });
}
void swap(size_t _i0, size_t _i1) const {
std::for_each(properties_.begin(), properties_.end(),
[_i0, _i1](BaseProperty* p) { if (p) p->swap(_i0, _i1); });
......@@ -224,6 +229,10 @@ public:
std::for_each(properties_.begin(), properties_.end(), Resize(_n));
}
void resize_if_smaller(size_t _n) const {
std::for_each(properties_.begin(), properties_.end(), ResizeIfSmaller(_n));
}
void swap(size_t _i0, size_t _i1) const {
std::for_each(properties_.begin(), properties_.end(), Swap(_i0, _i1));
}
......@@ -290,6 +299,13 @@ private:
size_t n_;
};
struct ResizeIfSmaller
{
ResizeIfSmaller(size_t _n) : n_(_n) {}
void operator()(BaseProperty* _p) const { if (_p && _p->n_elements() < n_) _p->resize(n_); }
size_t n_;
};
struct ClearAll
{
ClearAll() {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment