Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Barchiesi
OpenLDAP
Commits
2d97c1ca
Commit
2d97c1ca
authored
18 years ago
by
Howard Chu
Browse files
Options
Downloads
Patches
Plain Diff
ITS#4549 add tavl_find3() to return closest match
parent
f0adb769
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/avl.h
+3
-0
3 additions, 0 deletions
include/avl.h
libraries/liblutil/tavl.c
+20
-0
20 additions, 0 deletions
libraries/liblutil/tavl.c
with
23 additions
and
0 deletions
include/avl.h
+
3
−
0
View file @
2d97c1ca
...
...
@@ -134,6 +134,9 @@ tavl_find LDAP_P((Avlnode *, const void*, AVL_CMP));
LDAP_AVL_F
(
Avlnode
*
)
tavl_find2
LDAP_P
((
Avlnode
*
,
const
void
*
,
AVL_CMP
));
LDAP_AVL_F
(
Avlnode
*
)
tavl_find3
LDAP_P
((
Avlnode
*
,
const
void
*
,
AVL_CMP
,
int
*
ret
));
#define TAVL_DIR_LEFT 0
#define TAVL_DIR_RIGHT 1
...
...
This diff is collapsed.
Click to expand it.
libraries/liblutil/tavl.c
+
20
−
0
View file @
2d97c1ca
...
...
@@ -443,6 +443,26 @@ tavl_free( Avlnode *root, AVL_FREE dfree )
* < 0 if arg1 is less than arg2 and > 0 if arg1 is greater than arg2.
*/
/*
* tavl_find2 - returns Avlnode instead of data pointer.
* tavl_find3 - as above, but returns Avlnode even if no match is found.
* also return the last comparison result in ret.
*/
Avlnode
*
tavl_find3
(
Avlnode
*
root
,
const
void
*
data
,
AVL_CMP
fcmp
,
int
*
ret
)
{
int
cmp
,
dir
;
Avlnode
*
prev
;
while
(
root
!=
0
&&
(
cmp
=
(
*
fcmp
)(
data
,
root
->
avl_data
))
!=
0
)
{
prev
=
root
;
dir
=
cmp
>
0
;
root
=
avl_child
(
root
,
dir
);
}
*
ret
=
cmp
;
return
root
?
root
:
prev
;
}
Avlnode
*
tavl_find2
(
Avlnode
*
root
,
const
void
*
data
,
AVL_CMP
fcmp
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment