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 );
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 );
}
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;
DB_TXN *txn,
struct berval *in,
ID *id,
- char **matchedDN )
+ ID *id2 )
{
int rc;
DBT key, data;
data.ulen = sizeof(ID);
data.flags = DB_DBT_USERMEM;
- *matchedDN = NULL;
-
while(1) {
dn[-1] = DN_BASE_PREFIX;
}
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 {
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,
DB_TXN *txn,
struct berval *in,
ID *id,
- char **matchedDN )
+ ID *id2 )
{
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
int i;
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--) {
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;
}