summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-07-16 13:46:05 +0300
committerAndrew Bartlett <abartlet@samba.org>2010-07-19 17:33:34 +1000
commit3944c81d08177e7fa360b1925648686c729e2773 (patch)
treef38f503f70a7dd08d8d4da5bf3315914443dba3b
parent8d523d46f5dfcbf5a428fd75b908fe5bd738e62c (diff)
downloadsamba-3944c81d08177e7fa360b1925648686c729e2773.tar.gz
samba-3944c81d08177e7fa360b1925648686c729e2773.tar.bz2
samba-3944c81d08177e7fa360b1925648686c729e2773.zip
s4-ldb: Use _ldb_msg_add_el() in ldb_msg_add_empty()
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
-rw-r--r--source4/lib/ldb/common/ldb_msg.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index 444ba0a7f4..5681d5228e 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -144,37 +144,32 @@ static int _ldb_msg_add_el(struct ldb_message *msg,
return LDB_SUCCESS;
}
-/*
- add an empty element to a message
-*/
-int ldb_msg_add_empty( struct ldb_message *msg,
- const char *attr_name,
- int flags,
- struct ldb_message_element **return_el)
+/**
+ * Add an empty element with a given name to a message
+ */
+int ldb_msg_add_empty(struct ldb_message *msg,
+ const char *attr_name,
+ int flags,
+ struct ldb_message_element **return_el)
{
- struct ldb_message_element *els;
+ int ret;
+ struct ldb_message_element *el;
- els = talloc_realloc(msg, msg->elements,
- struct ldb_message_element, msg->num_elements+1);
- if (!els) {
- errno = ENOMEM;
- return LDB_ERR_OPERATIONS_ERROR;
+ ret = _ldb_msg_add_el(msg, &el);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
- els[msg->num_elements].values = NULL;
- els[msg->num_elements].num_values = 0;
- els[msg->num_elements].flags = flags;
- els[msg->num_elements].name = talloc_strdup(els, attr_name);
- if (!els[msg->num_elements].name) {
+ /* initialize newly added element */
+ el->flags = flags;
+ el->name = talloc_strdup(msg->elements, attr_name);
+ if (!el->name) {
errno = ENOMEM;
return LDB_ERR_OPERATIONS_ERROR;
}
- msg->elements = els;
- msg->num_elements++;
-
if (return_el) {
- *return_el = &els[msg->num_elements-1];
+ *return_el = el;
}
return LDB_SUCCESS;