From 96773427db9acd7502e7647fe09113cdfbbf67de Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 13 May 2005 09:06:28 +0000 Subject: [PATCH] don't bother about slap_dummy_bv --- servers/slapd/back-ldap/search.c | 47 +++++++++----------------------- servers/slapd/back-meta/search.c | 22 +++++---------- servers/slapd/overlays/rwm.c | 2 +- 3 files changed, 21 insertions(+), 50 deletions(-) diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 144e27f601..2c6d296f5c 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -38,8 +38,7 @@ static int ldap_build_entry( Operation *op, LDAPMessage *e, Entry *ent, - struct berval *bdn, int flags ); -#define LDAP_BUILD_ENTRY_PRIVATE 0x01 + struct berval *bdn ); /* * Quick'n'dirty rewrite of filter in case of error, to deal with @@ -269,35 +268,23 @@ fail:; do_retry = 0; e = ldap_first_entry( lc->lc_ld, res ); - rc = ldap_build_entry( op, e, &ent, &bdn, - LDAP_BUILD_ENTRY_PRIVATE ); + rc = ldap_build_entry( op, e, &ent, &bdn ); if ( rc == LDAP_SUCCESS ) { rs->sr_entry = &ent; rs->sr_attrs = op->ors_attrs; rs->sr_operational_attrs = NULL; rs->sr_flags = 0; abort = send_search_entry( op, rs ); - while ( ent.e_attrs ) { - Attribute *a; - - a = ent.e_attrs; - ent.e_attrs = a->a_next; - - if ( a->a_nvals != a->a_vals ) { - ber_bvarray_free( a->a_nvals ); - } - if ( a->a_vals != &slap_dummy_bv ) { - ber_bvarray_free( a->a_vals ); - } - ch_free( a ); - } - - if ( ent.e_dn && ( ent.e_dn != bdn.bv_val ) ) { - free( ent.e_dn ); + if ( !BER_BVISNULL( &ent.e_name ) && ( ent.e_name.bv_val != bdn.bv_val ) ) + { + free( ent.e_name.bv_val ); + BER_BVZERO( &ent.e_name ); } - if ( ent.e_ndn ) { - free( ent.e_ndn ); + if ( !BER_BVISNULL( &ent.e_nname ) ) { + free( ent.e_nname.bv_val ); + BER_BVZERO( &ent.e_nname ); } + entry_clean( &ent ); } ldap_msgfree( res ); if ( abort ) { @@ -445,15 +432,13 @@ ldap_build_entry( Operation *op, LDAPMessage *e, Entry *ent, - struct berval *bdn, - int flags ) + struct berval *bdn ) { struct berval a; BerElement ber = *e->lm_ber; Attribute *attr, **attrp; const char *text; int last; - int private = flags & LDAP_BUILD_ENTRY_PRIVATE; /* safe assumptions ... */ assert( ent ); @@ -530,13 +515,7 @@ ldap_build_entry( * Note: attr->a_vals can be null when using * values result filter */ - if ( private ) { - attr->a_vals = (struct berval *)&slap_dummy_bv; - - } else { - attr->a_vals = ch_malloc( sizeof( struct berval ) ); - BER_BVZERO( &attr->a_vals[ 0 ] ); - } + attr->a_vals = (struct berval *)&slap_dummy_bv; last = 0; } else { @@ -708,7 +687,7 @@ retry: *ent = ch_calloc( 1, sizeof( Entry ) ); - rc = ldap_build_entry( op, e, *ent, &bdn, 0 ); + rc = ldap_build_entry( op, e, *ent, &bdn ); if ( rc != LDAP_SUCCESS ) { ch_free( *ent ); diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index d5113fb3f3..90abb9f6c7 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -942,24 +942,16 @@ meta_send_entry( send_search_entry( op, rs ); rs->sr_entry = NULL; rs->sr_attrs = NULL; - while ( ent.e_attrs ) { - attr = ent.e_attrs; - ent.e_attrs = attr->a_next; - if ( attr->a_vals != &slap_dummy_bv ) { - if ( attr->a_nvals != attr->a_vals ) { - ber_bvarray_free( attr->a_nvals ); - } - ber_bvarray_free( attr->a_vals ); - } - free( attr ); - } - if ( ent.e_dn && ent.e_dn != bdn.bv_val ) { - free( ent.e_dn ); + if ( !BER_BVISNULL( &ent.e_name ) && ent.e_name.bv_val != bdn.bv_val ) { + free( ent.e_name.bv_val ); + BER_BVZERO( &ent.e_name ); } - if ( ent.e_ndn ) { - free( ent.e_ndn ); + if ( !BER_BVISNULL( &ent.e_nname ) ) { + free( ent.e_nname.bv_val ); + BER_BVZERO( &ent.e_nname ); } + entry_clean( &ent ); return LDAP_SUCCESS; } diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index 4ff18d6573..b91ba2c17f 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -868,7 +868,7 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first, int stripEntryDN ) /* just count */ ; if ( last == 0 ) { - /* empty? for now, we leave it in place */ + /* empty? leave it in place because of attrsonly and vlv */ goto next_attr; } last--; -- 2.39.5