Beispiel #1
0
//private function to recursively free the subtree rooted at node
static void treeNode_free(treeNode* node) {
  //  printf("about to try to free a node! \n");
  if(!node) return;
  if(node->left) treeNode_free(node->left);
  if(node->right) treeNode_free(node->right);
  free(node);
}
Beispiel #2
0
/* free all memory allocated for the tree, including the tree
   itself */
void kdtree_free(kdtree *tree) {

    if (!tree) return;
    treeNode_free(tree->root);
    free(tree);
}