More for a_numvals

This commit is contained in:
Howard Chu 2007-09-23 04:40:16 +00:00
parent 148afe6aa0
commit a3547e2758
11 changed files with 19 additions and 50 deletions

View file

@ -676,13 +676,7 @@ ldap_build_entry(
* values result filter
*/
attr->a_vals = (struct berval *)&slap_dummy_bv;
last = 0;
} else {
for ( last = 0; !BER_BVISNULL( &attr->a_vals[ last ] ); last++ )
/* just count vals */ ;
}
attr->a_numvals = last;
validate = attr->a_desc->ad_type->sat_syntax->ssyn_validate;
pretty = attr->a_desc->ad_type->sat_syntax->ssyn_pretty;
@ -693,7 +687,7 @@ ldap_build_entry(
goto next_attr;
}
for ( i = 0; i < last; i++ ) {
for ( i = 0; !BER_BVISNULL( &attr->a_vals[i] ); i++ ) {
struct berval pval;
int rc;
@ -725,6 +719,7 @@ ldap_build_entry(
attr->a_vals[i] = pval;
}
}
attr->a_numvals = last = i;
if ( last && attr->a_desc->ad_type->sat_equality &&
attr->a_desc->ad_type->sat_equality->smr_normalize )

View file

@ -617,8 +617,7 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
BerVarray tmp;
if ( attr->a_vals != NULL ) {
for ( ; !BER_BVISNULL( &attr->a_vals[ oldcount ] ); oldcount++ )
/* just count */ ;
oldcount = attr->a_numvals;
}
tmp = ch_realloc( attr->a_vals, ( oldcount + count + 1 ) * sizeof( struct berval ) );
@ -639,6 +638,7 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
} else {
attr->a_nvals = attr->a_vals;
}
attr->a_numvals += count;
} else {
append = 1;

View file

@ -1648,9 +1648,7 @@ fe_acl_attribute(
goto freeit;
}
for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ )
;
i = a->a_numvals;
v = op->o_tmpalloc( sizeof(struct berval) * ( i + 1 ),
op->o_tmpmemctx );
for ( i = 0, j = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ )

View file

@ -212,12 +212,7 @@ static int test_mra_filter(
if ( mra->ma_cf && mra->ma_rule->smr_usage & SLAP_MR_COMPONENT ) {
num_attr_vals = 0;
if ( !a->a_comp_data ) {
for ( ;
!BER_BVISNULL( &a->a_vals[num_attr_vals] );
num_attr_vals++ )
{
/* empty */;
}
num_attr_vals = a->a_numvals;
if ( num_attr_vals <= 0 ) {
/* no attribute value */
return LDAP_INAPPROPRIATE_MATCHING;

View file

@ -1365,11 +1365,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
/* count all the vals */
i = 0;
for ( a=e2->e_attrs; a; a=a->a_next ) {
if ( a->a_vals ) {
for (b=a->a_vals; !BER_BVISNULL( b ); b++) {
i++;
}
}
i += a->a_numvals;
}
vals = ch_malloc( (i+1) * sizeof( struct berval ));
i = 0;
@ -1396,9 +1392,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
i = 0;
for ( m = op->orm_modlist; m; m = m->sml_next ) {
if ( m->sml_values ) {
for ( b = m->sml_values; !BER_BVISNULL( b ); b++ ) {
i++;
}
i += m->sml_numvals;
} else if ( m->sml_op == LDAP_MOD_DELETE ||
m->sml_op == LDAP_MOD_REPLACE )
{
@ -1494,9 +1488,7 @@ static int accesslog_response(Operation *op, SlapReply *rs) {
i = 0;
for ( a = old->e_attrs; a != NULL; a = a->a_next ) {
if ( a->a_vals && a->a_flags ) {
for ( b = a->a_vals; !BER_BVISNULL( b ); b++ ) {
i++;
}
i += a->a_numvals;
}
}
vals = ch_malloc( (i + 1) * sizeof( struct berval ) );

View file

@ -248,8 +248,7 @@ dynlist_sc_update( Operation *op, SlapReply *rs )
}
/* test access to attribute */
for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ )
/* just count */ ;
i = a->a_numvals;
vals = op->o_tmpalloc( ( i + 1 ) * sizeof( struct berval ), op->o_tmpmemctx );
if ( a->a_nvals != a->a_vals ) {

View file

@ -1367,8 +1367,7 @@ remove_func (
attr = attr_find( rs->sr_entry->e_attrs, ad_queryId );
if ( attr == NULL ) return 0;
for ( count = 0; !BER_BVISNULL( &attr->a_vals[count] ); count++ )
;
count = attr->a_numvals;
assert( count > 0 );
qi = op->o_tmpalloc( sizeof( struct query_info ), op->o_tmpmemctx );
qi->next = op->o_callback->sc_private;

View file

@ -226,9 +226,7 @@ rwm_op_add( Operation *op, SlapReply *rs )
{
int j, last;
for ( last = 0; !BER_BVISNULL( &(*ap)->a_vals[ last ] ); last++ )
/* count values */ ;
last--;
last = (*ap)->a_numvals - 1;
for ( j = 0; !BER_BVISNULL( &(*ap)->a_vals[ j ] ); j++ ) {
struct ldapmapping *mapping = NULL;
@ -245,6 +243,7 @@ rwm_op_add( Operation *op, SlapReply *rs )
(*ap)->a_vals[ j ] = (*ap)->a_vals[ last ];
}
BER_BVZERO( &(*ap)->a_vals[ last ] );
(*ap)->a_numvals--;
last--;
j--;
}
@ -1054,9 +1053,8 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first, int stripEntryDN )
mapping->m_dst_ad->ad_type->sat_equality->smr_normalize )
{
int i = 0;
for ( last = 0; !BER_BVISNULL( &(*ap)->a_vals[last] ); last++ )
/* just count */ ;
last = (*ap)->a_numvals;
if ( last )
{
(*ap)->a_nvals = ch_malloc( (last+1) * sizeof(struct berval) );
@ -1105,8 +1103,7 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first, int stripEntryDN )
}
if ( last == -1 ) { /* not yet counted */
for ( last = 0; !BER_BVISNULL( &(*ap)->a_vals[last] ); last++ )
/* just count */ ;
last = (*ap)->a_numvals;
}
if ( last == 0 ) {

View file

@ -2554,11 +2554,9 @@ syncprov_db_open(
a = attr_find( e->e_attrs, slap_schema.si_ad_contextCSN );
if ( a ) {
int i;
ber_bvarray_dup_x( &si->si_ctxcsn, a->a_vals, NULL );
for ( i = 0; !BER_BVISNULL( &a->a_vals[i] ); i++ );
si->si_numcsns = i;
si->si_sids = slap_parse_csn_sids( si->si_ctxcsn, i, NULL );
si->si_numcsns = a->a_numvals;
si->si_sids = slap_parse_csn_sids( si->si_ctxcsn, a->a_numvals, NULL );
}
overlay_entry_release_ov( op, e, 0, on );
if ( si->si_ctxcsn ) {

View file

@ -304,9 +304,7 @@ valsort_response( Operation *op, SlapReply *rs )
a = attr_find( rs->sr_entry->e_attrs, vi->vi_ad );
}
/* count values */
for ( n = 0; !BER_BVISNULL( &a->a_vals[n] ); n++ );
n = a->a_numvals;
if ( vi->vi_sort & VALSORT_WEIGHTED ) {
int j, gotnvals;
long *index = op->o_tmpalloc( n * sizeof(long), op->o_tmpmemctx );

View file

@ -562,9 +562,7 @@ do_syncrep1(
ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
rc = backend_operational( op, &rs );
if ( rc == LDAP_SUCCESS && a.a_vals ) {
int num;
for (i=0; !BER_BVISNULL( &a.a_vals[i] ); i++) ;
num = i;
int num = a.a_numvals;
/* check for differences */
if ( num != si->si_cookieState->cs_num ) {
changed = 1;