fix last leak as reported by valgrind pyrit
authorRadek Brich <radek.brich@devl.cz>
Sun, 25 Nov 2007 22:22:40 +0100
branchpyrit
changeset 17 5176ba000a67
parent 16 20bceb605f48
child 18 25b7c445cf61
fix last leak as reported by valgrind
Makefile
src/kdtree.cc
--- a/Makefile	Sun Nov 25 21:47:10 2007 +0100
+++ b/Makefile	Sun Nov 25 22:22:40 2007 +0100
@@ -34,8 +34,8 @@
 %.o: src/%.cc
 	$(CXX) -c -o $@ src/$*.cc $(CCFLAGS)
 
-test%: tests/%.cc 
-	$(CXX) -o $@ tests/$*.cc $(CCFLAGS) 
+test%: tests/%.cc
+	$(CXX) -o $@ tests/$*.cc $(CCFLAGS)
 	./$@
 
 
--- a/src/kdtree.cc	Sun Nov 25 21:47:10 2007 +0100
+++ b/src/kdtree.cc	Sun Nov 25 22:22:40 2007 +0100
@@ -90,7 +90,7 @@
 KdNode::~KdNode()
 {
 	if (isLeaf())
-		;//delete shapes;  // this sigsegvs for unknown reason
+		delete shapes;
 	else
 		delete[] children;
 }
@@ -237,7 +237,7 @@
 	float rnum = splitpos->rnum;
 
 	// split this node
-	//delete shapes;
+	delete shapes;
 	children = new KdNode[2];
 	int state = 0;
 	for (sh = sslist.begin(); sh != sslist.end(); sh++)
@@ -301,7 +301,9 @@
 void KdTree::build()
 {
 	root = new KdNode();
-	root->shapes = &shapes;
+	ShapeList::iterator shape;
+	for (shape = shapes.begin(); shape != shapes.end(); shape++)
+		root->addShape(*shape);
 	root->subdivide(bbox, 0);
 	built = true;
 }