Remove casts of AVL function pointers.

This commit is contained in:
Hallvard Furuseth 2002-12-14 22:25:52 +00:00
parent ff2a3201cb
commit 2bcb48361d
22 changed files with 211 additions and 186 deletions

View file

@ -18,6 +18,7 @@
static void ravl_print LDAP_P(( Avlnode *root, int depth )); static void ravl_print LDAP_P(( Avlnode *root, int depth ));
static void myprint LDAP_P(( Avlnode *root )); static void myprint LDAP_P(( Avlnode *root ));
static int avl_strcmp LDAP_P(( const void *s, const void *t ));
int int
main( int argc, char **argv ) main( int argc, char **argv )
@ -54,7 +55,7 @@ main( int argc, char **argv )
if ( fgets( name, sizeof( name ), stdin ) == NULL ) if ( fgets( name, sizeof( name ), stdin ) == NULL )
exit( EXIT_SUCCESS ); exit( EXIT_SUCCESS );
name[ strlen( name ) - 1 ] = '\0'; name[ strlen( name ) - 1 ] = '\0';
if ( (p = (char *) avl_find( tree, name, (AVL_CMP) strcmp )) if ( (p = (char *) avl_find( tree, name, avl_strcmp ))
== NULL ) == NULL )
printf( "Not found.\n\n" ); printf( "Not found.\n\n" );
else else
@ -65,7 +66,7 @@ main( int argc, char **argv )
if ( fgets( name, sizeof( name ), stdin ) == NULL ) if ( fgets( name, sizeof( name ), stdin ) == NULL )
exit( EXIT_SUCCESS ); exit( EXIT_SUCCESS );
name[ strlen( name ) - 1 ] = '\0'; name[ strlen( name ) - 1 ] = '\0';
if ( avl_insert( &tree, strdup( name ), (AVL_CMP) strcmp, if ( avl_insert( &tree, strdup( name ), avl_strcmp,
avl_dup_error ) != 0 ) avl_dup_error ) != 0 )
printf( "\nNot inserted!\n" ); printf( "\nNot inserted!\n" );
break; break;
@ -74,7 +75,7 @@ main( int argc, char **argv )
if ( fgets( name, sizeof( name ), stdin ) == NULL ) if ( fgets( name, sizeof( name ), stdin ) == NULL )
exit( EXIT_SUCCESS ); exit( EXIT_SUCCESS );
name[ strlen( name ) - 1 ] = '\0'; name[ strlen( name ) - 1 ] = '\0';
if ( avl_delete( &tree, name, (AVL_CMP) strcmp ) == NULL ) if ( avl_delete( &tree, name, avl_strcmp ) == NULL )
printf( "\nNot found!\n" ); printf( "\nNot found!\n" );
break; break;
case 'q': /* quit */ case 'q': /* quit */
@ -119,3 +120,8 @@ static void myprint( Avlnode *root )
printf( "********\n" ); printf( "********\n" );
} }
static int avl_strcmp( const void *s, const void *t )
{
return strcmp( s, t );
}

View file

@ -173,9 +173,10 @@ rewrite_var_set(
*/ */
static void static void
rewrite_var_free( rewrite_var_free(
struct rewrite_var *var void *v_var
) )
{ {
struct rewrite_var *var = v_var;
assert( var != NULL ); assert( var != NULL );
assert( var->lv_name != NULL ); assert( var->lv_name != NULL );
@ -193,7 +194,7 @@ rewrite_var_delete(
Avlnode *tree Avlnode *tree
) )
{ {
avl_free( tree, ( AVL_FREE )rewrite_var_free ); avl_free( tree, rewrite_var_free );
return REWRITE_SUCCESS; return REWRITE_SUCCESS;
} }

View file

@ -53,10 +53,12 @@ static AttributeType *attr_list = NULL;
static int static int
attr_index_cmp( attr_index_cmp(
struct aindexrec *air1, const void *v_air1,
struct aindexrec *air2 const void *v_air2
) )
{ {
const struct aindexrec *air1 = v_air1;
const struct aindexrec *air2 = v_air2;
int i = air1->air_name.bv_len - air2->air_name.bv_len; int i = air1->air_name.bv_len - air2->air_name.bv_len;
if (i) if (i)
return i; return i;
@ -65,10 +67,12 @@ attr_index_cmp(
static int static int
attr_index_name_cmp( attr_index_name_cmp(
struct berval *type, const void *v_type,
struct aindexrec *air const void *v_air
) )
{ {
const struct berval *type = v_type;
const struct aindexrec *air = v_air;
int i = type->bv_len - air->air_name.bv_len; int i = type->bv_len - air->air_name.bv_len;
if (i) if (i)
return i; return i;
@ -96,8 +100,7 @@ at_bvfind(
{ {
struct aindexrec *air; struct aindexrec *air;
air = (struct aindexrec *) avl_find( attr_index, name, air = avl_find( attr_index, name, attr_index_name_cmp );
(AVL_CMP) attr_index_name_cmp );
return air != NULL ? air->air_at : NULL; return air != NULL ? air->air_at : NULL;
} }
@ -267,8 +270,7 @@ at_insert(
air->air_name.bv_len = strlen(sat->sat_oid); air->air_name.bv_len = strlen(sat->sat_oid);
air->air_at = sat; air->air_at = sat;
if ( avl_insert( &attr_index, (caddr_t) air, if ( avl_insert( &attr_index, (caddr_t) air,
(AVL_CMP) attr_index_cmp, attr_index_cmp, avl_dup_error ) ) {
(AVL_DUP) avl_dup_error ) ) {
*err = sat->sat_oid; *err = sat->sat_oid;
ldap_memfree(air); ldap_memfree(air);
return SLAP_SCHERR_ATTR_DUP; return SLAP_SCHERR_ATTR_DUP;
@ -285,8 +287,7 @@ at_insert(
air->air_name.bv_len = strlen(*names); air->air_name.bv_len = strlen(*names);
air->air_at = sat; air->air_at = sat;
if ( avl_insert( &attr_index, (caddr_t) air, if ( avl_insert( &attr_index, (caddr_t) air,
(AVL_CMP) attr_index_cmp, attr_index_cmp, avl_dup_error ) ) {
(AVL_DUP) avl_dup_error ) ) {
*err = *names; *err = *names;
ldap_memfree(air); ldap_memfree(air);
return SLAP_SCHERR_ATTR_DUP; return SLAP_SCHERR_ATTR_DUP;
@ -567,9 +568,9 @@ at_add(
#ifdef LDAP_DEBUG #ifdef LDAP_DEBUG
static int static int
at_index_printnode( struct aindexrec *air ) at_index_printnode( void *v_air, void *ignore )
{ {
struct aindexrec *air = v_air;
printf("%s = %s\n", printf("%s = %s\n",
air->air_name.bv_val, air->air_name.bv_val,
ldap_attributetype2str(&air->air_at->sat_atype) ); ldap_attributetype2str(&air->air_at->sat_atype) );
@ -580,8 +581,7 @@ static void
at_index_print( void ) at_index_print( void )
{ {
printf("Printing attribute type index:\n"); printf("Printing attribute type index:\n");
(void) avl_apply( attr_index, (AVL_APPLY) at_index_printnode, (void) avl_apply( attr_index, at_index_printnode, 0, -1, AVL_INORDER );
0, -1, AVL_INORDER );
} }
#endif #endif

View file

@ -23,19 +23,22 @@ typedef struct bdb_attrinfo {
static int static int
ainfo_type_cmp( ainfo_type_cmp(
AttributeDescription *desc, const void *v_desc,
AttrInfo *a const void *v_a
) )
{ {
const AttributeDescription *desc = v_desc;
const AttrInfo *a = v_a;
return desc - a->ai_desc; return desc - a->ai_desc;
} }
static int static int
ainfo_cmp( ainfo_cmp(
AttrInfo *a, const void *v_a,
AttrInfo *b const void *v_b
) )
{ {
const AttrInfo *a = v_a, *b = v_b;
return a->ai_desc - b->ai_desc; return a->ai_desc - b->ai_desc;
} }
@ -47,8 +50,7 @@ bdb_attr_mask(
{ {
AttrInfo *a; AttrInfo *a;
a = (AttrInfo *) avl_find( bdb->bi_attrs, desc, a = (AttrInfo *) avl_find( bdb->bi_attrs, desc, ainfo_type_cmp );
(AVL_CMP) ainfo_type_cmp );
*indexmask = a != NULL ? a->ai_indexmask : 0; *indexmask = a != NULL ? a->ai_indexmask : 0;
} }
@ -194,7 +196,7 @@ bdb_attr_index_config(
a->ai_indexmask = mask; a->ai_indexmask = mask;
rc = avl_insert( &bdb->bi_attrs, (caddr_t) a, rc = avl_insert( &bdb->bi_attrs, (caddr_t) a,
(AVL_CMP) ainfo_cmp, (AVL_DUP) avl_dup_error ); ainfo_cmp, avl_dup_error );
if( rc ) { if( rc ) {
fprintf( stderr, "%s: line %d: duplicate index definition " fprintf( stderr, "%s: line %d: duplicate index definition "

View file

@ -491,7 +491,7 @@ bdb_cache_add_entry_rw(
} }
if ( avl_insert( &cache->c_dntree, (caddr_t) e, if ( avl_insert( &cache->c_dntree, (caddr_t) e,
(AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 ) entry_dn_cmp, avl_dup_error ) != 0 )
{ {
/* free cache write lock */ /* free cache write lock */
ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock ); ldap_pvt_thread_rdwr_wunlock( &cache->c_rwlock );
@ -513,7 +513,7 @@ bdb_cache_add_entry_rw(
/* id tree */ /* id tree */
if ( avl_insert( &cache->c_idtree, (caddr_t) e, if ( avl_insert( &cache->c_idtree, (caddr_t) e,
(AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 ) entry_id_cmp, avl_dup_error ) != 0 )
{ {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1, LDAP_LOG( CACHE, DETAIL1,
@ -527,7 +527,7 @@ bdb_cache_add_entry_rw(
/* delete from dn tree inserted above */ /* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e, if ( avl_delete( &cache->c_dntree, (caddr_t) e,
(AVL_CMP) entry_dn_cmp ) == NULL ) entry_dn_cmp ) == NULL )
{ {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO, LDAP_LOG( CACHE, INFO,
@ -554,7 +554,7 @@ bdb_cache_add_entry_rw(
case DB_LOCK_NOTGRANTED : case DB_LOCK_NOTGRANTED :
/* undo avl changes immediately */ /* undo avl changes immediately */
if ( avl_delete( &cache->c_idtree, (caddr_t) e, if ( avl_delete( &cache->c_idtree, (caddr_t) e,
(AVL_CMP) entry_id_cmp ) == NULL ) { entry_id_cmp ) == NULL ) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO, LDAP_LOG( CACHE, INFO,
"bdb_cache_add_entry: can't delete (%s) from cache.\n", "bdb_cache_add_entry: can't delete (%s) from cache.\n",
@ -564,7 +564,7 @@ bdb_cache_add_entry_rw(
#endif #endif
} }
if ( avl_delete( &cache->c_dntree, (caddr_t) e, if ( avl_delete( &cache->c_dntree, (caddr_t) e,
(AVL_CMP) entry_dn_cmp ) == NULL ) { entry_dn_cmp ) == NULL ) {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO, LDAP_LOG( CACHE, INFO,
"bdb_cache_add_entry: can't delete (%s) from cache.\n", "bdb_cache_add_entry: can't delete (%s) from cache.\n",
@ -653,7 +653,7 @@ bdb_cache_update_entry(
assert( e->e_private ); assert( e->e_private );
if ( avl_insert( &cache->c_dntree, (caddr_t) e, if ( avl_insert( &cache->c_dntree, (caddr_t) e,
(AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 ) entry_dn_cmp, avl_dup_error ) != 0 )
{ {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1, LDAP_LOG( CACHE, DETAIL1,
@ -672,7 +672,7 @@ bdb_cache_update_entry(
/* id tree */ /* id tree */
if ( avl_insert( &cache->c_idtree, (caddr_t) e, if ( avl_insert( &cache->c_idtree, (caddr_t) e,
(AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 ) entry_id_cmp, avl_dup_error ) != 0 )
{ {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1, LDAP_LOG( CACHE, DETAIL1,
@ -686,7 +686,7 @@ bdb_cache_update_entry(
/* delete from dn tree inserted above */ /* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e, if ( avl_delete( &cache->c_dntree, (caddr_t) e,
(AVL_CMP) entry_dn_cmp ) == NULL ) entry_dn_cmp ) == NULL )
{ {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO, LDAP_LOG( CACHE, INFO,
@ -774,7 +774,7 @@ try_again:
ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock ); ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock );
if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e, if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
(AVL_CMP) entry_dn_cmp )) != NULL ) entry_dn_cmp )) != NULL )
{ {
int state; int state;
count++; count++;
@ -874,7 +874,7 @@ try_again:
ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock ); ldap_pvt_thread_rdwr_rlock( &cache->c_rwlock );
if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e, if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
(AVL_CMP) entry_id_cmp )) != NULL ) entry_id_cmp )) != NULL )
{ {
int state; int state;
ID ep_id; ID ep_id;
@ -1029,15 +1029,13 @@ bdb_cache_delete_entry_internal(
int rc = 0; /* return code */ int rc = 0; /* return code */
/* dn tree */ /* dn tree */
if ( avl_delete( &cache->c_dntree, (caddr_t) e, (AVL_CMP) entry_dn_cmp ) if ( avl_delete( &cache->c_dntree, (caddr_t) e, entry_dn_cmp ) == NULL )
== NULL )
{ {
rc = -1; rc = -1;
} }
/* id tree */ /* id tree */
if ( avl_delete( &cache->c_idtree, (caddr_t) e, (AVL_CMP) entry_id_cmp ) if ( avl_delete( &cache->c_idtree, (caddr_t) e, entry_id_cmp ) == NULL )
== NULL )
{ {
rc = -1; rc = -1;
} }

View file

@ -622,28 +622,32 @@ node_find_cmp(
static int static int
node_frdn_cmp( node_frdn_cmp(
struct berval *nrdn, const void *v_nrdn,
idNode *n const void *v_n
) )
{ {
const struct berval *nrdn = v_nrdn;
const idNode *n = v_n;
return ber_bvcmp(nrdn, &n->i_rdn->nrdn); return ber_bvcmp(nrdn, &n->i_rdn->nrdn);
} }
static int static int
node_add_cmp( node_add_cmp(
idNode *a, const void *v_a,
idNode *b const void *v_b
) )
{ {
const idNode *a = v_a, *b = v_b;
return a->i_id - b->i_id; return a->i_id - b->i_id;
} }
static int static int
node_rdn_cmp( node_rdn_cmp(
idNode *a, const void *v_a,
idNode *b const void *v_b
) )
{ {
const idNode *a = v_a, *b = v_b;
/* should be slightly better without ordering drawbacks */ /* should be slightly better without ordering drawbacks */
return ber_bvcmp(&a->i_rdn->nrdn, &b->i_rdn->nrdn); return ber_bvcmp(&a->i_rdn->nrdn, &b->i_rdn->nrdn);
} }
@ -661,15 +665,17 @@ idNode * bdb_find_rdn_node(
Avlnode *tree Avlnode *tree
) )
{ {
return avl_find(tree, (const void *)nrdn, (AVL_CMP)node_frdn_cmp); return avl_find(tree, nrdn, node_frdn_cmp);
} }
/* This function links a node into its parent's i_kids tree. */ /* This function links a node into its parent's i_kids tree. */
int bdb_insert_kid( static int bdb_insert_kid(
idNode *a, void *v_a,
Avlnode *tree void *v_tree
) )
{ {
idNode *a = v_a;
Avlnode *tree = v_tree;
int rc; int rc;
if (a->i_rdn->parent == 0) if (a->i_rdn->parent == 0)
@ -679,7 +685,7 @@ int bdb_insert_kid(
return -1; return -1;
ldap_pvt_thread_rdwr_wlock(&a->i_parent->i_kids_rdwr); ldap_pvt_thread_rdwr_wlock(&a->i_parent->i_kids_rdwr);
rc = avl_insert( &a->i_parent->i_kids, (caddr_t) a, rc = avl_insert( &a->i_parent->i_kids, (caddr_t) a,
(AVL_CMP)node_rdn_cmp, (AVL_DUP) avl_dup_error ); node_rdn_cmp, avl_dup_error );
ldap_pvt_thread_rdwr_wunlock(&a->i_parent->i_kids_rdwr); ldap_pvt_thread_rdwr_wunlock(&a->i_parent->i_kids_rdwr);
return rc; return rc;
} }
@ -701,8 +707,7 @@ idNode *bdb_add_node(
node->i_rdn->rdn.bv_val += (long)d; node->i_rdn->rdn.bv_val += (long)d;
node->i_rdn->nrdn.bv_val += (long)d; node->i_rdn->nrdn.bv_val += (long)d;
ldap_pvt_thread_rdwr_init(&node->i_kids_rdwr); ldap_pvt_thread_rdwr_init(&node->i_kids_rdwr);
avl_insert( &bdb->bi_tree, (caddr_t) node, avl_insert( &bdb->bi_tree, (caddr_t) node, node_add_cmp, avl_dup_error );
(AVL_CMP)node_add_cmp, (AVL_DUP) avl_dup_error );
if (id == 1) if (id == 1)
bdb->bi_troot = node; bdb->bi_troot = node;
return node; return node;
@ -741,7 +746,7 @@ int bdb_build_tree(
} }
cursor->c_close( cursor ); cursor->c_close( cursor );
rc = avl_apply(bdb->bi_tree, (AVL_APPLY)bdb_insert_kid, bdb->bi_tree, rc = avl_apply(bdb->bi_tree, bdb_insert_kid, bdb->bi_tree,
-1, AVL_INORDER ); -1, AVL_INORDER );
return rc; return rc;
@ -880,8 +885,7 @@ bdb_dn2id_delete(
if (n) { if (n) {
if (n->i_parent) { if (n->i_parent) {
ldap_pvt_thread_rdwr_wlock(&n->i_parent->i_kids_rdwr); ldap_pvt_thread_rdwr_wlock(&n->i_parent->i_kids_rdwr);
avl_delete(&n->i_parent->i_kids, &n->i_rdn->nrdn, avl_delete(&n->i_parent->i_kids, &n->i_rdn->nrdn, node_frdn_cmp);
(AVL_CMP)node_frdn_cmp);
ldap_pvt_thread_rdwr_wunlock(&n->i_parent->i_kids_rdwr); ldap_pvt_thread_rdwr_wunlock(&n->i_parent->i_kids_rdwr);
} }
free(n->i_rdn); free(n->i_rdn);
@ -986,26 +990,29 @@ bdb_dn2id_children(
*/ */
static int static int
insert_one( insert_one(
idNode *n, void *v_n,
ID *ids void *v_ids
) )
{ {
idNode *n = v_n;
ID *ids = v_ids;
return bdb_idl_insert(ids, n->i_id); return bdb_idl_insert(ids, n->i_id);
} }
static int static int
insert_sub( insert_sub(
idNode *n, void *v_n,
ID *ids void *v_ids
) )
{ {
idNode *n = v_n;
ID *ids = v_ids;
int rc; int rc;
rc = bdb_idl_insert(ids, n->i_id); rc = bdb_idl_insert(ids, n->i_id);
if (rc == 0) { if (rc == 0) {
ldap_pvt_thread_rdwr_rlock(&n->i_kids_rdwr); ldap_pvt_thread_rdwr_rlock(&n->i_kids_rdwr);
rc = avl_apply(n->i_kids, (AVL_APPLY)insert_sub, ids, -1, rc = avl_apply(n->i_kids, insert_sub, ids, -1, AVL_INORDER);
AVL_INORDER);
ldap_pvt_thread_rdwr_runlock(&n->i_kids_rdwr); ldap_pvt_thread_rdwr_runlock(&n->i_kids_rdwr);
} }
return rc; return rc;
@ -1038,11 +1045,9 @@ bdb_dn2idl(
ids[0] = 0; ids[0] = 0;
ldap_pvt_thread_rdwr_rlock(&n->i_kids_rdwr); ldap_pvt_thread_rdwr_rlock(&n->i_kids_rdwr);
if (prefix == DN_ONE_PREFIX) { if (prefix == DN_ONE_PREFIX) {
rc = avl_apply(n->i_kids, (AVL_APPLY)insert_one, ids, -1, rc = avl_apply(n->i_kids, insert_one, ids, -1, AVL_INORDER);
AVL_INORDER);
} else { } else {
rc = avl_apply(n->i_kids, (AVL_APPLY)insert_sub, ids, -1, rc = avl_apply(n->i_kids, insert_sub, ids, -1, AVL_INORDER);
AVL_INORDER);
} }
ldap_pvt_thread_rdwr_runlock(&n->i_kids_rdwr); ldap_pvt_thread_rdwr_runlock(&n->i_kids_rdwr);
return rc; return rc;

View file

@ -45,8 +45,9 @@
} while ( 0 ) } while ( 0 )
static int static int
bdb_idl_entry_cmp( bdb_idl_cache_entry_t* idl1, bdb_idl_cache_entry_t* idl2 ) bdb_idl_entry_cmp( const void *v_idl1, const void *v_idl2 )
{ {
const bdb_idl_cache_entry_t *idl1 = v_idl1, *idl2 = v_idl2;
int rc; int rc;
if ((rc = idl1->db - idl2->db )) return rc; if ((rc = idl1->db - idl2->db )) return rc;
@ -333,7 +334,8 @@ bdb_idl_fetch_key(
DBT2bv( key, &idl_tmp.kstr ); DBT2bv( key, &idl_tmp.kstr );
idl_tmp.db = db; idl_tmp.db = db;
ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex ); ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex );
matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp, (AVL_CMP) bdb_idl_entry_cmp ); matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp,
bdb_idl_entry_cmp );
if ( matched_idl_entry != NULL ) { if ( matched_idl_entry != NULL ) {
BDB_IDL_CPY( ids, matched_idl_entry->idl ); BDB_IDL_CPY( ids, matched_idl_entry->idl );
IDL_LRU_DELETE( bdb, matched_idl_entry ); IDL_LRU_DELETE( bdb, matched_idl_entry );
@ -469,7 +471,8 @@ bdb_idl_fetch_key(
BDB_IDL_CPY( ee->idl, ids ); BDB_IDL_CPY( ee->idl, ids );
ber_dupbv( &ee->kstr, &idl_tmp.kstr ); ber_dupbv( &ee->kstr, &idl_tmp.kstr );
ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex ); ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex );
if ( avl_insert( &bdb->bi_idl_tree, (caddr_t) ee, (AVL_CMP) bdb_idl_entry_cmp, avl_dup_error )) { if ( avl_insert( &bdb->bi_idl_tree, (caddr_t) ee,
bdb_idl_entry_cmp, avl_dup_error )) {
free( ee->kstr.bv_val ); free( ee->kstr.bv_val );
free( ee->idl ); free( ee->idl );
free( ee ); free( ee );
@ -479,7 +482,8 @@ bdb_idl_fetch_key(
int i = 0; int i = 0;
while ( bdb->bi_idl_lru_tail != NULL && i < 10 ) { while ( bdb->bi_idl_lru_tail != NULL && i < 10 ) {
ee = bdb->bi_idl_lru_tail; ee = bdb->bi_idl_lru_tail;
avl_delete( &bdb->bi_idl_tree, (caddr_t) ee, (AVL_CMP) bdb_idl_entry_cmp ); avl_delete( &bdb->bi_idl_tree, (caddr_t) ee,
bdb_idl_entry_cmp );
IDL_LRU_DELETE( bdb, ee ); IDL_LRU_DELETE( bdb, ee );
i++; i++;
--bdb->bi_idl_cache_size; --bdb->bi_idl_cache_size;
@ -533,9 +537,11 @@ bdb_idl_insert_key(
DBT2bv( key, &idl_tmp.kstr ); DBT2bv( key, &idl_tmp.kstr );
idl_tmp.db = db; idl_tmp.db = db;
ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex ); ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex );
matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp, (AVL_CMP) bdb_idl_entry_cmp ); matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp,
bdb_idl_entry_cmp );
if ( matched_idl_entry != NULL ) { if ( matched_idl_entry != NULL ) {
avl_delete( &bdb->bi_idl_tree, (caddr_t) matched_idl_entry, (AVL_CMP) bdb_idl_entry_cmp ); avl_delete( &bdb->bi_idl_tree, (caddr_t) matched_idl_entry,
bdb_idl_entry_cmp );
--bdb->bi_idl_cache_size; --bdb->bi_idl_cache_size;
IDL_LRU_DELETE( bdb, matched_idl_entry ); IDL_LRU_DELETE( bdb, matched_idl_entry );
free( matched_idl_entry->kstr.bv_val ); free( matched_idl_entry->kstr.bv_val );
@ -743,9 +749,11 @@ bdb_idl_delete_key(
DBT2bv( key, &idl_tmp.kstr ); DBT2bv( key, &idl_tmp.kstr );
idl_tmp.db = db; idl_tmp.db = db;
ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex ); ldap_pvt_thread_mutex_lock( &bdb->bi_idl_tree_mutex );
matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp, (AVL_CMP) bdb_idl_entry_cmp ); matched_idl_entry = avl_find( bdb->bi_idl_tree, &idl_tmp,
bdb_idl_entry_cmp );
if ( matched_idl_entry != NULL ) { if ( matched_idl_entry != NULL ) {
avl_delete( &bdb->bi_idl_tree, (caddr_t) matched_idl_entry, (AVL_CMP) bdb_idl_entry_cmp ); avl_delete( &bdb->bi_idl_tree, (caddr_t) matched_idl_entry,
bdb_idl_entry_cmp );
--bdb->bi_idl_cache_size; --bdb->bi_idl_cache_size;
IDL_LRU_DELETE( bdb, matched_idl_entry ); IDL_LRU_DELETE( bdb, matched_idl_entry );
free( matched_idl_entry->kstr.bv_val ); free( matched_idl_entry->kstr.bv_val );

View file

@ -120,7 +120,7 @@ ldap_back_map_attrs(
int remap int remap
); );
extern void mapping_free ( struct ldapmapping *mapping ); extern void mapping_free ( void *mapping );
#ifdef ENABLE_REWRITE #ifdef ENABLE_REWRITE
extern int suffix_massage_config( struct rewrite_info *info, extern int suffix_massage_config( struct rewrite_info *info,

View file

@ -131,9 +131,10 @@ ldap_back_db_init(
static void static void
conn_free( conn_free(
struct ldapconn *lc void *v_lc
) )
{ {
struct ldapconn *lc = v_lc;
ldap_unbind( lc->ld ); ldap_unbind( lc->ld );
if ( lc->bound_dn.bv_val ) { if ( lc->bound_dn.bv_val ) {
ch_free( lc->bound_dn.bv_val ); ch_free( lc->bound_dn.bv_val );
@ -145,8 +146,9 @@ conn_free(
} }
void void
mapping_free ( struct ldapmapping *mapping ) mapping_free( void *v_mapping )
{ {
struct ldapmapping *mapping = v_mapping;
ch_free( mapping->src.bv_val ); ch_free( mapping->src.bv_val );
ch_free( mapping->dst.bv_val ); ch_free( mapping->dst.bv_val );
ch_free( mapping ); ch_free( mapping );
@ -177,7 +179,7 @@ ldap_back_db_destroy(
li->bindpw = NULL; li->bindpw = NULL;
} }
if (li->conntree) { if (li->conntree) {
avl_free( li->conntree, (AVL_FREE) conn_free ); avl_free( li->conntree, conn_free );
} }
#ifdef ENABLE_REWRITE #ifdef ENABLE_REWRITE
if (li->rwinfo) { if (li->rwinfo) {
@ -190,9 +192,9 @@ ldap_back_db_destroy(
#endif /* !ENABLE_REWRITE */ #endif /* !ENABLE_REWRITE */
avl_free( li->oc_map.remap, NULL ); avl_free( li->oc_map.remap, NULL );
avl_free( li->oc_map.map, (AVL_FREE) mapping_free ); avl_free( li->oc_map.map, mapping_free );
avl_free( li->at_map.remap, NULL ); avl_free( li->at_map.remap, NULL );
avl_free( li->at_map.map, (AVL_FREE) mapping_free ); avl_free( li->at_map.map, mapping_free );
ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
ldap_pvt_thread_mutex_destroy( &li->conn_mutex ); ldap_pvt_thread_mutex_destroy( &li->conn_mutex );

View file

@ -23,19 +23,22 @@ typedef struct ldbm_attrinfo {
static int static int
ainfo_type_cmp( ainfo_type_cmp(
AttributeDescription *desc, const void *v_desc,
AttrInfo *a const void *v_a
) )
{ {
const AttributeDescription *desc = v_desc;
const AttrInfo *a = v_a;
return desc - a->ai_desc; return desc - a->ai_desc;
} }
static int static int
ainfo_cmp( ainfo_cmp(
AttrInfo *a, const void *v_a,
AttrInfo *b const void *v_b
) )
{ {
const AttrInfo *a = v_a, *b = v_b;
return a->ai_desc - b->ai_desc; return a->ai_desc - b->ai_desc;
} }
@ -47,8 +50,7 @@ attr_mask(
{ {
AttrInfo *a; AttrInfo *a;
a = (AttrInfo *) avl_find( li->li_attrs, desc, a = avl_find( li->li_attrs, desc, ainfo_type_cmp );
(AVL_CMP) ainfo_type_cmp );
*indexmask = a != NULL ? a->ai_indexmask : 0; *indexmask = a != NULL ? a->ai_indexmask : 0;
} }
@ -195,7 +197,7 @@ attr_index_config(
a->ai_indexmask = mask; a->ai_indexmask = mask;
rc = avl_insert( &li->li_attrs, (caddr_t) a, rc = avl_insert( &li->li_attrs, (caddr_t) a,
(AVL_CMP) ainfo_cmp, (AVL_DUP) avl_dup_error ); ainfo_cmp, avl_dup_error );
if( rc ) { if( rc ) {
fprintf( stderr, "%s: line %d: duplicate index definition " fprintf( stderr, "%s: line %d: duplicate index definition "

View file

@ -244,7 +244,7 @@ cache_add_entry_rw(
} }
if ( avl_insert( &cache->c_dntree, (caddr_t) e, if ( avl_insert( &cache->c_dntree, (caddr_t) e,
(AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 ) entry_dn_cmp, avl_dup_error ) != 0 )
{ {
/* free cache mutex */ /* free cache mutex */
ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
@ -266,7 +266,7 @@ cache_add_entry_rw(
/* id tree */ /* id tree */
if ( avl_insert( &cache->c_idtree, (caddr_t) e, if ( avl_insert( &cache->c_idtree, (caddr_t) e,
(AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 ) entry_id_cmp, avl_dup_error ) != 0 )
{ {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1, LDAP_LOG( CACHE, DETAIL1,
@ -280,7 +280,7 @@ cache_add_entry_rw(
/* delete from dn tree inserted above */ /* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e, if ( avl_delete( &cache->c_dntree, (caddr_t) e,
(AVL_CMP) entry_dn_cmp ) == NULL ) entry_dn_cmp ) == NULL )
{ {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO, LDAP_LOG( CACHE, INFO,
@ -368,7 +368,7 @@ cache_update_entry(
assert( e->e_private ); assert( e->e_private );
if ( avl_insert( &cache->c_dntree, (caddr_t) e, if ( avl_insert( &cache->c_dntree, (caddr_t) e,
(AVL_CMP) entry_dn_cmp, avl_dup_error ) != 0 ) entry_dn_cmp, avl_dup_error ) != 0 )
{ {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1, LDAP_LOG( CACHE, DETAIL1,
@ -387,7 +387,7 @@ cache_update_entry(
/* id tree */ /* id tree */
if ( avl_insert( &cache->c_idtree, (caddr_t) e, if ( avl_insert( &cache->c_idtree, (caddr_t) e,
(AVL_CMP) entry_id_cmp, avl_dup_error ) != 0 ) entry_id_cmp, avl_dup_error ) != 0 )
{ {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, DETAIL1, LDAP_LOG( CACHE, DETAIL1,
@ -401,7 +401,7 @@ cache_update_entry(
/* delete from dn tree inserted above */ /* delete from dn tree inserted above */
if ( avl_delete( &cache->c_dntree, (caddr_t) e, if ( avl_delete( &cache->c_dntree, (caddr_t) e,
(AVL_CMP) entry_dn_cmp ) == NULL ) entry_dn_cmp ) == NULL )
{ {
#ifdef NEW_LOGGING #ifdef NEW_LOGGING
LDAP_LOG( CACHE, INFO, LDAP_LOG( CACHE, INFO,
@ -484,7 +484,7 @@ try_again:
ldap_pvt_thread_mutex_lock( &cache->c_mutex ); ldap_pvt_thread_mutex_lock( &cache->c_mutex );
if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e, if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
(AVL_CMP) entry_dn_cmp )) != NULL ) entry_dn_cmp )) != NULL )
{ {
int state; int state;
count++; count++;
@ -571,7 +571,7 @@ try_again:
ldap_pvt_thread_mutex_lock( &cache->c_mutex ); ldap_pvt_thread_mutex_lock( &cache->c_mutex );
if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e, if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
(AVL_CMP) entry_id_cmp )) != NULL ) entry_id_cmp )) != NULL )
{ {
int state; int state;
ID ep_id; ID ep_id;
@ -683,15 +683,13 @@ cache_delete_entry_internal(
int rc = 0; /* return code */ int rc = 0; /* return code */
/* dn tree */ /* dn tree */
if ( avl_delete( &cache->c_dntree, (caddr_t) e, (AVL_CMP) entry_dn_cmp ) if ( avl_delete( &cache->c_dntree, (caddr_t) e, entry_dn_cmp ) == NULL )
== NULL )
{ {
rc = -1; rc = -1;
} }
/* id tree */ /* id tree */
if ( avl_delete( &cache->c_idtree, (caddr_t) e, (AVL_CMP) entry_id_cmp ) if ( avl_delete( &cache->c_idtree, (caddr_t) e, entry_id_cmp ) == NULL )
== NULL )
{ {
rc = -1; rc = -1;
} }

View file

@ -157,9 +157,10 @@ meta_back_db_init(
static void static void
conn_free( conn_free(
struct metaconn *lc void *v_lc
) )
{ {
struct metaconn *lc = v_lc;
struct metasingleconn *lsc; struct metasingleconn *lsc;
for ( lsc = lc->conns; !META_LAST(lsc); lsc++ ) { for ( lsc = lc->conns; !META_LAST(lsc); lsc++ ) {
@ -205,9 +206,9 @@ target_free(
rewrite_info_delete( lt->rwinfo ); rewrite_info_delete( lt->rwinfo );
} }
avl_free( lt->oc_map.remap, NULL ); avl_free( lt->oc_map.remap, NULL );
avl_free( lt->oc_map.map, ( AVL_FREE )mapping_free ); avl_free( lt->oc_map.map, mapping_free );
avl_free( lt->at_map.remap, NULL ); avl_free( lt->at_map.remap, NULL );
avl_free( lt->at_map.map, ( AVL_FREE )mapping_free ); avl_free( lt->at_map.map, mapping_free );
} }
int int
@ -228,8 +229,7 @@ meta_back_db_destroy(
ldap_pvt_thread_mutex_lock( &li->conn_mutex ); ldap_pvt_thread_mutex_lock( &li->conn_mutex );
if ( li->conntree ) { if ( li->conntree ) {
avl_free( li->conntree, avl_free( li->conntree, conn_free );
( AVL_FREE )conn_free );
} }
/* /*
@ -245,8 +245,7 @@ meta_back_db_destroy(
ldap_pvt_thread_mutex_lock( &li->cache.mutex ); ldap_pvt_thread_mutex_lock( &li->cache.mutex );
if ( li->cache.tree ) { if ( li->cache.tree ) {
avl_free( li->cache.tree, avl_free( li->cache.tree, meta_dncache_free );
( AVL_FREE )meta_dncache_free );
} }
ldap_pvt_thread_mutex_unlock( &li->cache.mutex ); ldap_pvt_thread_mutex_unlock( &li->cache.mutex );

View file

@ -263,9 +263,11 @@ backsql_has_children(
return rc; return rc;
} }
int static int
backsql_get_attr_vals( backsql_at_map_rec *at, backsql_srch_info *bsi ) backsql_get_attr_vals( void *v_at, void *v_bsi )
{ {
backsql_at_map_rec *at = v_at;
backsql_srch_info *bsi = v_bsi;
RETCODE rc; RETCODE rc;
SQLHSTMT sth; SQLHSTMT sth;
BACKSQL_ROW_NTS row; BACKSQL_ROW_NTS row;
@ -403,7 +405,7 @@ backsql_id2entry( backsql_srch_info *bsi, Entry *e, backsql_entryID *eid )
} else { } else {
Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): " Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): "
"retrieving all attributes\n", 0, 0, 0 ); "retrieving all attributes\n", 0, 0, 0 );
avl_apply( bsi->oc->attrs, (AVL_APPLY)backsql_get_attr_vals, avl_apply( bsi->oc->attrs, backsql_get_attr_vals,
bsi, 0, AVL_INORDER ); bsi, 0, AVL_INORDER );
} }

View file

@ -26,14 +26,16 @@
* Uses the pointer to the ObjectClass structure * Uses the pointer to the ObjectClass structure
*/ */
static int static int
backsql_cmp_oc( backsql_oc_map_rec *m1, backsql_oc_map_rec *m2 ) backsql_cmp_oc( const void *v_m1, const void *v_m2 )
{ {
const backsql_oc_map_rec *m1 = v_m1, *m2 = v_m2;
return ( m1->oc < m2->oc ? -1 : ( m1->oc > m2->oc ? 1 : 0 ) ); return ( m1->oc < m2->oc ? -1 : ( m1->oc > m2->oc ? 1 : 0 ) );
} }
static int static int
backsql_cmp_oc_id( backsql_oc_map_rec *m1, backsql_oc_map_rec *m2 ) backsql_cmp_oc_id( const void *v_m1, const void *v_m2 )
{ {
const backsql_oc_map_rec *m1 = v_m1, *m2 = v_m2;
return ( m1->id < m2->id ? -1 : ( m1->id > m2->id ? 1 : 0 ) ); return ( m1->id < m2->id ? -1 : ( m1->id > m2->id ? 1 : 0 ) );
} }
@ -41,8 +43,9 @@ backsql_cmp_oc_id( backsql_oc_map_rec *m1, backsql_oc_map_rec *m2 )
* Uses the pointer to the AttributeDescription structure * Uses the pointer to the AttributeDescription structure
*/ */
static int static int
backsql_cmp_attr( backsql_at_map_rec *m1, backsql_at_map_rec *m2 ) backsql_cmp_attr( const void *v_m1, const void *v_m2 )
{ {
const backsql_at_map_rec *m1 = v_m1, *m2 = v_m2;
return ( m1->ad < m2->ad ? -1 : ( m1->ad > m2->ad ? 1 : 0 ) ); return ( m1->ad < m2->ad ? -1 : ( m1->ad > m2->ad ? 1 : 0 ) );
} }
@ -116,8 +119,7 @@ backsql_add_sysmaps( backsql_oc_map_rec *oc_map )
at_map->param_order = 0; at_map->param_order = 0;
at_map->expect_return = 0; at_map->expect_return = 0;
backsql_make_attr_query( oc_map, at_map ); backsql_make_attr_query( oc_map, at_map );
avl_insert( &oc_map->attrs, at_map, avl_insert( &oc_map->attrs, at_map, backsql_cmp_attr, NULL );
(AVL_CMP)backsql_cmp_attr, NULL );
at_map = (backsql_at_map_rec *)ch_calloc( 1, at_map = (backsql_at_map_rec *)ch_calloc( 1,
sizeof( backsql_at_map_rec ) ); sizeof( backsql_at_map_rec ) );
@ -145,8 +147,7 @@ backsql_add_sysmaps( backsql_oc_map_rec *oc_map )
at_map->param_order = 0; at_map->param_order = 0;
at_map->expect_return = 0; at_map->expect_return = 0;
backsql_make_attr_query( oc_map, at_map ); backsql_make_attr_query( oc_map, at_map );
avl_insert( &oc_map->attrs, at_map, avl_insert( &oc_map->attrs, at_map, backsql_cmp_attr, NULL );
(AVL_CMP)backsql_cmp_attr, NULL );
return 1; return 1;
} }
@ -259,10 +260,8 @@ backsql_load_schema_map( backsql_info *si, SQLHDBC dbh )
*/ */
oc_map->attrs = NULL; oc_map->attrs = NULL;
avl_insert( &si->oc_by_oc, oc_map, avl_insert( &si->oc_by_oc, oc_map, backsql_cmp_oc, NULL );
(AVL_CMP)backsql_cmp_oc, NULL ); avl_insert( &si->oc_by_id, oc_map, backsql_cmp_oc_id, NULL );
avl_insert( &si->oc_by_id, oc_map,
(AVL_CMP)backsql_cmp_oc_id, NULL );
oc_id = oc_map->id; oc_id = oc_map->id;
Debug( LDAP_DEBUG_TRACE, "load_schema_map(): " Debug( LDAP_DEBUG_TRACE, "load_schema_map(): "
"objectClass '%s': keytbl='%s' keycol='%s'\n", "objectClass '%s': keytbl='%s' keycol='%s'\n",
@ -367,8 +366,7 @@ backsql_load_schema_map( backsql_info *si, SQLHDBC dbh )
Debug( LDAP_DEBUG_TRACE, "load_schema_map(): " Debug( LDAP_DEBUG_TRACE, "load_schema_map(): "
"preconstructed query '%s'\n", "preconstructed query '%s'\n",
at_map->query, 0, 0 ); at_map->query, 0, 0 );
avl_insert( &oc_map->attrs, at_map, avl_insert( &oc_map->attrs, at_map, backsql_cmp_attr, NULL );
(AVL_CMP)backsql_cmp_attr, NULL );
} }
backsql_FreeRow( &at_row ); backsql_FreeRow( &at_row );
SQLFreeStmt( at_sth, SQL_CLOSE ); SQLFreeStmt( at_sth, SQL_CLOSE );
@ -393,8 +391,7 @@ backsql_oc2oc( backsql_info *si, ObjectClass *oc )
#endif /* BACKSQL_TRACE */ #endif /* BACKSQL_TRACE */
tmp.oc = oc; tmp.oc = oc;
res = (backsql_oc_map_rec *)avl_find( si->oc_by_oc, &tmp, res = (backsql_oc_map_rec *)avl_find( si->oc_by_oc, &tmp, backsql_cmp_oc );
(AVL_CMP)backsql_cmp_oc );
#ifdef BACKSQL_TRACE #ifdef BACKSQL_TRACE
if ( res != NULL ) { if ( res != NULL ) {
Debug( LDAP_DEBUG_TRACE, "<==backsql_oc2oc(): " Debug( LDAP_DEBUG_TRACE, "<==backsql_oc2oc(): "
@ -425,8 +422,7 @@ backsql_name2oc( backsql_info *si, struct berval *oc_name )
return NULL; return NULL;
} }
res = (backsql_oc_map_rec *)avl_find( si->oc_by_oc, &tmp, res = (backsql_oc_map_rec *)avl_find( si->oc_by_oc, &tmp, backsql_cmp_oc );
(AVL_CMP)backsql_cmp_oc );
#ifdef BACKSQL_TRACE #ifdef BACKSQL_TRACE
if ( res != NULL ) { if ( res != NULL ) {
Debug( LDAP_DEBUG_TRACE, "<==oc_with_name(): " Debug( LDAP_DEBUG_TRACE, "<==oc_with_name(): "
@ -453,7 +449,7 @@ backsql_id2oc( backsql_info *si, unsigned long id )
tmp.id = id; tmp.id = id;
res = (backsql_oc_map_rec *)avl_find( si->oc_by_id, &tmp, res = (backsql_oc_map_rec *)avl_find( si->oc_by_id, &tmp,
(AVL_CMP)backsql_cmp_oc_id ); backsql_cmp_oc_id );
#ifdef BACKSQL_TRACE #ifdef BACKSQL_TRACE
if ( res != NULL ) { if ( res != NULL ) {
@ -482,7 +478,7 @@ backsql_ad2at( backsql_oc_map_rec* objclass, AttributeDescription *ad )
tmp.ad = ad; tmp.ad = ad;
res = (backsql_at_map_rec *)avl_find( objclass->attrs, &tmp, res = (backsql_at_map_rec *)avl_find( objclass->attrs, &tmp,
(AVL_CMP)backsql_cmp_attr ); backsql_cmp_attr );
#ifdef BACKSQL_TRACE #ifdef BACKSQL_TRACE
if ( res != NULL ) { if ( res != NULL ) {
@ -518,7 +514,7 @@ backsql_name2at( backsql_oc_map_rec* objclass, struct berval *attr )
} }
res = (backsql_at_map_rec *)avl_find( objclass->attrs, &tmp, res = (backsql_at_map_rec *)avl_find( objclass->attrs, &tmp,
(AVL_CMP)backsql_cmp_attr ); backsql_cmp_attr );
#ifdef BACKSQL_TRACE #ifdef BACKSQL_TRACE
if ( res != NULL ) { if ( res != NULL ) {
@ -535,8 +531,9 @@ backsql_name2at( backsql_oc_map_rec* objclass, struct berval *attr )
} }
static void static void
backsql_free_attr( backsql_at_map_rec *at ) backsql_free_attr( void *v_at )
{ {
backsql_at_map_rec *at = v_at;
Debug( LDAP_DEBUG_TRACE, "==>free_attr(): '%s'\n", Debug( LDAP_DEBUG_TRACE, "==>free_attr(): '%s'\n",
at->ad->ad_cname.bv_val, 0, 0 ); at->ad->ad_cname.bv_val, 0, 0 );
ch_free( at->sel_expr.bv_val ); ch_free( at->sel_expr.bv_val );
@ -567,11 +564,12 @@ backsql_free_attr( backsql_at_map_rec *at )
} }
static void static void
backsql_free_oc( backsql_oc_map_rec *oc ) backsql_free_oc( void *v_oc )
{ {
backsql_oc_map_rec *oc = v_oc;
Debug( LDAP_DEBUG_TRACE, "==>free_oc(): '%s'\n", Debug( LDAP_DEBUG_TRACE, "==>free_oc(): '%s'\n",
BACKSQL_OC_NAME( oc ), 0, 0 ); BACKSQL_OC_NAME( oc ), 0, 0 );
avl_free( oc->attrs, (AVL_FREE)backsql_free_attr ); avl_free( oc->attrs, backsql_free_attr );
ch_free( oc->keytbl.bv_val ); ch_free( oc->keytbl.bv_val );
ch_free( oc->keycol.bv_val ); ch_free( oc->keycol.bv_val );
if ( oc->create_proc != NULL ) { if ( oc->create_proc != NULL ) {
@ -592,8 +590,8 @@ int
backsql_destroy_schema_map( backsql_info *si ) backsql_destroy_schema_map( backsql_info *si )
{ {
Debug( LDAP_DEBUG_TRACE, "==>destroy_schema_map()\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "==>destroy_schema_map()\n", 0, 0, 0 );
avl_free( si->oc_by_oc, NULL ); avl_free( si->oc_by_oc, 0 );
avl_free( si->oc_by_id, (AVL_FREE)backsql_free_oc ); avl_free( si->oc_by_id, backsql_free_oc );
Debug( LDAP_DEBUG_TRACE, "<==destroy_schema_map()\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "<==destroy_schema_map()\n", 0, 0, 0 );
return 0; return 0;
} }

View file

@ -799,9 +799,11 @@ backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
return ( query->bv_val == NULL ? 1 : 0 ); return ( query->bv_val == NULL ? 1 : 0 );
} }
int static int
backsql_oc_get_candidates( backsql_oc_map_rec *oc, backsql_srch_info *bsi ) backsql_oc_get_candidates( void *v_oc, void *v_bsi )
{ {
backsql_oc_map_rec *oc = v_oc;
backsql_srch_info *bsi = v_bsi;
struct berval query; struct berval query;
SQLHSTMT sth; SQLHSTMT sth;
RETCODE rc; RETCODE rc;
@ -1128,7 +1130,7 @@ backsql_search(
*/ */
srch_info.n_candidates = ( isroot ? -2 : limit->lms_s_unchecked == -1 srch_info.n_candidates = ( isroot ? -2 : limit->lms_s_unchecked == -1
? -2 : limit->lms_s_unchecked ); ? -2 : limit->lms_s_unchecked );
avl_apply( bi->oc_by_oc, (AVL_APPLY)backsql_oc_get_candidates, avl_apply( bi->oc_by_oc, backsql_oc_get_candidates,
&srch_info, BACKSQL_STOP, AVL_INORDER ); &srch_info, BACKSQL_STOP, AVL_INORDER );
if ( !isroot && limit->lms_s_unchecked != -1 ) { if ( !isroot && limit->lms_s_unchecked != -1 ) {
if ( srch_info.n_candidates == -1 ) { if ( srch_info.n_candidates == -1 ) {

View file

@ -253,8 +253,9 @@ backsql_FreeRow( BACKSQL_ROW_NTS *row )
} }
static int static int
backsql_cmp_connid( backsql_db_conn *c1, backsql_db_conn *c2 ) backsql_cmp_connid( const void *v_c1, const void *v_c2 )
{ {
const backsql_db_conn *c1 = v_c1, *c2 = v_c2;
if ( c1->ldap_cid > c2->ldap_cid ) { if ( c1->ldap_cid > c2->ldap_cid ) {
return 1; return 1;
} }
@ -390,7 +391,7 @@ backsql_open_db_conn( backsql_info *si, int ldap_cid, backsql_db_conn **pdbc )
Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(): " Debug( LDAP_DEBUG_TRACE, "backsql_open_db_conn(): "
"connected, adding to tree\n", 0, 0, 0 ); "connected, adding to tree\n", 0, 0, 0 );
ldap_pvt_thread_mutex_lock( &si->dbconn_mutex ); ldap_pvt_thread_mutex_lock( &si->dbconn_mutex );
avl_insert( &si->db_conns, dbc, (AVL_CMP)backsql_cmp_connid, NULL ); avl_insert( &si->db_conns, dbc, backsql_cmp_connid, NULL );
ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex ); ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex );
Debug( LDAP_DEBUG_TRACE, "<==backsql_open_db_conn()\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "<==backsql_open_db_conn()\n", 0, 0, 0 );
@ -408,8 +409,7 @@ backsql_free_db_conn( Backend *be, Connection *ldapc )
Debug( LDAP_DEBUG_TRACE, "==>backsql_free_db_conn()\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "==>backsql_free_db_conn()\n", 0, 0, 0 );
tmp.ldap_cid = ldapc->c_connid; tmp.ldap_cid = ldapc->c_connid;
ldap_pvt_thread_mutex_lock( &si->dbconn_mutex ); ldap_pvt_thread_mutex_lock( &si->dbconn_mutex );
conn = (backsql_db_conn *)avl_delete( &si->db_conns, &tmp, conn = avl_delete( &si->db_conns, &tmp, backsql_cmp_connid );
(AVL_CMP)backsql_cmp_connid );
ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex ); ldap_pvt_thread_mutex_unlock( &si->dbconn_mutex );
/* /*
@ -444,8 +444,7 @@ backsql_get_db_conn( Backend *be, Connection *ldapc, SQLHDBC *dbh )
* we have one thread per connection, as I understand -- * we have one thread per connection, as I understand --
* so we do not need locking here * so we do not need locking here
*/ */
dbc = (backsql_db_conn *)avl_find( si->db_conns, &tmp, dbc = avl_find( si->db_conns, &tmp, backsql_cmp_connid );
(AVL_CMP)backsql_cmp_connid );
if ( !dbc ) { if ( !dbc ) {
rc = backsql_open_db_conn( si, ldapc->c_connid, &dbc ); rc = backsql_open_db_conn( si, ldapc->c_connid, &dbc );
if ( rc != LDAP_SUCCESS) { if ( rc != LDAP_SUCCESS) {

View file

@ -28,9 +28,11 @@ static ContentRule *cr_list = NULL;
static int static int
cr_index_cmp( cr_index_cmp(
struct cindexrec *cir1, const void *v_cir1,
struct cindexrec *cir2 ) const void *v_cir2 )
{ {
const struct cindexrec *cir1 = v_cir1;
const struct cindexrec *cir2 = v_cir2;
int i = cir1->cir_name.bv_len - cir2->cir_name.bv_len; int i = cir1->cir_name.bv_len - cir2->cir_name.bv_len;
if (i) if (i)
return i; return i;
@ -39,9 +41,11 @@ cr_index_cmp(
static int static int
cr_index_name_cmp( cr_index_name_cmp(
struct berval *name, const void *v_name,
struct cindexrec *cir ) const void *v_cir )
{ {
const struct berval *name = v_name;
const struct cindexrec *cir = v_cir;
int i = name->bv_len - cir->cir_name.bv_len; int i = name->bv_len - cir->cir_name.bv_len;
if (i) if (i)
return i; return i;
@ -64,8 +68,7 @@ cr_bvfind( struct berval *crname )
{ {
struct cindexrec *cir; struct cindexrec *cir;
cir = (struct cindexrec *) avl_find( cr_index, crname, cir = avl_find( cr_index, crname, cr_index_name_cmp );
(AVL_CMP) cr_index_name_cmp );
if ( cir != NULL ) { if ( cir != NULL ) {
return( cir->cir_cr ); return( cir->cir_cr );
@ -118,8 +121,7 @@ cr_insert(
assert( cir->cir_cr ); assert( cir->cir_cr );
if ( avl_insert( &cr_index, (caddr_t) cir, if ( avl_insert( &cr_index, (caddr_t) cir,
(AVL_CMP) cr_index_cmp, cr_index_cmp, avl_dup_error ) )
(AVL_DUP) avl_dup_error ) )
{ {
*err = scr->scr_oid; *err = scr->scr_oid;
ldap_memfree(cir); ldap_memfree(cir);
@ -142,8 +144,7 @@ cr_insert(
assert( cir->cir_cr ); assert( cir->cir_cr );
if ( avl_insert( &cr_index, (caddr_t) cir, if ( avl_insert( &cr_index, (caddr_t) cir,
(AVL_CMP) cr_index_cmp, cr_index_cmp, avl_dup_error ) )
(AVL_DUP) avl_dup_error ) )
{ {
*err = *names; *err = *names;
ldap_memfree(cir); ldap_memfree(cir);

View file

@ -388,17 +388,19 @@ entry_cmp( Entry *e1, Entry *e2 )
} }
int int
entry_dn_cmp( Entry *e1, Entry *e2 ) entry_dn_cmp( const void *v_e1, const void *v_e2 )
{ {
/* compare their normalized UPPERCASED dn's */ /* compare their normalized UPPERCASED dn's */
const Entry *e1 = v_e1, *e2 = v_e2;
int rc = e1->e_nname.bv_len - e2->e_nname.bv_len; int rc = e1->e_nname.bv_len - e2->e_nname.bv_len;
if (rc) return rc; if (rc) return rc;
return( strcmp( e1->e_ndn, e2->e_ndn ) ); return( strcmp( e1->e_ndn, e2->e_ndn ) );
} }
int int
entry_id_cmp( Entry *e1, Entry *e2 ) entry_id_cmp( const void *v_e1, const void *v_e2 )
{ {
const Entry *e1 = v_e1, *e2 = v_e2;
return( e1->e_id < e2->e_id ? -1 : (e1->e_id > e2->e_id ? 1 : 0) ); return( e1->e_id < e2->e_id ? -1 : (e1->e_id > e2->e_id ? 1 : 0) );
} }

View file

@ -27,10 +27,12 @@ static MatchingRuleUse *mru_list = NULL;
static int static int
mr_index_cmp( mr_index_cmp(
struct mindexrec *mir1, const void *v_mir1,
struct mindexrec *mir2 const void *v_mir2
) )
{ {
const struct mindexrec *mir1 = v_mir1;
const struct mindexrec *mir2 = v_mir2;
int i = mir1->mir_name.bv_len - mir2->mir_name.bv_len; int i = mir1->mir_name.bv_len - mir2->mir_name.bv_len;
if (i) return i; if (i) return i;
return (strcmp( mir1->mir_name.bv_val, mir2->mir_name.bv_val )); return (strcmp( mir1->mir_name.bv_val, mir2->mir_name.bv_val ));
@ -38,10 +40,12 @@ mr_index_cmp(
static int static int
mr_index_name_cmp( mr_index_name_cmp(
struct berval *name, const void *v_name,
struct mindexrec *mir const void *v_mir
) )
{ {
const struct berval *name = v_name;
const struct mindexrec *mir = v_mir;
int i = name->bv_len - mir->mir_name.bv_len; int i = name->bv_len - mir->mir_name.bv_len;
if (i) return i; if (i) return i;
return (strncmp( name->bv_val, mir->mir_name.bv_val, name->bv_len )); return (strncmp( name->bv_val, mir->mir_name.bv_val, name->bv_len ));
@ -62,8 +66,7 @@ mr_bvfind( struct berval *mrname )
{ {
struct mindexrec *mir = NULL; struct mindexrec *mir = NULL;
if ( (mir = (struct mindexrec *) avl_find( mr_index, mrname, if ( (mir = avl_find( mr_index, mrname, mr_index_name_cmp )) != NULL ) {
(AVL_CMP) mr_index_name_cmp )) != NULL ) {
return( mir->mir_mr ); return( mir->mir_mr );
} }
return( NULL ); return( NULL );
@ -105,8 +108,7 @@ mr_insert(
mir->mir_name.bv_len = strlen( smr->smr_oid ); mir->mir_name.bv_len = strlen( smr->smr_oid );
mir->mir_mr = smr; mir->mir_mr = smr;
if ( avl_insert( &mr_index, (caddr_t) mir, if ( avl_insert( &mr_index, (caddr_t) mir,
(AVL_CMP) mr_index_cmp, mr_index_cmp, avl_dup_error ) ) {
(AVL_DUP) avl_dup_error ) ) {
*err = smr->smr_oid; *err = smr->smr_oid;
ldap_memfree(mir); ldap_memfree(mir);
return SLAP_SCHERR_MR_DUP; return SLAP_SCHERR_MR_DUP;
@ -122,8 +124,7 @@ mr_insert(
mir->mir_name.bv_len = strlen( *names ); mir->mir_name.bv_len = strlen( *names );
mir->mir_mr = smr; mir->mir_mr = smr;
if ( avl_insert( &mr_index, (caddr_t) mir, if ( avl_insert( &mr_index, (caddr_t) mir,
(AVL_CMP) mr_index_cmp, mr_index_cmp, avl_dup_error ) ) {
(AVL_DUP) avl_dup_error ) ) {
*err = *names; *err = *names;
ldap_memfree(mir); ldap_memfree(mir);
return SLAP_SCHERR_MR_DUP; return SLAP_SCHERR_MR_DUP;

View file

@ -119,9 +119,10 @@ static ObjectClass *oc_list = NULL;
static int static int
oc_index_cmp( oc_index_cmp(
struct oindexrec *oir1, const void *v_oir1,
struct oindexrec *oir2 ) const void *v_oir2 )
{ {
const struct oindexrec *oir1 = v_oir1, *oir2 = v_oir2;
int i = oir1->oir_name.bv_len - oir2->oir_name.bv_len; int i = oir1->oir_name.bv_len - oir2->oir_name.bv_len;
if (i) if (i)
return i; return i;
@ -130,9 +131,11 @@ oc_index_cmp(
static int static int
oc_index_name_cmp( oc_index_name_cmp(
struct berval *name, const void *v_name,
struct oindexrec *oir ) const void *v_oir )
{ {
const struct berval *name = v_name;
const struct oindexrec *oir = v_oir;
int i = name->bv_len - oir->oir_name.bv_len; int i = name->bv_len - oir->oir_name.bv_len;
if (i) if (i)
return i; return i;
@ -155,8 +158,7 @@ oc_bvfind( struct berval *ocname )
{ {
struct oindexrec *oir; struct oindexrec *oir;
oir = (struct oindexrec *) avl_find( oc_index, ocname, oir = avl_find( oc_index, ocname, oc_index_name_cmp );
(AVL_CMP) oc_index_name_cmp );
if ( oir != NULL ) { if ( oir != NULL ) {
return( oir->oir_oc ); return( oir->oir_oc );
@ -360,8 +362,7 @@ oc_insert(
assert( oir->oir_oc ); assert( oir->oir_oc );
if ( avl_insert( &oc_index, (caddr_t) oir, if ( avl_insert( &oc_index, (caddr_t) oir,
(AVL_CMP) oc_index_cmp, oc_index_cmp, avl_dup_error ) )
(AVL_DUP) avl_dup_error ) )
{ {
*err = soc->soc_oid; *err = soc->soc_oid;
ldap_memfree(oir); ldap_memfree(oir);
@ -384,8 +385,7 @@ oc_insert(
assert( oir->oir_oc ); assert( oir->oir_oc );
if ( avl_insert( &oc_index, (caddr_t) oir, if ( avl_insert( &oc_index, (caddr_t) oir,
(AVL_CMP) oc_index_cmp, oc_index_cmp, avl_dup_error ) )
(AVL_DUP) avl_dup_error ) )
{ {
*err = *names; *err = *names;
ldap_memfree(oir); ldap_memfree(oir);

View file

@ -445,8 +445,8 @@ LDAP_SLAPD_F (int) entry_encode LDAP_P(( Entry *e, struct berval *bv ));
LDAP_SLAPD_F (void) entry_free LDAP_P(( Entry *e )); LDAP_SLAPD_F (void) entry_free LDAP_P(( Entry *e ));
LDAP_SLAPD_F (int) entry_cmp LDAP_P(( Entry *a, Entry *b )); LDAP_SLAPD_F (int) entry_cmp LDAP_P(( Entry *a, Entry *b ));
LDAP_SLAPD_F (int) entry_dn_cmp LDAP_P(( Entry *a, Entry *b )); LDAP_SLAPD_F (int) entry_dn_cmp LDAP_P(( const void *v_a, const void *v_b ));
LDAP_SLAPD_F (int) entry_id_cmp LDAP_P(( Entry *a, Entry *b )); LDAP_SLAPD_F (int) entry_id_cmp LDAP_P(( const void *v_a, const void *v_b ));
/* /*
* extended.c * extended.c

View file

@ -26,20 +26,21 @@ static Syntax *syn_list = NULL;
static int static int
syn_index_cmp( syn_index_cmp(
struct sindexrec *sir1, const void *v_sir1,
struct sindexrec *sir2 const void *v_sir2
) )
{ {
const struct sindexrec *sir1 = v_sir1, *sir2 = v_sir2;
return (strcmp( sir1->sir_name, sir2->sir_name )); return (strcmp( sir1->sir_name, sir2->sir_name ));
} }
static int static int
syn_index_name_cmp( syn_index_name_cmp(
const char *name, const void *name,
struct sindexrec *sir const void *sir
) )
{ {
return (strcmp( name, sir->sir_name )); return (strcmp( name, ((const struct sindexrec *)sir)->sir_name ));
} }
Syntax * Syntax *
@ -47,8 +48,7 @@ syn_find( const char *synname )
{ {
struct sindexrec *sir = NULL; struct sindexrec *sir = NULL;
if ( (sir = (struct sindexrec *) avl_find( syn_index, synname, if ( (sir = avl_find( syn_index, synname, syn_index_name_cmp )) != NULL ) {
(AVL_CMP) syn_index_name_cmp )) != NULL ) {
return( sir->sir_syn ); return( sir->sir_syn );
} }
return( NULL ); return( NULL );
@ -107,8 +107,7 @@ syn_insert(
sir->sir_name = ssyn->ssyn_oid; sir->sir_name = ssyn->ssyn_oid;
sir->sir_syn = ssyn; sir->sir_syn = ssyn;
if ( avl_insert( &syn_index, (caddr_t) sir, if ( avl_insert( &syn_index, (caddr_t) sir,
(AVL_CMP) syn_index_cmp, syn_index_cmp, avl_dup_error ) ) {
(AVL_DUP) avl_dup_error ) ) {
*err = ssyn->ssyn_oid; *err = ssyn->ssyn_oid;
ldap_memfree(sir); ldap_memfree(sir);
return SLAP_SCHERR_SYN_DUP; return SLAP_SCHERR_SYN_DUP;