summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/tools/ldbedit.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-05-06 04:40:15 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:45 -0500
commitd8ce7c6a2acbf371509a23775470e7614bcb6027 (patch)
tree3b0d2157dc855a17a6e7f0ace37cddfb60dfdb04 /source4/lib/ldb/tools/ldbedit.c
parent3aa278b873c5d06a279e0e65a96d6e6b42b64583 (diff)
downloadsamba-d8ce7c6a2acbf371509a23775470e7614bcb6027.tar.gz
samba-d8ce7c6a2acbf371509a23775470e7614bcb6027.tar.bz2
samba-d8ce7c6a2acbf371509a23775470e7614bcb6027.zip
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)
Diffstat (limited to 'source4/lib/ldb/tools/ldbedit.c')
-rw-r--r--source4/lib/ldb/tools/ldbedit.c17
1 files changed, 9 insertions, 8 deletions
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;i<msg1->num_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;