Use boost::shared_ptr to avoid a memory leak

This commit is contained in:
Andreas Fabri 2013-11-19 10:28:51 +01:00
parent da1791759c
commit 9ab541b052
2 changed files with 8 additions and 5 deletions

3
Skin_surface_3/include/CGAL/Skin_surface_base_3.h Normal file → Executable file
View File

@ -30,6 +30,7 @@
#include <boost/random/linear_congruential.hpp>
#include <boost/random/uniform_smallint.hpp>
#include <boost/random/variate_generator.hpp>
#include <boost/shared_ptr.hpp>
// For the Weighted_converter
#include <CGAL/Regular_triangulation_euclidean_traits_3.h>
@ -88,7 +89,7 @@ private:
public:
typedef Anchor_point Vertex_info;
typedef std::pair<Simplex, Quadratic_surface *> Cell_info;
typedef std::pair<Simplex, boost::shared_ptr<Quadratic_surface> > Cell_info;
private:
// Triangulated_mixed_complex:

View File

@ -24,6 +24,8 @@
#include <CGAL/Skin_surface_quadratic_surface_3.h>
#include <CGAL/Triangulation_simplex_3.h>
#include <boost/shared_ptr.hpp>
namespace CGAL {
template <class T>
@ -162,7 +164,7 @@ public:
FT shrink;
Rt_Simplex prev_s;
Quadratic_surface *surf;
boost::shared_ptr<Quadratic_surface> surf;
// c is the center of the orthogonal sphere
// w is the weight of the orthogonal sphere
@ -177,14 +179,14 @@ public:
Q[1] = Q[3] = Q[4] = 0;
Q[0] = Q[2] = Q[5] = orient;
surf = new Quadratic_surface(Q, c, s*w, (orient==1? 0 : 3));
surf = boost::shared_ptr<Quadratic_surface>(new Quadratic_surface(Q, c, s*w, (orient==1? 0 : 3)));
} else {
// Multiply with 1-s to make the function defining the
// skin surface implicitly continuous
Q[1] = Q[3] = Q[4] = 0;
Q[0] = Q[2] = Q[5] = orient*(1-s);
surf = new Quadratic_surface(Q, c, s*(1-s)*w, (orient==1? 0 : 3));
surf = boost::shared_ptr<Quadratic_surface>(new Quadratic_surface(Q, c, s*(1-s)*w, (orient==1? 0 : 3)));
}
}
@ -204,7 +206,7 @@ public:
Q[4] = orient*(-2*t.z()*t.y()/den);
Q[5] = orient*(- t.z()*t.z()/den + (1-s));
surf = new Quadratic_surface(Q, c, s*(1-s)*w, (orient==1? 1 : 2));
surf = boost::shared_ptr<Quadratic_surface>(new Quadratic_surface(Q, c, s*(1-s)*w, (orient==1? 1 : 2)));
}
Surface_RT Q[6];