From: Howard Chu Date: Fri, 19 Nov 2004 23:33:46 +0000 (+0000) Subject: Add avl_find2 returning the Avlnode, allowing its data to be reset directly X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~267 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9fd1c817139d96fb52163a18b81282e60fd447dd;p=openldap Add avl_find2 returning the Avlnode, allowing its data to be reset directly instead of recycling thru avl_find/avl_delete/avl_insert --- diff --git a/include/avl.h b/include/avl.h index 16cea00f5b..60d535c3f4 100644 --- a/include/avl.h +++ b/include/avl.h @@ -38,7 +38,6 @@ LDAP_BEGIN_DECL typedef struct avlnode Avlnode; -#ifdef AVL_INTERNAL struct avlnode { void* avl_data; signed int avl_bf; @@ -46,6 +45,8 @@ struct avlnode { struct avlnode *avl_right; }; +#ifdef AVL_INTERNAL + #define NULLAVL ((Avlnode *) NULL) /* balance factor values */ @@ -76,6 +77,9 @@ avl_delete LDAP_P((Avlnode **, void*, AVL_CMP)); LDAP_AVL_F( void* ) avl_find LDAP_P((Avlnode *, const void*, AVL_CMP)); +LDAP_AVL_F( Avlnode* ) +avl_find2 LDAP_P((Avlnode *, const void*, AVL_CMP)); + LDAP_AVL_F( void* ) avl_find_lin LDAP_P((Avlnode *, const void*, AVL_CMP)); diff --git a/libraries/liblutil/avl.c b/libraries/liblutil/avl.c index 29dafee02a..37f1da5bd1 100644 --- a/libraries/liblutil/avl.c +++ b/libraries/liblutil/avl.c @@ -644,8 +644,8 @@ avl_free( Avlnode *root, AVL_FREE dfree ) * < 0 if arg1 is less than arg2 and > 0 if arg1 is greater than arg2. */ -void* -avl_find( Avlnode *root, const void* data, AVL_CMP fcmp ) +Avlnode * +avl_find2( Avlnode *root, const void *data, AVL_CMP fcmp ) { int cmp; @@ -655,6 +655,13 @@ avl_find( Avlnode *root, const void* data, AVL_CMP fcmp ) else root = root->avl_right; } + return root; +} + +void* +avl_find( Avlnode *root, const void* data, AVL_CMP fcmp ) +{ + root = avl_find2( root, data, fcmp ); return( root ? root->avl_data : 0 ); }