* 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;
goto next_attr;
}
- for ( i = 0; i < last; i++ ) {
+ for ( i = 0; !BER_BVISNULL( &attr->a_vals[i] ); i++ ) {
struct berval pval;
int rc;
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 )
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 ) );
} else {
attr->a_nvals = attr->a_vals;
}
+ attr->a_numvals += count;
} else {
append = 1;
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++ )
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;
/* 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;
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 )
{
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 ) );
}
/* 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 ) {
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;
{
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;
(*ap)->a_vals[ j ] = (*ap)->a_vals[ last ];
}
BER_BVZERO( &(*ap)->a_vals[ last ] );
+ (*ap)->a_numvals--;
last--;
j--;
}
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) );
}
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 ) {
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 ) {
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 );
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;