-
Stephen Nicholas Swatman authored
In its current implementation, the TrkGlobalChi2Fitter has an internal memory management system with concepts of "ownership" over certain pointers. This mechanism makes it extremely difficult for anyone without very intimate knowledge of the code to make changes to it, as seemingly harmless changes to the code lead to segfaults and other errors. Our solution to this is to migrate the fitter's inner memory management code almost entirely to C++ smart pointers, which not only leverages RAII to ensure memory safety, but also ensures that unique pointers cannot simply be copied to create unsafe situations. Instead the programmer must explicitly move them, which adds a layer of protection to the development of the code. In the end, we feel this change makes the code more predictable, easier to maintain, more readable, and more safe.