+ Modifications *modhead = NULL;
+ Modifications *mod;
+ Modifications **modtail = &modhead;
+ Attribute *a_new;
+ AttributeDescription *a_new_desc;
+ int i, count, rc;
+
+ a_new = e->e_attrs;
+
+ while ( a_new != NULL ) {
+ a_new_desc = a_new->a_desc;
+ mod = (Modifications *) malloc( sizeof( Modifications ));
+
+ if ( a_new_desc != slap_schema.si_ad_queryid )
+ mod->sml_op = LDAP_MOD_REPLACE;
+ else
+ mod->sml_op = LDAP_MOD_ADD;
+
+ ber_dupbv( &mod->sml_type, &a_new_desc->ad_cname );
+
+ for ( count = 0; a_new->a_vals[count].bv_val; count++ );
+
+ mod->sml_bvalues = (struct berval*) malloc(
+ (count+1) * sizeof( struct berval) );
+
+ /* see slap_mods_check() comments...
+ * if a_vals == a_nvals, there is no normalizer.
+ * in this case, mod->sml_nvalues must be left NULL.
+ */
+ if ( a_new->a_vals != a_new->a_nvals ) {
+ mod->sml_nvalues = (struct berval*) malloc(
+ (count+1) * sizeof( struct berval) );
+ } else {
+ mod->sml_nvalues = NULL;
+ }