Leak when reading std::vector

Hi Wile

Don’t you think that instead of:

Yes, I agree. The original code snippet can be improved by using the more modern and safer interface. I am guessing that the intent is to read just the vector in which case the pointer would be useful. Finally the code can also be slightly updated to support also TChain.

[code]{
TFile output(“output.root”);
std::vector* v = nullptr;

TTree *tree; output.GetObject(“tree”, tree);
if (!tree) return -1; // just a precaution
TBranch *bvpx = 0;
tree->SetBranchAddress(“vector”, &v, &bvpx);
for(Long64_t e = 0; e < tree->GetEntriesFast(); ++e) {
Long64_t local = tree->LoadTree(e);
bvpx->GetEntry(local);
// use v
}
tree->ResetBranchAddresses();
delete v;
}[/code]

Cheers,
Philippe.