From 116911945e7f834278abf586c1d4d3a62174858a Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sat, 5 Jul 2014 00:23:04 +0100 Subject: [PATCH] fix position of TR_TREE_FIND call --- src/tree/insert.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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