Fix the memory leak in minkowski_sum_3

Gaussian_map allocates a Sphere_map on every construction and passes
it off to its base class SM_decorator. The decorator has a shallow
copy-constructor and doesn't clean up its resource.

The best fix would be to use a shared_ptr for psm_ in SM_decorator,
but that possibly breaks users and classes that actually account for
the missing memory management.

This is the worst of all possible fixes. We just clean up all
pointers. The code now checks fine with gperftools and
HEAPCHECK=strict
This commit is contained in:
Philipp Möller 2013-02-08 00:25:20 +01:00
parent 52684f2b1a
commit 3a0932f578
1 changed files with 10 additions and 0 deletions

View File

@ -220,6 +220,16 @@ bipartite_nary_union_sorted_combined(Nef_polyhedron& N0,
Ntmp.delegate(Convertor, true); Ntmp.delegate(Convertor, true);
CGAL_assertion(Ntmp.is_valid()); CGAL_assertion(Ntmp.is_valid());
nary_union.add_polyhedron(Ntmp); nary_union.add_polyhedron(Ntmp);
delete GcG.sphere_map();
}
// clean up the spherical_mapS
for(GM_iterator it = GM0.begin(); it != GM0.end(); ++it) {
delete it->first.sphere_map();
}
for(GM_iterator it = GM1.begin(); it != GM1.end(); ++it) {
delete it->first.sphere_map();
} }
return nary_union.get_union(); return nary_union.get_union();