Commit 951c9fa9 authored by berenger-bramas's avatar berenger-bramas

Remove memory leaks (two forgotten deletes).

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@412 2616d619-271b-44dc-8df4-d4a8f33a7222
parent ba8c3c76
...@@ -119,6 +119,7 @@ public: ...@@ -119,6 +119,7 @@ public:
/** Desctructor */ /** Desctructor */
virtual ~FOctree() { virtual ~FOctree() {
delete [] boxWidthAtLevel; delete [] boxWidthAtLevel;
delete root;
} }
/** To get the tree height */ /** To get the tree height */
......
...@@ -25,7 +25,7 @@ public: ...@@ -25,7 +25,7 @@ public:
} }
/** Constructor from the memory pointer */ /** Constructor from the memory pointer */
FSmartPointer(ClassType* const inPointer) : pointer(0), counter(0) { explicit FSmartPointer(ClassType* const inPointer) : pointer(0), counter(0) {
assign(inPointer); assign(inPointer);
} }
...@@ -52,9 +52,11 @@ public: ...@@ -52,9 +52,11 @@ public:
/** Point to a new pointer, release if needed */ /** Point to a new pointer, release if needed */
void assign(ClassType* const inPointer){ void assign(ClassType* const inPointer){
release(); release();
pointer = inPointer; if( inPointer ){
counter = new int; pointer = inPointer;
(*counter) = 1; counter = new int;
(*counter) = 1;
}
} }
/** Point to a new pointer, release if needed */ /** Point to a new pointer, release if needed */
...@@ -62,16 +64,17 @@ public: ...@@ -62,16 +64,17 @@ public:
release(); release();
pointer = inPointer.pointer; pointer = inPointer.pointer;
counter = inPointer.counter; counter = inPointer.counter;
if(counter) (*counter) = (*counter) + 1; if(counter) (*counter) += 1;
} }
/** Dec counter and Release the memory last */ /** Dec counter and Release the memory last */
void release(){ void release(){
if(counter){ if(counter){
(*counter) = (*counter) - 1; (*counter) -= 1;
if( (*counter) == 0 ){ if( (*counter) == 0 ){
if(MemoryType == FSmartArrayMemory) delete[] pointer; if(MemoryType == FSmartArrayMemory) delete[] pointer;
else if(MemoryType == FSmartPointerMemory) delete pointer; else if(MemoryType == FSmartPointerMemory) delete pointer;
delete counter;
} }
pointer = 0; pointer = 0;
counter = 0; counter = 0;
......
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