]> git.sur5r.net Git - openldap/commitdiff
More cleanup
authorHoward Chu <hyc@openldap.org>
Sat, 29 Dec 2001 10:25:19 +0000 (10:25 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 29 Dec 2001 10:25:19 +0000 (10:25 +0000)
servers/slapd/back-bdb/back-bdb.h
servers/slapd/back-bdb/dn2entry.c
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/proto-bdb.h

index 1e5582139588a3925eacdef616ded309b2504ca5..1b746c913d038cb704b5efb81ec3c71a7e26288a 100644 (file)
@@ -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;
index b95ae4ea6a9bf80b19d636fc213b4d5b48fe6f97..3073ffe85f94949d8c0faa9633eda718aa755d79 100644 (file)
@@ -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;
index 1f5969e3ff1e4b10e88150b312baa50209a68e08..1b01e7584267da550b544b3029bbece1ee124ef8 100644 (file)
@@ -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;
 }
index 802a81361d9d628ee5263184f4dece06b1a8d62c..7f86a9a14f2d84c61e5bfab84276d6f3d7910458 100644 (file)
@@ -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,