Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.

Commit b3d0e00

Browse files
EinarElentomeichlersmith
authored andcommitted
Don't report that G4Region is leaked (it isn't)
1 parent 55704b0 commit b3d0e00

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/SimCore/Geo/AuxInfoReader.cxx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,18 @@ void AuxInfoReader::createRegion(G4String name,
246246

247247
G4VUserRegionInformation* regionInfo =
248248
new UserRegionInformation(storeTrajectories);
249-
G4Region* region = new G4Region(name);
249+
// This looks like a memory leak, but isn't. I (Einar) have checked. Geant4
250+
// registers the region in the constructor and deletes it at the end.
251+
//
252+
// Some static analysis tools may struggle with identifying that this one
253+
// happens to be fine. The NOLINT comment tells clang-tidy to not bother
254+
// within the region
255+
//
256+
// NOLINTBEGIN
257+
auto region = new G4Region(name);
250258
region->SetUserInformation(regionInfo);
251-
252-
// G4cout << "Created new detector region " << region->GetName() << G4endl <<
253-
// G4endl;
254259
}
260+
// NOLINTEND
255261

256262
void AuxInfoReader::createVisAttributes(G4String name,
257263
const G4GDMLAuxListType* auxInfoList) {

0 commit comments

Comments
 (0)