From c40115c12e482946477e024766f2c521c1b9d7b3 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 24 May 2003 01:54:03 +0000 Subject: [PATCH] Don't use single malloc for BDB_HIER e->e_name + e->e_nname --- servers/slapd/back-bdb/cache.c | 4 ---- servers/slapd/back-bdb/dn2id.c | 4 ++-- servers/slapd/back-bdb/id2entry.c | 6 +----- servers/slapd/back-bdb/modrdn.c | 10 +--------- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/servers/slapd/back-bdb/cache.c b/servers/slapd/back-bdb/cache.c index 8a6e1b3cba..bf965d4cd1 100644 --- a/servers/slapd/back-bdb/cache.c +++ b/servers/slapd/back-bdb/cache.c @@ -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; diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index 865d5ae07c..8c6fed3bbe 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -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 ) { diff --git a/servers/slapd/back-bdb/id2entry.c b/servers/slapd/back-bdb/id2entry.c index 2660b697d2..66aad73ed6 100644 --- a/servers/slapd/back-bdb/id2entry.c +++ b/servers/slapd/back-bdb/id2entry.c @@ -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 ); diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 2e3824a2ac..d414328e8c 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -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 );