[ROOT] push_back giving me problems

From: David R. Relyea (relyea@SLAC.stanford.edu)
Date: Fri Jan 11 2002 - 07:44:26 MET


Push_back from stl::vector is giving me problems.  If I run this code:

#include <vector>
(many other includes)

void something() {

  mfile = TMapFile::Create("e.map");

  // Get all data entries in file

  TMapRec *mr = mfile->GetFirst();

  vector< TString* > hts;

  while (mfile->OrgAddress(mr)) {
    TString boo = mr->GetClassName();
    if(boo.Contains("TH1F")) {
      TString* nname=new TString(mr->GetName());
      hts.push_back(nname);
      cout << boo << "\t" << nname->Data() << endl;
    }
    mr   = mr->GetNext();
  }
}

If I comment out the line

      hts.push_back(nname);

, this runs perfectly well (in CINT) over my entire TMapfile.  However, if
I uncomment that line (as shown) and run this in CINT, it seg faults after
two iterations of the while loop, specifically on the

TString boo = mr->GetClassName()

.  Is this a problem CINT has with vectors (which I doubt), or does this
have something to do with how TMapFile handles pointers?  Any advice would
be appreciated.  Thanks.

David Relyea



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:37 MET