Polish bintree.c and implement tests

This commit is contained in:
Tobias Linz committed 2026-11-18 19:37:36 +01:00
1 parent 21cfd2e3ca
commit a062691967
3 files changed
+135 -11

No files matched your search

+4 -1
View File
@@ -6,7 +6,7 @@
// if isDuplicate is NULL, otherwise ignores duplicates and sets isDuplicate to 1 (or to 0 if a new entry is added).
TreeNode *addToTree(TreeNode *root, const void *const data, const size_t dataSize, const CompareFctType compareFct, int *isDuplicate)
{
if(data == NULL || dataSize == 0 || compareFct == NULL)
if(data == NULL || dataSize == 0)
return root;
if(root == NULL)
@@ -35,6 +35,9 @@ TreeNode *addToTree(TreeNode *root, const void *const data, const size_t dataSiz
return root;
}
if(compareFct == NULL)
return root;
const int comparisonValue = compareFct(data, root->data);
if(comparisonValue > 0)