/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2011 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/* assign new indexes to an attribute's ordered values */
void
-ordered_value_renumber( Attribute *a, int vals )
+ordered_value_renumber( Attribute *a )
{
char *ptr, ibuf[64]; /* many digits */
struct berval ibv, tmp, vtmp;
- int i;
+ unsigned i;
ibv.bv_val = ibuf;
- for (i=0; i<vals; i++) {
- ibv.bv_len = sprintf(ibv.bv_val, "{%d}", i);
+ for (i=0; i<a->a_numvals; i++) {
+ ibv.bv_len = sprintf(ibv.bv_val, "{%u}", i);
vtmp = a->a_vals[i];
if ( vtmp.bv_val[0] == '{' ) {
ptr = ber_bvchr(&vtmp, '}');
}
if ( do_renumber && renumber )
- ordered_value_renumber( a, vals );
+ ordered_value_renumber( a );
return 0;
}
struct berval *out,
void *ctx )
{
- struct berval bv = *val,
+ struct berval bv,
idx = BER_BVNULL;
int rc;
assert( val != NULL );
assert( out != NULL );
+ bv = *val;
+
if ( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) {
/* Skip past the assertion index */
struct berval *normalized,
void *ctx )
{
- struct berval bv = *val,
+ struct berval bv,
idx = BER_BVNULL;
int rc;
assert( val != NULL );
assert( normalized != NULL );
+ bv = *val;
+
if ( ad->ad_type->sat_flags & SLAP_AT_ORDERED ) {
/* Skip past the assertion index */
vnum = i;
if ( a ) {
- for (i=0; !BER_BVISNULL( a->a_vals+i ); i++) ;
- anum = i;
ordered_value_sort( a, 0 );
} else {
Attribute **ap;
- anum = 0;
for ( ap=&e->e_attrs; *ap; ap = &(*ap)->a_next ) ;
a = attr_alloc( ad );
*ap = a;
}
+ anum = a->a_numvals;
new = ch_malloc( (anum+vnum+1) * sizeof(struct berval));
}
if ( anum ) {
AC_MEMCPY( new, a->a_vals, anum * sizeof(struct berval));
- if ( nnew )
+ if ( nnew && a->a_nvals )
AC_MEMCPY( nnew, a->a_nvals, anum * sizeof(struct berval));
}
k = strtol( vals[i].bv_val + 1, &next, 0 );
if ( next == vals[i].bv_val + 1 ||
next[ 0 ] != '}' ||
- next - vals[i].bv_val > vals[i].bv_len )
+ (ber_len_t) (next - vals[i].bv_val) > vals[i].bv_len )
{
ch_free( nnew );
ch_free( new );
a->a_nvals = a->a_vals;
}
- ordered_value_renumber( a, anum );
+ a->a_numvals = anum;
+ ordered_value_renumber( a );
return 0;
}