]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Fix Coverity
authorakisiel <akisiel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 13 Dec 2011 15:35:26 +0000 (15:35 +0000)
committerakisiel <akisiel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 13 Dec 2011 15:35:26 +0000 (15:35 +0000)
PWG2/FEMTOSCOPY/AliFemto/AliFemtoEvent.cxx

index 39e9cc1f4d7e2b233ab288ad0253f7a72a7eb6e0..f09b0a884a3d4cdc09d37141b7d137aaf6552b2a 100644 (file)
@@ -289,11 +289,43 @@ AliFemtoEvent& AliFemtoEvent::operator=(const AliFemtoEvent& aEvent)
   fTriggerCluster=aEvent.fTriggerCluster;
   fReactionPlaneAngle=aEvent.fReactionPlaneAngle;
   fEP=aEvent.fEP;
-  // create collections
+  if (fTrackCollection) {
+    for (AliFemtoTrackIterator iter=fTrackCollection->begin();iter!=fTrackCollection->end();iter++){
+      delete *iter;
+    }
+    fTrackCollection->clear();
+    delete fTrackCollection;
+  }
   fTrackCollection = new AliFemtoTrackCollection;
+
+  if (fV0Collection) {
+    for (AliFemtoV0Iterator tV0iter=fV0Collection->begin();tV0iter!=fV0Collection->end();tV0iter++){
+      delete *tV0iter;
+    }//added by M Chojnacki To avodid memory leak 
+    fV0Collection->clear();
+    delete fV0Collection;
+  }
+
   fV0Collection = new AliFemtoV0Collection;
+
+  if (fXiCollection) {
+    for (AliFemtoXiIterator tXiIter=fXiCollection->begin();tXiIter!=fXiCollection->end();tXiIter++){
+      delete *tXiIter;
+    }
+    fXiCollection->clear();
+    delete fXiCollection;
+  }
   fXiCollection = new AliFemtoXiCollection;
+  
+  if (fKinkCollection) {
+    for (AliFemtoKinkIterator kinkIter=fKinkCollection->begin();kinkIter!=fKinkCollection->end();kinkIter++){
+      delete *kinkIter;
+    }
+    fKinkCollection->clear();
+    delete fKinkCollection;
+  }
   fKinkCollection = new AliFemtoKinkCollection;
+
   // copy track collection  
   for ( AliFemtoTrackIterator tIter=aEvent.fTrackCollection->begin(); tIter!=aEvent.fTrackCollection->end(); tIter++) {
     AliFemtoTrack* trackCopy = new AliFemtoTrack(**tIter);