- Fix deletion using an ad-hoc functor to avoid memory leaks, instead that ptr_fun(operator delete). Valgrind says we're doing well with History\!

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@787 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-07-20 21:50:28 +00:00
parent 69a7ee03eb
commit 19ee5c1884
8 changed files with 62 additions and 8 deletions

View file

@ -35,6 +35,7 @@
#include "history_observer.hh"
#include "concrete_history.hh"
#include "deletor.tcc"
#include "smartp.tcc"
#include <algorithm>
@ -44,6 +45,7 @@
using namespace sgpem;
using namespace std;
using memory::smart_ptr;
using memory::deletor;
// ---------------
@ -88,7 +90,8 @@ ConcreteHistory::ConcreteHistory()
ConcreteHistory::~ConcreteHistory()
{
for_each(_snapshots.begin(), _snapshots.end(), ptr_fun(operator delete));
for_each(_snapshots.begin(), _snapshots.end(),
deletor<ConcreteEnvironment>());
}
ConcreteHistory::ConcreteHistory(const ConcreteHistory& h) :
@ -391,7 +394,7 @@ ConcreteHistory::reset(bool notify)
Snapshots::iterator it = _snapshots.begin();
it++; // Skip first environment that we saved
for_each(it, _snapshots.end(), ptr_fun(operator delete));
for_each(it, _snapshots.end(), deletor<ConcreteEnvironment>());
_snapshots.resize(1); // Truncate to keep only our "model"
if(notify)