removed no longer needed comments

This commit is contained in:
Jonas Hofmann 2025-12-09 18:04:58 +01:00
parent 2d6f8689f2
commit 21aa67b165
3 changed files with 3 additions and 50 deletions

View File

@ -52,7 +52,6 @@ TreeNode *addToTreeRec(TreeNode *currentNode, TreeNode *newNode, CompareFctType
{
if ((currentNode == NULL))
{
// printf("Node == NULL\n");
if ((isDuplicate == NULL) || root)
{
return newNode;
@ -64,17 +63,14 @@ TreeNode *addToTreeRec(TreeNode *currentNode, TreeNode *newNode, CompareFctType
}
else if ((compareFct(currentNode->data, newNode->data) < 0))
{
// printf("<0\n");
currentNode->left = addToTreeRec(currentNode->left, newNode, compareFct, isDuplicate, 0);
}
else if ((compareFct(currentNode->data, newNode->data) > 0))
{
// printf(">0\n");
currentNode->right = addToTreeRec(currentNode->right, newNode, compareFct, isDuplicate, 0);
}
else if ((compareFct(currentNode->data, newNode->data) == 0))
{
// printf("==0\n");
if (isDuplicate == NULL)
{
currentNode->left = addToTreeRec(currentNode->left, newNode, compareFct, isDuplicate, 0);
@ -113,45 +109,22 @@ void clearTreeRec(TreeNode *currentNode)
if (currentNode != NULL)
{
clearTree(currentNode->left);
clearTree(currentNode->right);
clearNode(currentNode);
/*
printf("1\n");
free(&currentNode->data);
currentNode->data = NULL;
printf("2\n");
// free(currentNode);
// currentNode = NULL;
printf("3\n");
// */
}
}
void clearNode(TreeNode *node)
{
// printf("in clearNode\n");
// printf("node-> data = %u\n", node->data);
// printf("node-> data = %u\n", _ADDRESSOF(node->data));
// printf("data = %p\n", node->data);
free(node->data);
node->data = NULL;
// printf("data = %p\n", node->data);
// printf("node-> data = %u\n", &node->data);
// printf("data freed \n");
node->left = NULL;
node->right = NULL;
// printf("left & right = Null\n");
// printf("node = %p\n", node);
// printf("node = %u\n", _ADDRESSOF(node));
free(node);
// printf("node = %d\n", node);
node = NULL;
// printf("node = %p\n", node);
// printf("node = %u\n", &node);
// printf("freed node\n");
}

View File

@ -11,6 +11,7 @@ void setUp(void) {
// Falls notwendig, kann hier Vorbereitungsarbeit gemacht werden
}
void tearDown(void) {
// Hier kann Bereinigungsarbeit nach jedem Test durchgeführt werden
}
@ -92,7 +93,6 @@ void test_nextTreeDataReturnsNextDataCorrectly(void)
}
// test if clear Tree frees all node.name and node memory AND sets them to zero
// aditionally tests if the memoryspaces have been cleared
void test_clearTreeworksLikeExpected(void)
@ -114,7 +114,6 @@ void test_clearTreeworksLikeExpected(void)
testRoot = addToTree(testRoot, &score5, sizeof(int), compareIntEntries, NULL);
testRoot = addToTree(testRoot, &score6, sizeof(int), compareIntEntries, NULL);
testRoot = addToTree(testRoot, &score7, sizeof(int), compareIntEntries, NULL);
// printf("Tree Filled\n");
// Save all Adresses
TreeNode *node1 = testRoot;
@ -124,37 +123,18 @@ void test_clearTreeworksLikeExpected(void)
TreeNode *node5 = testRoot->right;
TreeNode *node6 = testRoot->right->left;
TreeNode *node7 = testRoot->right->right;
// printf("Adresses Saved\n");
clearTree(testRoot);
// printf("Tree Cleared\n");
// Check if everything has been set to NULL
TEST_ASSERT_NULL(node1->data);
//TEST_ASSERT_NULL(testRoot);
TEST_ASSERT_NULL(node1->data);
// TEST_ASSERT_NULL(node1);
TEST_ASSERT_NULL(node2->data);
// TEST_ASSERT_NULL(node2);
TEST_ASSERT_NULL(node3->data);
// TEST_ASSERT_NULL(node3);
TEST_ASSERT_NULL(node4->data);
// TEST_ASSERT_NULL(node4);
TEST_ASSERT_NULL(node5->data);
// TEST_ASSERT_NULL(node5);
TEST_ASSERT_NULL(node6->data);
// TEST_ASSERT_NULL(node6);
TEST_ASSERT_NULL(node7->data);
// TEST_ASSERT_NULL(node7);
// */
}

Binary file not shown.