]> git.sur5r.net Git - openldap/commitdiff
eliminate code duplication
authorPierangelo Masarati <ando@openldap.org>
Thu, 13 Aug 2009 21:24:32 +0000 (21:24 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 13 Aug 2009 21:24:32 +0000 (21:24 +0000)
servers/slapd/overlays/translucent.c

index f5d3cf8e380962f1e06d9880c805fbc8e271291d..102b909418bad93d21cea013ba89bc3bd0e6f71b 100644 (file)
@@ -281,22 +281,6 @@ void glue_parent(Operation *op) {
        return;
 }
 
-/*
-** dup_bervarray()
-**     copy a BerVarray;
-*/
-
-BerVarray dup_bervarray(BerVarray b) {
-       int i, len;
-       BerVarray nb;
-       for(len = 0; b[len].bv_val; len++);
-       nb = ch_malloc((len+1) * sizeof(BerValue));
-       for(i = 0; i < len; i++) ber_dupbv(&nb[i], &b[i]);
-       nb[len].bv_val = NULL;
-       nb[len].bv_len = 0;
-       return(nb);
-}
-
 /*
 ** free_attr_chain()
 **     free only the Attribute*, not the contents;
@@ -886,9 +870,12 @@ static int translucent_search_cb(Operation *op, SlapReply *rs) {
                                        if(a->a_vals != a->a_nvals)
                                                ber_bvarray_free(a->a_nvals);
                                        ber_bvarray_free(a->a_vals);
-                                       a->a_vals = dup_bervarray(ax->a_vals);
-                                       a->a_nvals = (ax->a_vals == ax->a_nvals) ?
-                                               a->a_vals : dup_bervarray(ax->a_nvals);
+                                       ber_bvarray_dup_x( &a->a_vals, ax->a_vals, NULL );
+                                       if ( ax->a_vals == ax->a_nvals ) {
+                                               a->a_nvals = a->a_vals;
+                                       } else {
+                                               ber_bvarray_dup_x( &a->a_nvals, ax->a_nvals, NULL );
+                                       }
                                        break;
                                }
                        }