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:
/** Desctructor */
virtual ~FOctree() {
delete [] boxWidthAtLevel;
delete root;
}
/** To get the tree height */
......
......@@ -25,7 +25,7 @@ public:
}
/** Constructor from the memory pointer */
FSmartPointer(ClassType* const inPointer) : pointer(0), counter(0) {
explicit FSmartPointer(ClassType* const inPointer) : pointer(0), counter(0) {
assign(inPointer);
}
......@@ -52,26 +52,29 @@ public:
/** Point to a new pointer, release if needed */
void assign(ClassType* const inPointer){
release();
if( inPointer ){
pointer = inPointer;
counter = new int;
(*counter) = 1;
}
}
/** Point to a new pointer, release if needed */
void assign(const FSmartPointer& inPointer){
release();
pointer = inPointer.pointer;
counter = inPointer.counter;
if(counter) (*counter) = (*counter) + 1;
if(counter) (*counter) += 1;
}
/** Dec counter and Release the memory last */
void release(){
if(counter){
(*counter) = (*counter) - 1;
(*counter) -= 1;
if( (*counter) == 0 ){
if(MemoryType == FSmartArrayMemory) delete[] pointer;
else if(MemoryType == FSmartPointerMemory) delete pointer;
delete counter;
}
pointer = 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