Skip to content

Commit 5308621

Browse files
committed
Merge branch 'master' of github.com:mariusmuja/flann
2 parents 0a34c3f + 82f2b31 commit 5308621

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/cpp/flann/algorithms/hierarchical_clustering_index.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,18 @@ class HierarchicalClusteringIndex : public NNIndex<HierarchicalClusteringIndex<D
345345
if (ownDataset_) {
346346
delete[] dataset_.ptr();
347347
}
348+
349+
clearNodeTrees();
350+
}
351+
352+
/**
353+
* Clears Node tree
354+
* calling Node destructor explicitly
355+
*/
356+
void clearNodeTrees(){
357+
for (int i=0; i<trees_; ++i) {
358+
tree_roots_[i]->~Node();
359+
}
348360
}
349361

350362
/**
@@ -386,6 +398,7 @@ class HierarchicalClusteringIndex : public NNIndex<HierarchicalClusteringIndex<D
386398
extendDataset(points);
387399

388400
if (rebuild_threshold>1 && size_at_build_*rebuild_threshold<size_) {
401+
clearNodeTrees();
389402
pool_.free();
390403
buildIndex();
391404
}
@@ -501,6 +514,17 @@ class HierarchicalClusteringIndex : public NNIndex<HierarchicalClusteringIndex<D
501514
* Level
502515
*/
503516
int level;
517+
518+
/**
519+
* destructor
520+
* calling Node destructor explicitly
521+
*/
522+
~Node(){
523+
for(int i=0; i<childs.size(); i++){
524+
childs[i]->~Node();
525+
}
526+
};
527+
504528
};
505529
typedef Node* NodePtr;
506530

0 commit comments

Comments
 (0)