summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/ldb_tdb/ldb_pack.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-01-02 07:49:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:07:55 -0500
commit1a988ec9af7960616fb4661b20d86ff05146d836 (patch)
tree725eb92b6b97133b23972215f5c69117e29c339c /source4/lib/ldb/ldb_tdb/ldb_pack.c
parent65f96eba32b93ced0717c2639007bba59da55fa4 (diff)
downloadsamba-1a988ec9af7960616fb4661b20d86ff05146d836.tar.gz
samba-1a988ec9af7960616fb4661b20d86ff05146d836.tar.bz2
samba-1a988ec9af7960616fb4661b20d86ff05146d836.zip
r4474: - converted ldb to use talloc internally
- added gcov flags to Makefile.ldb - expanded ldb test suite to get more coverage (This used to be commit 0ab98f50a7e0fe15347a99e5c29a6590a87729a0)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb/ldb_pack.c')
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_pack.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c
index 9515beeaa7..a548a4189b 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_pack.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c
@@ -99,7 +99,7 @@ int ltdb_pack_data(struct ldb_module *module,
}
/* allocate it */
- data->dptr = ldb_malloc(ldb, size);
+ data->dptr = talloc_array_p(ldb, char, size);
if (!data->dptr) {
errno = ENOMEM;
return -1;
@@ -144,25 +144,14 @@ int ltdb_pack_data(struct ldb_module *module,
void ltdb_unpack_data_free(struct ldb_module *module,
struct ldb_message *message)
{
- struct ldb_context *ldb = module->ldb;
- unsigned int i;
-
- for (i=0;i<message->num_elements;i++) {
- if (message->elements[i].values) ldb_free(ldb, message->elements[i].values);
- }
- if (message->elements) ldb_free(ldb, message->elements);
+ talloc_free(message->elements);
}
/*
unpack a ldb message from a linear buffer in TDB_DATA
- note that this does not fill in the class and key elements
-
- caller frees. Memory for the elements[] and values[] arrays are
- malloced, but the memory for the elements is re-used from the
- TDB_DATA data. This means the caller only has to free the elements
- and values arrays. This can be done with ltdb_unpack_data_free()
+ Free with ltdb_unpack_data_free()
*/
int ltdb_unpack_data(struct ldb_module *module,
const struct TDB_DATA *data,
@@ -220,8 +209,7 @@ int ltdb_unpack_data(struct ldb_module *module,
goto failed;
}
- message->elements = ldb_malloc_array_p(ldb, struct ldb_message_element,
- message->num_elements);
+ message->elements = talloc_array_p(ldb, struct ldb_message_element, message->num_elements);
if (!message->elements) {
errno = ENOMEM;
goto failed;
@@ -247,9 +235,9 @@ int ltdb_unpack_data(struct ldb_module *module,
message->elements[i].num_values = pull_uint32(p, 0);
message->elements[i].values = NULL;
if (message->elements[i].num_values != 0) {
- message->elements[i].values = ldb_malloc_array_p(ldb,
- struct ldb_val,
- message->elements[i].num_values);
+ message->elements[i].values = talloc_array_p(message->elements,
+ struct ldb_val,
+ message->elements[i].num_values);
if (!message->elements[i].values) {
errno = ENOMEM;
goto failed;