fix memory leak in AliFileMerger
authorshahoian <ruben.shahoyan@cern.ch>
Tue, 2 Dec 2014 23:47:42 +0000 (00:47 +0100)
committershahoian <ruben.shahoyan@cern.ch>
Tue, 2 Dec 2014 23:48:03 +0000 (00:48 +0100)
ANALYSIS/AliFileMerger.cxx
ANALYSIS/AliFileMerger.h

index 3c07be8..f8d88fb 100644 (file)
@@ -91,7 +91,6 @@ AliFileMerger::AliFileMerger():
 }
 
 //______________________________________________________________________
-
 AliFileMerger::AliFileMerger(const char* name):
   TNamed(name,name),
   fRejectMask(0),
@@ -104,6 +103,13 @@ AliFileMerger::AliFileMerger(const char* name):
   //
 }
 
+//______________________________________________________________________
+AliFileMerger::~AliFileMerger()
+{
+  // d-tor
+  delete fRejectMask;
+  delete fAcceptMask;
+}
 
 void AliFileMerger::IterAlien(const char* outputDir, const char* outputFileName, const char* pattern, Bool_t dontOverwrite){
 
@@ -369,21 +375,28 @@ Bool_t AliFileMerger::IsRejected(TString name){
 
 
 
-void AliFileMerger::AddReject(const char *reject){
+void AliFileMerger::AddReject(const char *reject)
+{
   //
   // add reject string to the list of entries to be rejected for merging
   //
-  if (!fRejectMask) fRejectMask = new TObjArray;
+  if (!fRejectMask) {
+    fRejectMask = new TObjArray();
+    fRejectMask->SetOwner(kTRUE);
+  }
   fRejectMask->AddLast(new TObjString(reject));
 }
-void AliFileMerger::AddAccept(const char *accept){
+
+void AliFileMerger::AddAccept(const char *accept)
+{
   //
   // add reject string to the list of entries to be rejected for merging
   //
-  if (!fAcceptMask) fAcceptMask = new TObjArray;
+  if (!fAcceptMask) {
+    fAcceptMask = new TObjArray();
+    fAcceptMask->SetOwner(kTRUE);
+  }
   fAcceptMask->AddLast(new TObjString(accept));
-
-
 }
 
 //___________________________________________________________________________
@@ -404,6 +417,7 @@ int AliFileMerger::MergeRootfile( TDirectory *target, TList *sourcelist, Bool_t
   //
   Int_t nguess = sourcelist->GetSize()+1000;
   THashList allNames(nguess);
+  allNames.SetOwner(kTRUE);
   ((THashList*)target->GetList())->Rehash(nguess);
   ((THashList*)target->GetListOfKeys())->Rehash(nguess);
   TList listH;
index aecb230..8f36fb1 100644 (file)
@@ -22,6 +22,7 @@ class AliFileMerger : public TNamed
  public:
   AliFileMerger();
   AliFileMerger(const char* name);
+  virtual ~AliFileMerger();
   void Merge(TFile* fileIn, TObjArray * array);
 
   void IterTXT( const char * fileList,  const char* outputFileName,Bool_t dontOverwrite=kFALSE);