This commit is contained in:
Maximilian Ott 2025-12-10 17:53:26 +01:00
parent 7135abe9a6
commit 39e0758dbd

View File

@ -72,8 +72,6 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc
*isDuplicate = 1;
}
return root;
}
// Iterates over the tree given by root. Follows the usage of strtok. If tree is NULL, the next entry of the last tree given is returned in ordering direction.
@ -81,9 +79,22 @@ TreeNode *addToTree(TreeNode *root, const void *data, size_t dataSize, CompareFc
// push the top node and push all its left nodes.
void *nextTreeData(TreeNode *root)
{
static StackNode *stack = NULL;
if (root != NULL)
stack = push_left(root, stack);
if (stack == NULL)
return NULL;
TreeNode *node;
node = pop(&stack);
if (node->right != NULL)
stack = push_left(node->right, stack);
return node->data;
}
// Releases all memory resources (including data copies).
void clearTree(TreeNode *root)
{