memcpy(treeNode->data, data, tree->dataSize);
}
-void _tree_add_child(Tree* tree, TreeNode* treeNode, void* data)
+TreeNode* _tree_add_child(Tree* tree, TreeNode* treeNode, void* data)
{
TreeNode* newChildNode = (TreeNode*) safe_malloc(sizeof (TreeNode));
newChildNode->data = safe_malloc(tree->dataSize);
newChildNode->firstChild = NULL;
newChildNode->lastChild = NULL;
tree->size++;
+ return newChildNode;
}
-void _tree_add_sibling(Tree* tree, TreeNode* treeNode, void* data)
+TreeNode* _tree_add_sibling(Tree* tree, TreeNode* treeNode, void* data)
{
TreeNode* newSiblingNode = (TreeNode*) safe_malloc(sizeof (TreeNode));
newSiblingNode->data = safe_malloc(tree->dataSize);
newSiblingNode->firstChild = NULL;
newSiblingNode->lastChild = NULL;
tree->size++;
+ return newSiblingNode;
}
void _tree_remove_rekursiv(Tree* tree, TreeNode* treeNode)
}
/**
- * @brief Add a child to current node children.
+ * @brief Append a child to current node.
*/
-void _tree_add_child(
+TreeNode* _tree_add_child(
Tree* tree, ///< "this" pointer.
TreeNode* treeNode, ///< Pointer to a node in the "this" tree.
void* data ///< Pointer to data to be added.
* @param tree "this" pointer.
* @param treeNode Pointer to a node in the "this" tree.
* @param data Data to be added.
+ * @return The newly added tree node.
*
- * Usage: void tree_add_child(Tree* tree, TreeNode* treeNode, void data)
+ * Usage: TreeNode* tree_add_child(Tree* tree, TreeNode* treeNode, void data)
*/
#define tree_add_child(tree,treeNode,data) \
{ \
/**
* @brief Add a sibling to current node (after it on the right).
*/
-void _tree_add_sibling(
+TreeNode* _tree_add_sibling(
Tree* tree, ///< "this" pointer.
TreeNode* treeNode, ///< Pointer to a node in the "this" tree.
void* data ///< Pointer to data to be added.
* @param tree "this" pointer.
* @param treeNode Pointer to a node in the "this" tree.
* @param data Data to be added.
+ * @return The newly added tree node.
*
- * Usage: void tree_add_sibling(Tree* tree, TreeNode* treeNode, void data)
+ * Usage: TreeNode* tree_add_sibling(Tree* tree, TreeNode* treeNode, void data)
*/
#define tree_add_sibling(tree, treeNode, data) \
{ \