#include "ldap_pvt.h"
#include "slap.h"
-#ifdef LDAP_DEBUG
-static void at_index_print( void )
-{
-}
-#endif
-
void
attr_free( Attribute *a )
{
ber_bvarray_free( a->a_vals );
#ifdef SLAP_NVALUES
- ber_bvarray_free( a->a_nvals );
+ if (a->a_nvals != a->a_vals) ber_bvarray_free( a->a_nvals );
#endif
free( a );
}
tmp->a_vals[i].bv_val = NULL;
#ifdef SLAP_NVALUES
- if( a->a_nvals != NULL ) {
+ if( a->a_nvals != a->a_vals ) {
tmp->a_nvals = ch_malloc((i+1) * sizeof(struct berval));
for( i=0; a->a_nvals[i].bv_val != NULL; i++ ) {
ber_dupbv( &tmp->a_nvals[i], &a->a_nvals[i] );
tmp->a_nvals[i].bv_val = NULL;
} else {
- tmp->a_nvals = NULL;
+ tmp->a_nvals = tmp->a_vals;
}
#endif
/*
* attr_merge - merge the given type and value with the list of
* attributes in attrs.
+ *
+ * For SLAP_NVALUES: nvals must be NULL if the attribute has no
+ * normalizer. In this case, a->a_nvals will be set equal to a->a_vals.
+ *
* returns 0 everything went ok
* -1 trouble
*/
#ifdef SLAP_NVALUES
if( !rc && nvals ) rc = value_add( &(*a)->a_nvals, nvals );
+ else (*a)->a_nvals = (*a)->a_vals;
#endif
return rc;
AttributeDescription *desc,
struct berval *val
#ifdef SLAP_NVALUES
- , BerVarray nval
+ , struct berval *nval
#endif
) {
int rc;
#ifdef SLAP_NVALUES
if( !rc && nval ) rc = value_add_one( &(*a)->a_nvals, nval );
+ else (*a)->a_nvals = (*a)->a_vals;
#endif
return rc;
}