Hi Pierre-Luc Following the statements: gDirectory->Add(list); gDirectory->Delete("*;*"); delete list; your program will crash soon or later. In your case, the program may give the illusion to run because the deleted list has not yet been overwritten by a new object. I suggest using a tool like valgrind that will report a problem with your statements. Rene Brun On Fri, 30 May 2003, Pierre-Luc Drouin wrote: > Hello, > > In a mail posted on Tue Feb 26 2002, Rene Brun wrote: > > TDirectory and TFolder both manage tree like structures. > There are many differences between the two classes. > TDirectory manages hierachical structures in memory AND disk. > TFolder knows only about memory. > TDirectory always owns the objects. This is not the case > with a TFolder. > > I've tried the following code: > TList* list=new TList; > TObjString* buf=NULL; > for(Int_t i = 0; i<cardbuf.Count();i++){ > buf=new TObjString; > *buf=cardbuf[i][formulaindex].Data(); > list->Add(buf); > } > gDirectory->Add(list); > gDirectory->Delete("*;*"); > delete list; > > If TDirectory owned always its objects, it should fail on last line > because it would try to free memory that is already freed. However, it > doesn't. Why? > > Where can I find detailed documentation about ownership of > List/Array/Tree/Directory classes in Root? > > Thank you! > > Pierre-Luc Drouin > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET