>edit:: you should also check if localRoot->(left or right)child is a null, before deleting it.
He does, that is the base case for the recursion.
>this is a pretty standard implementation of a recursive freeing of a BST
Umm...not really.
>freeBST( Node* t ) //get root
You forgot the return value, and the comment is just obscure.
>if( t->leftChild != NULL )
>freeBST( t->leftChild );
There's no need for this test if you return when t is a null pointer.
>if( t->rightChild != NULL )
>freeBST( t->rightChild );
Ditto
>delete t; /* free(t) if c */
Free t if c? What is that supposed to mean?
Recursive post order traversal usually takes one of these two forms:
Code:
void delete_all ( struct node *tree )
{
if ( tree == NULL )
return;
delete_all ( tree->left );
delete_all ( tree->right );
delete tree;
}
Code:
void delete_all ( struct node *tree )
{
if ( tree != NULL ) {
delete_all ( tree->left );
delete_all ( tree->right );
delete tree;
}
}
The OP's code conforms to the second, so the function is correct and we can conclude that the problem is elsewhere.