]> git.sur5r.net Git - openldap/commitdiff
Don't use single malloc for BDB_HIER e->e_name + e->e_nname
authorHoward Chu <hyc@openldap.org>
Sat, 24 May 2003 01:54:03 +0000 (01:54 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 24 May 2003 01:54:03 +0000 (01:54 +0000)
servers/slapd/back-bdb/cache.c
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/id2entry.c
servers/slapd/back-bdb/modrdn.c

index 8a6e1b3cbaf0f83af2dbfbe35657f2072d847378..bf965d4cd16524987e6e79ff61280eba3b9651b9 100644 (file)
@@ -719,15 +719,11 @@ bdb_cache_modrdn(
                attrs_free( e->e_attrs );
        }
        e->e_attrs = new->e_attrs;
-#ifdef BDB_HIER
-       ch_free(e->e_name.bv_val);
-#else
        if( e->e_nname.bv_val < e->e_bv.bv_val || e->e_nname.bv_val >
                e->e_bv.bv_val + e->e_bv.bv_len ) {
                ch_free(e->e_name.bv_val);
                ch_free(e->e_nname.bv_val);
        }
-#endif
        e->e_name = new->e_name;
        e->e_nname = new->e_nname;
 
index 865d5ae07c39b28c69109cce30cb46c4b5c1c7dd..8c6fed3bbe3d5afdf3c523984302d65bce7986d5 100644 (file)
@@ -563,8 +563,8 @@ int hdb_fix_dn(
 
        e->e_name.bv_len = rlen - 1;
        e->e_nname.bv_len = nrlen - 1;
-       e->e_name.bv_val = ch_malloc(rlen + nrlen);
-       e->e_nname.bv_val = e->e_name.bv_val + rlen;
+       e->e_name.bv_val = ch_malloc(rlen);
+       e->e_nname.bv_val = ch_malloc(nrlen);
        ptr = e->e_name.bv_val;
        nptr = e->e_nname.bv_val;
        for ( ei = BEI(e); ei && ei->bei_id; ei=ei->bei_parent ) {
index 2660b697d2bb4d342d40171bfbcdf4d8800656da..66aad73ed6c1760a75067d6c98dad3ddf2afc738 100644 (file)
@@ -160,7 +160,6 @@ int bdb_entry_return(
                attrs_free( e->e_attrs );
        }
 
-#ifndef BDB_HIER
        /* See if the DNs were changed by modrdn */
        if( e->e_nname.bv_val < e->e_bv.bv_val || e->e_nname.bv_val >
                e->e_bv.bv_val + e->e_bv.bv_len ) {
@@ -169,15 +168,12 @@ int bdb_entry_return(
                e->e_name.bv_val = NULL;
                e->e_nname.bv_val = NULL;
        }
+#ifndef BDB_HIER
        /* In tool mode the e_bv buffer is realloc'd, leave it alone */
        if( !(slapMode & SLAP_TOOL_MODE) ) {
                free( e->e_bv.bv_val );
        }
 #else
-       /* We had to construct the dn and ndn as well, in a single block */
-       if( e->e_name.bv_val ) {
-               free( e->e_name.bv_val );
-       }
        free( e->e_bv.bv_val );
 #endif
        free( e );
index 2e3824a2ac0a7d15b74a8a91f6a5b2661fb6be7f..d414328e8c69332290589ab766ce3febaaba9325 100644 (file)
@@ -802,14 +802,6 @@ retry:     /* transaction retry */
         * already happened, must free the names. The frees are
         * done in bdb_cache_modrdn().
         */
-#ifdef BDB_HIER
-       e->e_name.bv_val = ch_malloc(new_dn.bv_len + new_ndn.bv_len + 2);
-       e->e_name.bv_len = new_dn.bv_len;
-       e->e_nname.bv_val = e->e_name.bv_val + new_dn.bv_len + 1;
-       e->e_nname.bv_len = new_ndn.bv_len;
-       strcpy(e->e_name.bv_val, new_dn.bv_val);
-       strcpy(e->e_nname.bv_val, new_ndn.bv_val);
-#else
        if( e->e_nname.bv_val < e->e_bv.bv_val || e->e_nname.bv_val >
                e->e_bv.bv_val + e->e_bv.bv_len ) {
                e->e_name.bv_val = NULL;
@@ -819,7 +811,7 @@ retry:      /* transaction retry */
        e->e_nname = new_ndn;
        new_dn.bv_val = NULL;
        new_ndn.bv_val = NULL;
-#endif
+
        /* add new one */
        rs->sr_err = bdb_dn2id_add( op->o_bd, lt2, neip ? neip : eip, e,
                op->o_tmpmemctx );