Dear Rooters The following code fragment works fine when compiled, but causes CINT to give a ***Break *** bus error: //------------------------- char nextline[4096]; input.getline(nextline, 4096, delim); TString str = ""; char *tmpname = new char[strlen(nextline) + 1]; char *delname = tmpname; tmpname = strtok(strcpy(tmpname,nextline),sep); while(tmpname) { if (strstr(tmpname,var) != 0) { str = SubString(tmpname, '(',')'); //<====causes error // TString str = SubString(tmpname, '(',')'); //<===no error!! // str = tmpname; //<===no error cout << "str= " << str << endl; }//if tmpname = strtok(NULL, sep); //<======malloc error in 1. case if (tmpname == 0) break; }//while delete [] delname; //------------------------- TString SubString(const char *name, char sep1, char sep2) { // Extract substring between first sep1 and last sep2 TString outname = TString(name); Int_t first = outname.First(sep1) + 1; Int_t last = outname.Last(sep2); Int_t len = last - first; outname = &outname[first]; if (last > 0) outname.Resize(len); return outname; }//SubString //------------------------ While the compiled code works fine, in CINT I get the following error: *** malloc[416]: Deallocation of a pointer not malloced: 0x1b2d565; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug However, when "str" is initialized within the while() loop as "TString str", or when I write "str = tmpname" (see code fragment), CINT is able to run the code without problems. Could there be something wrong with my code? Could this be a general problem of CINT not being able to handle the case of an "if" statement within a "while()" loop, or could this be a problem on MacOS X only? (I am running root 3.04/01 on MacOS X 1.1.2) Thank you in advance for your help. Best regards Christian _._._._._._._._._._._._._._._._ C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a V.i.e.n.n.a A.u.s.t.r.i.a _._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:24 MET