Don't use single malloc for BDB_HIER e->e_name + e->e_nname

This commit is contained in:
Howard Chu 2003-05-24 01:54:03 +00:00
parent d6bfa4ab8f
commit c40115c12e
4 changed files with 4 additions and 20 deletions

View 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;

View 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 ) {

View 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 );

View 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 );