fix a memory leak in the destructor of AABB_tree

the primitive container was clear before deleting the nodes
(which was not done since the container was empty)

At the same time I made the delete of the KD-tree done only
if it was constructed
This commit is contained in:
Sébastien Loriot 2013-06-03 08:29:40 +02:00
parent fa177d6db5
commit 8bb442ae3b
2 changed files with 14 additions and 6 deletions

View File

@ -141,8 +141,8 @@ namespace CGAL {
void clear()
{
// clear AABB tree
m_primitives.clear();
clear_nodes();
m_primitives.clear();
clear_search_tree();
}
@ -385,7 +385,7 @@ public:
// clear nodes
void clear_nodes()
{
if(size() > 1) {
if( !empty() ) {
delete [] m_p_root_node;
}
m_p_root_node = NULL;
@ -394,10 +394,14 @@ public:
// clears internal KD tree
void clear_search_tree() const
{
delete m_p_search_tree;
m_p_search_tree = NULL;
m_search_tree_constructed = false;
m_default_search_tree_constructed = false;
if ( m_search_tree_constructed )
{
CGAL_assertion( m_p_search_tree!=NULL );
delete m_p_search_tree;
m_p_search_tree = NULL;
m_search_tree_constructed = false;
m_default_search_tree_constructed = false;
}
}
public:

View File

@ -148,6 +148,10 @@ David A. Wheeler's 'SLOCCount'</a>, restricted to the <code>include/CGAL/</code>
<li>Bug-fix in IO when using <code>Lazy_exact_nt</code> as number type or <code>Exact_predicates_exact_constructions_kernel</code> as kernel.</li>
</ul>
<h3>3D Fast Intersection and Distance Computation</h3>
<ul>
<li> Fix a memory leak in the destructor of the class <code>AABB-tree</code>
</ul>
</div>
<h2 id="release4.2">Release 4.2 </h2>