Skip to content
Snippets Groups Projects
Commit aca23dea authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

functions : remove memory leak

parent 75752d1d
Branches
Tags
No related merge requests found
...@@ -92,8 +92,8 @@ dataCacheDouble &dataCacheMap::substitute(const function *f) ...@@ -92,8 +92,8 @@ dataCacheDouble &dataCacheMap::substitute(const function *f)
dataCacheMap::~dataCacheMap() dataCacheMap::~dataCacheMap()
{ {
for (std::set<dataCacheDouble*>::iterator it = _toDelete.begin(); for (std::set<dataCacheDouble*>::iterator it = _allDataCaches.begin();
it!=_toDelete.end(); it++) { it!=_allDataCaches.end(); it++) {
delete *it; delete *it;
} }
} }
...@@ -309,7 +309,7 @@ class functionLua : public function { ...@@ -309,7 +309,7 @@ class functionLua : public function {
void dataCacheMap::setNbEvaluationPoints(int nbEvaluationPoints) { void dataCacheMap::setNbEvaluationPoints(int nbEvaluationPoints) {
_nbEvaluationPoints = nbEvaluationPoints; _nbEvaluationPoints = nbEvaluationPoints;
for(std::set<dataCacheDouble*>::iterator it = _toResize.begin(); it!= _toResize.end(); it++){ for(std::set<dataCacheDouble*>::iterator it = _allDataCaches.begin(); it!= _allDataCaches.end(); it++){
(*it)->resize(); (*it)->resize();
(*it)->_valid = false; (*it)->_valid = false;
} }
......
...@@ -147,18 +147,14 @@ class dataCacheMap { ...@@ -147,18 +147,14 @@ class dataCacheMap {
std::list<dataCacheMap*> _children; std::list<dataCacheMap*> _children;
int _nbEvaluationPoints; int _nbEvaluationPoints;
std::map<const function*, dataCacheDouble*> _cacheDoubleMap; std::map<const function*, dataCacheDouble*> _cacheDoubleMap;
std::set<dataCacheDouble*> _toDelete; std::set<dataCacheDouble*> _allDataCaches;
std::set<dataCacheDouble*> _toResize;
std::set<dataCacheDouble*> _toInvalidateOnElement; std::set<dataCacheDouble*> _toInvalidateOnElement;
MElement *_element; MElement *_element;
protected: protected:
void addDataCache(dataCacheDouble *data){
_toDelete.insert(data);
}
void addDataCacheDouble(dataCacheDouble *data, bool invalidatedOnElement){ void addDataCacheDouble(dataCacheDouble *data, bool invalidatedOnElement){
_toResize.insert(data); _allDataCaches.insert(data);
if(invalidatedOnElement) if(invalidatedOnElement)
_toInvalidateOnElement.insert(data); _toInvalidateOnElement.insert(data);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment