Clear Patch for OpenMesh.. free all used memory on mesh clear
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@190 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -64,7 +64,7 @@ public:
|
||||
//-------------------------------------------------- constructor / destructor
|
||||
|
||||
PropertyContainer() {}
|
||||
virtual ~PropertyContainer() { clear(); }
|
||||
virtual ~PropertyContainer() { std::for_each(properties_.begin(), properties_.end(), Delete()); }
|
||||
|
||||
|
||||
//------------------------------------------------------------- info / access
|
||||
@@ -177,7 +177,16 @@ public:
|
||||
|
||||
void clear()
|
||||
{
|
||||
std::for_each(properties_.begin(), properties_.end(), Delete());
|
||||
// Clear properties vector:
|
||||
// Replaced the old version with new one
|
||||
// which performs a swap to clear values and
|
||||
// deallocate memory.
|
||||
|
||||
// Old version (changed 22.07.09) {
|
||||
// std::for_each(properties_.begin(), properties_.end(), Delete());
|
||||
// }
|
||||
|
||||
std::for_each(properties_.begin(), properties_.end(), ClearAll());
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +265,12 @@ private:
|
||||
size_t n_;
|
||||
};
|
||||
|
||||
struct ClearAll
|
||||
{
|
||||
ClearAll() {}
|
||||
void operator()(BaseProperty* _p) const { if (_p) _p->clear(); }
|
||||
};
|
||||
|
||||
struct Swap
|
||||
{
|
||||
Swap(size_t _i0, size_t _i1) : i0_(_i0), i1_(_i1) {}
|
||||
|
||||
Reference in New Issue
Block a user