From 09b861f45ba2354edee85ccc966e3b3ee62e02e0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 29 Jul 2006 01:23:50 +0000 Subject: r17301: Add a new function to copy a list of attributes, while adding one to the end. Andrew Bartlett (This used to be commit 2a87ed1111f4ed72798372d6005a88a929c39de6) --- source4/lib/ldb/common/ldb_msg.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source4/lib/ldb') diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c index 797d050975..254775cfbc 100644 --- a/source4/lib/ldb/common/ldb_msg.c +++ b/source4/lib/ldb/common/ldb_msg.c @@ -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 */ -- cgit