diff --git a/src/tree/insert.c b/src/tree/insert.c index 18e0787..6f8ffb5 100644 --- a/src/tree/insert.c +++ b/src/tree/insert.c @@ -30,8 +30,6 @@ TR_treeInsert(TR_Tree * this, const void * search, TR_TreeComp comp) TR_Tree new_node = NULL; int found; - TR_TREE_FIND(node, search, found, comp); - /* * insert the node or return the one in tree if comparison * succeeds. @@ -43,6 +41,8 @@ TR_treeInsert(TR_Tree * this, const void * search, TR_TreeComp comp) */ *this = node = new_node = TR_new(TR_Tree, search); } else { + TR_TREE_FIND(node, search, found, comp); + if (found == 0) { // we found an element // as this is insert and not find this will overwrite an existing