From: Howard Chu Date: Sat, 29 Dec 2001 10:25:19 +0000 (+0000) Subject: More cleanup X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~418 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dd59babf4385cbdfb22f5c29b9c08e9318fb6421;p=openldap More cleanup --- diff --git a/servers/slapd/back-bdb/back-bdb.h b/servers/slapd/back-bdb/back-bdb.h index 1e55821395..1b746c913d 100644 --- a/servers/slapd/back-bdb/back-bdb.h +++ b/servers/slapd/back-bdb/back-bdb.h @@ -103,7 +103,6 @@ struct bdb_info { ldap_pvt_thread_rdwr_t bi_tree_rdwr; void *bi_troot; int bi_nrdns; - int bi_sufflen; #endif int bi_txn; diff --git a/servers/slapd/back-bdb/dn2entry.c b/servers/slapd/back-bdb/dn2entry.c index b95ae4ea6a..3073ffe85f 100644 --- a/servers/slapd/back-bdb/dn2entry.c +++ b/servers/slapd/back-bdb/dn2entry.c @@ -27,8 +27,7 @@ bdb_dn2entry( int flags ) { int rc; - ID id; - char *matchedDN = NULL; + ID id, id2 = 0; Debug(LDAP_DEBUG_TRACE, "bdb_dn2entry(\"%s\")\n", dn->bv_val, 0, 0 ); @@ -37,7 +36,7 @@ bdb_dn2entry( if( matched != NULL ) { *matched = NULL; - rc = bdb_dn2id_matched( be, tid, dn, &id, &matchedDN ); + rc = bdb_dn2id_matched( be, tid, dn, &id, &id2 ); } else { rc = bdb_dn2id( be, tid, dn, &id ); } @@ -46,10 +45,10 @@ bdb_dn2entry( return rc; } - if( matchedDN == NULL ) { + if( id2 == 0 ) { rc = bdb_id2entry( be, tid, id, e ); } else { - rc = bdb_id2entry( be, tid, id, matched ); + rc = bdb_id2entry( be, tid, id2, matched ); } return rc; diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 1f5969e3ff..1b01e75842 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -237,7 +237,7 @@ bdb_dn2id_matched( DB_TXN *txn, struct berval *in, ID *id, - char **matchedDN ) + ID *id2 ) { int rc; DBT key, data; @@ -260,8 +260,6 @@ bdb_dn2id_matched( data.ulen = sizeof(ID); data.flags = DB_DBT_USERMEM; - *matchedDN = NULL; - while(1) { dn[-1] = DN_BASE_PREFIX; @@ -293,12 +291,12 @@ bdb_dn2id_matched( } if( dn != buf+1 ) { - *matchedDN = (char *) dn; + *id2 = *id; } Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_matched: id=0x%08lx: %s %s\n", - (long) *id, *matchedDN == NULL ? "entry" : "matched", dn ); + (long) *id, *id2 == 0 ? "entry" : "matched", dn ); break; } else { @@ -343,6 +341,7 @@ bdb_dn2id_children( data.dlen = sizeof(id); rc = db->get( db, txn, &key, &data, bdb->bi_db_opflags ); + free( key.data ); Debug( LDAP_DEBUG_TRACE, "<= bdb_dn2id_children( %s ): %schildren (%d)\n", dn, @@ -742,7 +741,7 @@ bdb_dn2id_matched( DB_TXN *txn, struct berval *in, ID *id, - char **matchedDN ) + ID *id2 ) { struct bdb_info *bdb = (struct bdb_info *) be->be_private; int i; @@ -761,8 +760,10 @@ bdb_dn2id_matched( rdns = ldap_explode_dn(in->bv_val, 0); for (i=0; rdns[i]; i++); i -= bdb->bi_nrdns; - if (i < 0) + if (i < 0) { + charray_free(rdns); return -1; + } n = p; ldap_pvt_thread_rdwr_rlock(&bdb->bi_tree_rdwr); for (--i; i>=0; i--) { @@ -773,22 +774,12 @@ bdb_dn2id_matched( p = n; } ldap_pvt_thread_rdwr_runlock(&bdb->bi_tree_rdwr); + charray_free(rdns); if (n) { *id = n->i_id; - } else if (matchedDN) { - int len = 0, j; - char *ptr; - ++i; - for (j=i; rdns[j]; j++) - len += strlen(rdns[j]) + 1; - ptr = ch_malloc(len); - *matchedDN = ptr; - for (;rdns[i]; i++) { - ptr = slap_strcopy(ptr, rdns[i]); - *ptr++ = ','; - } - ptr[-1] = '\0'; + } else if (id2) { + *id2 = p->i_id; } return n ? 0 : DB_NOTFOUND; } diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 802a81361d..7f86a9a14f 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -74,7 +74,7 @@ int bdb_dn2id_matched( DB_TXN *tid, struct berval *dn, ID *id, - char **matchedDN ); + ID *id2 ); int bdb_dn2id_add( BackendDB *be,