further debugging

This commit is contained in:
Jonas Hofmann 2025-12-09 08:46:56 +01:00
parent f7549910eb
commit 7c3df62d86
4 changed files with 13 additions and 3 deletions

View File

@ -113,6 +113,15 @@ void clearTreeRec(TreeNode *currentNode)
clearTree(currentNode->right);
clearNode(currentNode);
/*
printf("1\n");
free(&currentNode->data);
currentNode->data = NULL;
printf("2\n");
// free(currentNode);
// currentNode = NULL;
printf("3\n");
// */
}
}
@ -120,11 +129,11 @@ void clearTreeRec(TreeNode *currentNode)
void clearNode(TreeNode *node)
{
// printf("in clearNode\n");
printf("node-> data = %u\n", &node->data);
// printf("node-> data = %u\n", node->data);
// printf("node-> data = %u\n", _ADDRESSOF(node->data));
free(&node->data);
node->data = NULL;
printf("node-> data = %u\n", &node->data);
// printf("node-> data = %u\n", &node->data);
// printf("data freed \n");
node->left = NULL;
node->right = NULL;
@ -134,6 +143,7 @@ void clearNode(TreeNode *node)
// free(node);
// printf("node = %d\n", node);
node = NULL;
printf("node = %u\n", &node);
printf("freed node\n");
}

BIN
bintree.o

Binary file not shown.

View File

@ -131,7 +131,7 @@ void test_clearTreeworksLikeExpected(void)
// Check if everything has been set to NULL
TEST_ASSERT_NULL(testRoot->data);
// TEST_ASSERT_NULL(testRoot);
TEST_ASSERT_NULL(testRoot);
TEST_ASSERT_NULL(node1->data);
// TEST_ASSERT_NULL(node1);

Binary file not shown.