]> git.sur5r.net Git - openldap/commitdiff
rework of slap_mods2entry dup
authorJong Hyuk Choi <jongchoi@openldap.org>
Fri, 24 Sep 2004 08:19:50 +0000 (08:19 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Fri, 24 Sep 2004 08:19:50 +0000 (08:19 +0000)
servers/slapd/add.c

index d4f6b6b914eb0457ab28027e8b5cf419af281110..086efa4ba7ce1434e327f6161a060dbbb79973d5 100644 (file)
@@ -422,24 +422,32 @@ slap_mods2entry(
 
                        /* should check for duplicates */
 
-                       AC_MEMCPY( &attr->a_vals[i], mods->sml_values,
-                               sizeof( struct berval ) * j );
-
-                       /* trim the mods array */
-                       ch_free( mods->sml_values );
-                       mods->sml_values = NULL;
+                       if ( dup ) {
+                               for ( j = 0; mods->sml_values[j].bv_val; j++ ) {
+                                       ber_dupbv( &attr->a_vals[i+j], &mods->sml_values[j] );
+                               }
+                               BER_BVZERO( &attr->a_vals[i+j] );       
+                       } else {
+                               AC_MEMCPY( &attr->a_vals[i], mods->sml_values,
+                                       sizeof( struct berval ) * j );
+                               ch_free( mods->sml_values );
+                               mods->sml_values = NULL;
+                       }
 
                        if( mods->sml_nvalues ) {
                                attr->a_nvals = ch_realloc( attr->a_nvals,
                                        sizeof( struct berval ) * (i+j) );
-
-                               AC_MEMCPY( &attr->a_nvals[i], mods->sml_nvalues,
-                                       sizeof( struct berval ) * j );
-
-                               /* trim the mods array */
-                               ch_free( mods->sml_nvalues );
-                               mods->sml_nvalues = NULL;
-
+                               if ( dup ) {
+                                       for ( j = 0; mods->sml_nvalues[j].bv_val; j++ ) {
+                                               ber_dupbv( &attr->a_nvals[i+j], &mods->sml_nvalues[j] );
+                                       }
+                                       BER_BVZERO( &attr->a_nvals[i+j] );      
+                               } else {
+                                       AC_MEMCPY( &attr->a_nvals[i], mods->sml_nvalues,
+                                               sizeof( struct berval ) * j );
+                                       ch_free( mods->sml_nvalues );
+                                       mods->sml_nvalues = NULL;
+                               }
                        } else {
                                attr->a_nvals = attr->a_vals;
                        }