Pull Request №763 RosettaCommons/rosetta/main ← lyskov-ai/rosetta/refactor/owning-raw-pointers-to-unique-ptr
Merge: 0c38201cdcd83a9217d947a1604b4317f71c6831←4066812b2d3eccc8fe66d5300f13054195e3fc6a
Replace manually-deleted owning raw pointers with std::unique_ptr
----------------
Merge commit message:
Replace manually-deleted owning raw pointers with std::unique_ptr
Twelve classes held a heap object by raw pointer and freed it with an
explicit delete in their destructor. Hold each in a std::unique_ptr
instead, so ownership is expressed in the type and the destructors stop
hand-managing memory.
Eight graph classes own boost::unordered_object_pool instances:
utility::graph::Graph and Digraph (element pool plus edge pool each),
EnergyGraph, MinimizationGraph, TenANeighborGraph,
BuriedUnsatPenaltyGraph, JobDigraph and SewGraph. In Graph and Digraph
this also corrects the teardown order: the explicit delete freed the
element pool from the destructor body while edge_list_ -- which holds a
reference to that pool and returns its elements to it as it is destroyed
-- was still alive. Member destruction now runs the list first and frees
the pool afterwards.
SICFast, MotifHashRigidScore, triangleIterator and FragmentCandidate
each owned a single object while leaving their copy operations implicit,
so copying any of them would have double-freed. The unique_ptr members
make them non-copyable.
MotifHashRigidScore::ssinfo1_ and ssinfo2_ were never allocated -- always
null, with their only readers commented out -- so they are deleted rather
than converted, along with the now-unused SS_Info2 includes.