Thomas Schoerner wrote: > Hello, > > a probably very simple question: > > Assume that in ProcessCut I create objects on the heap and have a cut > which is not always fulfilled: > > Bool_t AnaJet::ProcessCut(Int_t entry) > { > m_AnaJet_Particles_Lab = new TObjArray; > ... > ... > if(somecondition) return kFALSE; > ... > ... > return kTRUE; > } > > If I manage to get to ProcessFill, I can delete the object and have no > problem: > > void AnaJet::ProcessFill(Int_t entry) > { > ... > delete m_AnaJet_Particles_Lab; > ... > } > > BUt what if somecondition is not fulfilled and I do not get to > ProcessFill? How can I efficienctly delete the object so that only the > pointer remains and I can reallocate memory during the next event? > > Cheers, > > Thomas Hello Thomas, Yous problem can be simply solved if you delete the object if the condition is not fulfilled. In the ProcessCut method, you can simply do: Bool_t AnaJet::ProcessCut(Int_t entry) { m_AnaJet_Particles_Lab = new TObjArray; ... ... if(somecondition) { delete m_AnaJet_Particles_Lab; return kFALSE; } ... ... return kTRUE; } I hope this helps. Cheers -- Daniel CUSSOL LPC Caen Boulevard du Marechal Juin 14050 CAEN CEDEX e-mail : cussol@in2p3.fr Tel : +33-(0)2-31-45-29-73 FAX : +33-(0)2-31-45-25-49
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET