From 512a4a15baabd26f7adf937ccb0cb230325007e9 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Tue, 15 Mar 2016 14:54:33 +0100 Subject: [PATCH] [GL] QuadTree: Prevent mem leaks. --- GeoLib/QuadTree.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GeoLib/QuadTree.h b/GeoLib/QuadTree.h index 64cbab9d167..b7c7236de14 100644 --- a/GeoLib/QuadTree.h +++ b/GeoLib/QuadTree.h @@ -384,16 +384,20 @@ private: POINT mid_point(_ll); mid_point[0] += (_ur[0] - _ll[0]) / 2.0; mid_point[1] += (_ur[1] - _ll[1]) / 2.0; + assert(_childs[0] == nullptr); _childs[0] = new QuadTree<POINT> (mid_point, _ur, this, _depth + 1, _max_points_per_node); // north east POINT h_ll(mid_point), h_ur(mid_point); h_ll[0] = _ll[0]; h_ur[1] = _ur[1]; + assert(_childs[1] == nullptr); _childs[1] = new QuadTree<POINT> (h_ll, h_ur, this, _depth + 1, _max_points_per_node); // north west + assert(_childs[2] == nullptr); _childs[2] = new QuadTree<POINT> (_ll, mid_point, this, _depth + 1, _max_points_per_node); // south west h_ll = _ll; h_ll[0] = mid_point[0]; h_ur = _ur; h_ur[1] = mid_point[1]; + assert(_childs[3] == nullptr); _childs[3] = new QuadTree<POINT> (h_ll, h_ur, this, _depth + 1, _max_points_per_node); // south east // distribute points to sub quadtrees -- GitLab