[ROOT] CINT bug ?

From: Patois Yannick (patois@ganil.fr)
Date: Fri Oct 27 2000 - 10:19:22 MEST


Hi rooters,

ROOT version 2.25/03 on Linux-i386

I define a rootlogon.C with :

{gROOT->LoadMacro("usefulstufftest.C");}

So when I launch root it load the following file :
<<<< FILE usefulstufftest.C
TFile* get_file(char *name) {
  TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(name);
  if (!f)     f = new TFile(name);
  f->cd();  return(f);
}

TFile* get_file(char *fix,char *name0) {
  char fname[200];
  sprintf(fname,"%s%s",fix,name0);
  TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(fname);
  if (!f)     f = new TFile(fname);
  f->cd();  return(f);
}
>>>>

The two functions are very similar, and I regulary use it to open a root
file. But the second one seems to work only once.

I wrote the following macro :
<<<< FILE bug.C
void bug(void) {
  char *rname0[2]={"hsimple.root","hsimple2.root"};
  char *rname1[2]={".root","2.root"};

  for (int i=0;i<2;i++) {
// Opening the files using the first function
    TFile *f = get_file(rname0[i]);
    printf("name : %s\n",f->GetName());
// Opening the files using the second one
    TFile *f = get_file("hsimple",rname1[i]);
    printf("name : %s\n",f->GetName()); 
  }
}
>>>>

If I comment the opening using the second function everything is ok:

root [0] .x bug.C
name : hsimple.root
name : hsimple2.root
root [1] .x bug.C
name : hsimple.root
name : hsimple2.root

If I comment the first opening and uncomment the second, I get :

root [3] .x bug.C
name : hsimple.root   <--
name : hsimple2.root  <-- First time, opening OK
root [4] .x bug.C
Error in <TFile::TFile>: file  does not exist
name : 
Error in <TFile::TFile>: file  does not exist
name : 

Second time it doesnt work ! It seems that the pointer to the string
passed as argument is pointing anywhere, resulting in a completly
irrelevant file name.

Is this reproducable ?
As anybody and idea about what's wrong ?

	Yannick



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:36 MET