mirror of
https://github.com/samba-team/samba.git
synced 2025-01-14 19:24:43 +03:00
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>
This commit is contained in:
parent
a95fd4ef64
commit
8d523d46f5
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user