When a member is not found from the tree, return the new member
instead of the parent node. Also fix the comment regarding the
function.
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
* bintree_add - Add to tree
*
* Adds a node to a sorted tree. If the new node is already found from
- * the tree, the existing node is added and the new node is not
+ * the tree, the existing node is returned and the new node is not
* added. If new node is not found, the new one is added and the tree
* is kept sorted.
*/
else
tree->left = new;
- return tree;
+ return new;
}
if (ret > 0) {
else
tree->right = new;
- return tree;
+ return new;
}
return tree;