some memory leak 'fixes'

This commit is contained in:
nemu
2009-04-20 14:12:26 +00:00
parent 61f6fd1b9c
commit 99dedce540
8 changed files with 57 additions and 17 deletions

View File

@ -301,15 +301,8 @@ PTheory::~PTheory()
fLFIntegral.clear();
fDynLFFuncValue.clear();
if (fMul) {
delete fMul;
fMul = 0;
}
if (fAdd) {
delete fAdd;
fAdd = 0;
}
// recursive clean up
CleanUp(this);
if (fUserFcn) {
delete fUserFcn;
@ -664,6 +657,30 @@ double PTheory::Func(register double t, const PDoubleVector& paramValues, const
return 0.0;
}
//--------------------------------------------------------------------------
/**
* <p> Recursively clean up theory
*
* \param theo
*/
void PTheory::CleanUp(PTheory *theo)
{
if (theo->fMul) { // '*' present
CleanUp(theo->fMul);
if (theo->fAdd) {
CleanUp(theo->fAdd);
delete theo;
theo = 0;
}
} else { // '*' NOT present
if (theo->fAdd) {
CleanUp(theo->fAdd);
delete theo;
theo = 0;
}
}
}
//--------------------------------------------------------------------------
/**
* <p>