X-Git-Url: http://git.silc.fi/gitweb/?p=runtime.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcavltree.c;h=44d313e9bd9243a14acb51d1386d0b1cb988d8ca;hp=cef09195d6dd6aa4414f764695ec5a4afb0cd481;hb=55dac5fbf2f83e8ca4278fa6fcdbbccbeb1d12cd;hpb=9df31f979d5ebd26edd45dceed544c4eb166ccd4 diff --git a/lib/silcutil/silcavltree.c b/lib/silcutil/silcavltree.c index cef09195..44d313e9 100644 --- a/lib/silcutil/silcavltree.c +++ b/lib/silcutil/silcavltree.c @@ -142,10 +142,10 @@ static int silc_avl_tree_rot_right(SilcTree *tree, SilcTreeHeader *h) /* Find entry */ void *silc_avl_tree_find(SilcTree *tree, void *entry, - SilcTreeCompare compare, void *context) + SilcCompare compare, void *context) { SilcTreeHeader *h; - SilcTreeCompare cmp = compare ? compare : tree->compare; + SilcCompare cmp = compare ? compare : tree->compare; void *cmp_context = compare ? context : tree->context; int ret; @@ -154,10 +154,12 @@ void *silc_avl_tree_find(SilcTree *tree, void *entry, h = tree->root; while (h) { ret = cmp(entry, SILC_TREE_GET_ENTRY(tree, h), cmp_context); - if (!ret) { + if (ret == SILC_COMPARE_EQUAL_TO) { SILC_LOG_DEBUG(("Found %p", SILC_TREE_GET_ENTRY(tree, h))); return SILC_TREE_GET_ENTRY(tree, h); } + if (ret == SILC_COMPARE_STOP) + return NULL; h = ret > 0 ? h->right : h->left; } @@ -199,13 +201,13 @@ SilcBool silc_avl_tree_add(SilcTree *tree, void *entry) } ret = tree->compare(entry, SILC_TREE_GET_ENTRY(tree, h), tree->context); - if (!tree->duplicates && ret == 0) { + if (!tree->duplicates && ret == SILC_COMPARE_EQUAL_TO) { silc_set_errno(SILC_ERR_ALREADY_EXISTS); return FALSE; } /* Duplicate entry, add to list */ - if (ret == 0) { + if (ret == SILC_COMPARE_EQUAL_TO) { q = SILC_TREE_GET_HEADER(tree, entry); q->duplicate = TRUE; q->parent = h;