[ROOT] TFolder vs TDirectory ownership

From: Pierre-Luc Drouin (pldrouin@physics.carleton.ca)
Date: Fri May 30 2003 - 20:57:08 MEST


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