]> git.sur5r.net Git - openldap/commitdiff
More for a_numvals
authorHoward Chu <hyc@openldap.org>
Sun, 23 Sep 2007 04:40:16 +0000 (04:40 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 23 Sep 2007 04:40:16 +0000 (04:40 +0000)
servers/slapd/back-ldap/search.c
servers/slapd/back-sql/entry-id.c
servers/slapd/backend.c
servers/slapd/filterentry.c
servers/slapd/overlays/accesslog.c
servers/slapd/overlays/dynlist.c
servers/slapd/overlays/pcache.c
servers/slapd/overlays/rwm.c
servers/slapd/overlays/syncprov.c
servers/slapd/overlays/valsort.c
servers/slapd/syncrepl.c

index 69d03ce0a26e4f3dafec7ecb563390ece1ccb452..3d23276bf1d1f48a7f8edad17a5b9d4207283a68 100644 (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 )
index 2f8b93820da1aac0ebe5d228500d2f243ad63461..f61fc5c8640f03cadb32e7450c7dee7af504ad9d 100644 (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;
index 3d83060f557712d26bca64b69ec5a54457a18994..eb766d349d95ebec6bd6389a7818b9ec87915d22 100644 (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++ )
index d1fb4856e30cf5bb8162656713bebaa912e3a9dc..7d5fabfbc3d7ab88c2bdcf8fcf9cea958816e3c8 100644 (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;
index 646c9a8d1ffa34639986ab8258ce3b5e9e952772..e0b0e8bb024dd01c5181d9f98b5bddee7803da7a 100644 (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 ) );
index 965b6b553540219219b87a89f2cf917b8e16aa5c..7e8a50ca3be46dadc7085581c589d21d2ebed3ae 100644 (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 ) {
index 71e04db825d56d34303df1d6b5aaf11bc6d9d9eb..5506c22e3a8d70974ec5b5d8c064ac1ffc40a280 100644 (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;
index 47068cda38926bd67af0ca8c26c402082b059eea..1afb4654f31bc914093c747a0f91ec2d7d4b1fea 100644 (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 ) {
index 8a3c6817b154b0525f860109be8d5449d5d0d450..72d2b330cc81b9ccd0a8c2c281b18dd71407d9f7 100644 (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 ) {
index 5950a208c40b4e09a960901f360fcddbf3ddc2ee..5cc06cfaf0acdbe7d4300c826e438f9f82cbe722 100644 (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 );
index 86a81f32d37018d0eaca7001a19bdc54c1c72c2a..2ab959c8589c8a415422cb0f6053c1e3934c5beb 100644 (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;