generated from freudenreichan/info2Praktikum-DobleSpiel
clearTree implementation
This commit is contained in:
1 parent
942c816dfc
commit
b2b6f6a896
1 file changed
+13
-1
+13
-1
@@ -26,7 +26,19 @@ void *nextTreeData(TreeNode *root)
|
|||||||
// Releases all memory resources (including data copies).
|
// Releases all memory resources (including data copies).
|
||||||
void clearTree(TreeNode *root)
|
void clearTree(TreeNode *root)
|
||||||
{
|
{
|
||||||
|
if(root->left != NULL){
|
||||||
|
clearTree(root->left);
|
||||||
|
free(root->left->data);
|
||||||
|
free(root->left);
|
||||||
|
root->left = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(root->right != NULL){
|
||||||
|
clearTree(root->right);
|
||||||
|
free(root->right->data);
|
||||||
|
free(root->right);
|
||||||
|
root->right;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the number of entries in the tree given by root.
|
// Returns the number of entries in the tree given by root.
|
||||||
|
|||||||
Reference in new issue
Block a user