summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-07-16 13:44:13 +0300
committerAndrew Bartlett <abartlet@samba.org>2010-07-19 17:33:34 +1000
commit8d523d46f5dfcbf5a428fd75b908fe5bd738e62c (patch)
tree003739677caa7e0302c4964a82f55c6251bdcc5f /source4/lib/ldb
parenta95fd4ef647ed6d4c81ab862e08e7c42ee2fe0d6 (diff)
downloadsamba-8d523d46f5dfcbf5a428fd75b908fe5bd738e62c.tar.gz
samba-8d523d46f5dfcbf5a428fd75b908fe5bd738e62c.tar.bz2
samba-8d523d46f5dfcbf5a428fd75b908fe5bd738e62c.zip
s4-ldb: Add separate function to add empty element into ldb_msg
It just adds another element, nothing more. Caller is responsible to fill-in the added element and determine how to handle data allocation contexts. Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/common/ldb_msg.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index ca7b961953..444ba0a7f4 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -114,6 +114,36 @@ struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v)
return v2;
}
+/**
+ * Adds new empty element to msg->elements
+ */
+static int _ldb_msg_add_el(struct ldb_message *msg,
+ struct ldb_message_element **return_el)
+{
+ struct ldb_message_element *els;
+
+ /*
+ * TODO: Find out a way to assert on input parameters.
+ * msg and return_el must be valid
+ */
+
+ els = talloc_realloc(msg, msg->elements,
+ struct ldb_message_element, msg->num_elements + 1);
+ if (!els) {
+ errno = ENOMEM;
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ZERO_STRUCT(els[msg->num_elements]);
+
+ msg->elements = els;
+ msg->num_elements++;
+
+ *return_el = &els[msg->num_elements-1];
+
+ return LDB_SUCCESS;
+}
+
/*
add an empty element to a message
*/