Advertisement

Deleting a BSP tree

Started by October 02, 2000 01:55 AM
0 comments, last by Ecco2000 24 years, 3 months ago
After installing a memory manager in my sample I realized it was time to clean up after my self as far as the bsp struct goes when I saw that I had 24 memory leaks. So I wrote this function to solve all my problems but it didn''t 15 of those memory leaks still exist in the bsp tree. Is there something I''m missing or is there an easier way to delete this struct.
    
struct polygon
{
	vec3_t p1, p2, p3;
	vec3_t normal;
	vec3_t color;
	polygon* next;

};

struct bsp
{
	polygon splitter;
	bsp* front;
	bsp* back;
};

//----------------------------------------------------------------------------

//	BSP_Delete -- Delete a bsp struct

//

//	Parameters

//	 currentnode -- The starting node to delete beneath.

//

//	Returns

//	 none

//----------------------------------------------------------------------------

void BSP_Delete(bsp* currentnode)
{
	// If there is a node to the front of this process it.

	if (currentnode->front != NULL) 
	{
		BSP_Delete(currentnode->front);
	}
	// Processed everything to the front of this so delete it

	delete(currentnode->front);
	// If there is a node to the back of this process it.

	if (currentnode->back != NULL) 
	{
		BSP_Delete(currentnode->back);
	}
	// Processed everything to the back of this so delete it

	delete(currentnode->back);
}
    
"Don't make me come down there..." -GOD
your leak may not be from the delete, but from the construction of the tree. just a thought
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement