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

@ -42,7 +42,7 @@ endif
# -- Linux
ifeq ($(OS),LINUX)
CXX = g++
CXXFLAGS = -O3 -Wall -Wno-trigraphs -fPIC
CXXFLAGS = -g -O3 -Wall -Wno-trigraphs -fPIC
PMUSRPATH = ../include
MNPATH = $(ROOTSYS)/include
GSLPATH = /usr/include/gsl

View File

@ -103,6 +103,16 @@ PFitter::~PFitter()
{
fCmdList.clear();
if (fMnUserParamState) {
delete fMnUserParamState;
fMnUserParamState = 0;
}
if (fFcnMin) {
delete fFcnMin;
fFcnMin = 0;
}
if (fFitterFcn) {
delete fFitterFcn;
fFitterFcn = 0;
@ -831,13 +841,17 @@ bool PFitter::ExecuteSave()
hcorr->Draw("COLZTEXT");
else
hcorr->Draw("COLZ");
ccorr->Write();
ccorr->Write("ccorr", TObject::kOverwrite, sizeof(ccorr));
ff.Close();
// clean up
if (ccorr)
if (ccorr) {
delete ccorr;
if (hcorr)
ccorr = 0;
}
if (hcorr) {
delete hcorr;
hcorr = 0;
}
}
parNo.clear(); // clean up
} else {

View File

@ -96,6 +96,11 @@ PMsrHandler::~PMsrHandler()
fPlots.clear();
fStatistic.fStatLines.clear();
fParamInUse.clear();
if (fFuncHandler) {
delete fFuncHandler;
fFuncHandler = 0;
}
}
//--------------------------------------------------------------------------

View File

@ -1660,8 +1660,11 @@ bool PRunDataHandler::IsWhitespace(const char *str)
{
unsigned int i=0;
while (isblank(str[i]) || (iscntrl(str[i])) && str[i] != 0)
while (isblank(str[i]) || iscntrl(str[i])) {
if (str[i] == 0)
break;
i++;
}
if (i == strlen(str))
return true;

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>

View File

@ -199,6 +199,7 @@ class PTheory
virtual double Func(register double t, const PDoubleVector& paramValues, const PDoubleVector& funcValues) const;
private:
virtual void CleanUp(PTheory *theo);
virtual int SearchDataBase(TString name);
virtual void MakeCleanAndTidyTheoryBlock(PMsrLines* fullTheoryBlock);
virtual void MakeCleanAndTidyPolynom(unsigned int i, PMsrLines* fullTheoryBlock);

View File

@ -351,7 +351,7 @@ int main(int argc, char *argv[])
// read input file and write output file
char str[256];
int tag;
int tag = -1;
bool success = true;
while (!fin.eof() && success) {
fin.getline(str, sizeof(str));

View File

@ -123,10 +123,10 @@
</func>
<func>
<name>internFld</name>
<comment>(phase frequency Trate Lrate)</comment>
<comment>(fraction phase frequency Trate Lrate)</comment>
<label>internal Lorentz field</label>
<pixmap>internalField.png</pixmap>
<params>4</params>
<params>5</params>
</func>
<func>
<name>TFieldCos</name>