r17301: Add a new function to copy a list of attributes, while adding one to
authorAndrew Bartlett <abartlet@samba.org>
Sat, 29 Jul 2006 01:23:50 +0000 (01:23 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:15:08 +0000 (14:15 -0500)
the end.

Andrew Bartlett
(This used to be commit 2a87ed1111f4ed72798372d6005a88a929c39de6)

source4/lib/ldb/common/ldb_msg.c

index 797d050975ca44a559dff88d206696e7782901fc..254775cfbc23bb6c62017810b07223ad2d9c2432 100644 (file)
@@ -610,6 +610,28 @@ const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs)
 }
 
 
+/*
+  copy an attribute list. This only copies the array, not the elements
+  (ie. the elements are left as the same pointers)
+*/
+const char **ldb_attr_list_copy_add(TALLOC_CTX *mem_ctx, const char * const *attrs, const char *new_attr)
+{
+       const char **ret;
+       int i;
+       for (i=0;attrs[i];i++) /* noop */ ;
+       ret = talloc_array(mem_ctx, const char *, i+2);
+       if (ret == NULL) {
+               return NULL;
+       }
+       for (i=0;attrs[i];i++) {
+               ret[i] = attrs[i];
+       }
+       ret[i] = new_attr;
+       ret[i+1] = NULL;
+       return ret;
+}
+
+
 /*
   return 1 if an attribute is in a list of attributes, or 0 otherwise
 */