Added KDTree.__del__() that destroy the points to prevent memory leaks
authorDmitriy Morozov <dmitriy@mrzv.org>
Sat Jun 20 13:00:20 2009 -0700 (2 years ago)
changeset 7fc7a9f78a5db
parent 6e34a29c36f13
child 8ef31983c4dd2
Added KDTree.__del__() that destroy the points to prevent memory leaks
ann-kd-tree.cpp
       1 --- a/ann-kd-tree.cpp	Sat Jun 20 12:33:19 2009 -0700
       2 +++ b/ann-kd-tree.cpp	Sat Jun 20 13:00:20 2009 -0700
       3 @@ -24,6 +24,12 @@
       4      
       5      boost::shared_ptr<ANNkd_tree>   p(new ANNkd_tree(dataPts, npts, dimension));
       6      return p;
       7 +}
       8 +
       9 +void                                destroy_points(ANNkd_tree& kdtree)
      10 +{
      11 +    ANNpointArray   dataPts     = kdtree.thePoints();
      12 +    annDeallocPts(dataPts);
      13  }
      14  
      15  bp::tuple                           search(ANNkd_tree& kdtree, bp::list q, int k, double eps, bool priority = false)
      16 @@ -90,6 +96,7 @@
      17  {
      18      bp::class_<ANNkd_tree>("KDTree")
      19          .def("__init__",            bp::make_constructor(&init_from_list))
      20 +        .def("__del__",             &destroy_points)
      21  
      22          .def("kSearch",             &ksearch)
      23          .def("kPriSearch",          &k_priority_search)