Skip to content

Commit d1a3d52

Browse files
author
Han Hu
committed
fix constructor and deconstructor of the KDTreeIndex::Node. This will cause the serialization work incorrectly in the case of the debug version and when the child pointer is not initialized as NULL automatically.
Because in saving node, serilazation relies on leaf_node = ((child1==NULL) && (child2==NULL)) to determine whether it's leaf or not.
1 parent 6f1d8f8 commit d1a3d52

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/cpp/flann/algorithms/kdtree_index.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,19 @@ class KDTreeIndex : public NNIndex<Distance>
299299
* Point data
300300
*/
301301
ElementType* point;
302-
/**
303-
* The child nodes.
304-
*/
305-
Node* child1, * child2;
306-
307-
~Node() {
308-
if (child1!=NULL) child1->~Node();
309-
if (child2!=NULL) child2->~Node();
310-
}
302+
/**
303+
* The child nodes.
304+
*/
305+
Node* child1, *child2;
306+
Node(){
307+
child1 = NULL;
308+
child2 = NULL;
309+
}
310+
~Node() {
311+
if (child1 != NULL) { child1->~Node(); child1 = NULL; }
312+
313+
if (child2 != NULL) { child2->~Node(); child2 = NULL; }
314+
}
311315

312316
private:
313317
template<typename Archive>

0 commit comments

Comments
 (0)