From d8ce7c6a2acbf371509a23775470e7614bcb6027 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 May 2004 04:40:15 +0000 Subject: r502: modified ldb to allow the use of an external pool memory allocator. The way to use this is to call ldb_set_alloc() with a function pointer to whatever memory allocator you like. It includes a context pointer to allow for pool based allocators. (This used to be commit 3955c482e6c2c9e975a4bb809ec8cb6068e48e34) --- source4/lib/ldb/tools/ldbedit.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/tools/ldbedit.c') diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index eb95ed3267..57c54cad40 100644 --- a/source4/lib/ldb/tools/ldbedit.c +++ b/source4/lib/ldb/tools/ldbedit.c @@ -60,7 +60,7 @@ static int modify_record(struct ldb_context *ldb, continue; } - if (ldb_msg_add(&mod, + if (ldb_msg_add(ldb, &mod, &msg2->elements[i], el?LDB_FLAG_MOD_REPLACE:LDB_FLAG_MOD_ADD) != 0) { return -1; @@ -72,7 +72,7 @@ static int modify_record(struct ldb_context *ldb, for (i=0;inum_elements;i++) { el = ldb_msg_find_element(msg2, msg1->elements[i].name); if (!el) { - if (ldb_msg_add_empty(&mod, + if (ldb_msg_add_empty(ldb, &mod, msg1->elements[i].name, LDB_FLAG_MOD_DELETE) != 0) { return -1; @@ -159,7 +159,8 @@ static int merge_edits(struct ldb_context *ldb, /* save a set of messages as ldif to a file */ -static int save_ldif(FILE *f, struct ldb_message **msgs, int count) +static int save_ldif(struct ldb_context *ldb, + FILE *f, struct ldb_message **msgs, int count) { int i; @@ -172,7 +173,7 @@ static int save_ldif(FILE *f, struct ldb_message **msgs, int count) ldif.changetype = LDB_CHANGETYPE_NONE; ldif.msg = *msgs[i]; - ldif_write_file(f, &ldif); + ldif_write_file(ldb, f, &ldif); } return 0; @@ -211,13 +212,13 @@ static int do_edit(struct ldb_context *ldb, struct ldb_message **msgs1, int coun return -1; } - if (save_ldif(f, msgs1, count1) != 0) { + if (save_ldif(ldb, f, msgs1, count1) != 0) { return -1; } fclose(f); - asprintf(&cmd, "%s %s", editor, template); + ldb_asprintf(ldb, &cmd, "%s %s", editor, template); if (!cmd) { unlink(template); @@ -242,8 +243,8 @@ static int do_edit(struct ldb_context *ldb, struct ldb_message **msgs1, int coun return -1; } - while ((ldif = ldif_read_file(f))) { - msgs2 = realloc_p(msgs2, struct ldb_message *, count2+1); + while ((ldif = ldif_read_file(ldb, f))) { + msgs2 = ldb_realloc_p(ldb, msgs2, struct ldb_message *, count2+1); if (!msgs2) { fprintf(stderr, "out of memory"); return -1; -- cgit