projects
/
runtime.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
SilcTree: Replace SilcTreeCompare with SilcCompare
[runtime.git]
/
lib
/
silcutil
/
silcavltree.c
diff --git
a/lib/silcutil/silcavltree.c
b/lib/silcutil/silcavltree.c
index cef09195d6dd6aa4414f764695ec5a4afb0cd481..44d313e9bd9243a14acb51d1386d0b1cb988d8ca 100644
(file)
--- 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,
/* Find entry */
void *silc_avl_tree_find(SilcTree *tree, void *entry,
- Silc
Tree
Compare compare, void *context)
+ SilcCompare compare, void *context)
{
SilcTreeHeader *h;
{
SilcTreeHeader *h;
- Silc
Tree
Compare cmp = compare ? compare : tree->compare;
+ SilcCompare cmp = compare ? compare : tree->compare;
void *cmp_context = compare ? context : tree->context;
int ret;
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);
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);
}
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;
}
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);
}
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 */
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;
q = SILC_TREE_GET_HEADER(tree, entry);
q->duplicate = TRUE;
q->parent = h;