summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-09-18 13:41:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:06:55 -0500
commitc364bbbfa3441f40e3bcab76392d998163e7bf76 (patch)
tree2a01f02fa79607a784c442ee34359fd2468c71a3 /source4/lib/ldb/common
parentdf7fbf8cfdcf679d2dd48818176068dd9ad97ab6 (diff)
downloadsamba-c364bbbfa3441f40e3bcab76392d998163e7bf76.tar.gz
samba-c364bbbfa3441f40e3bcab76392d998163e7bf76.tar.bz2
samba-c364bbbfa3441f40e3bcab76392d998163e7bf76.zip
r25215: replace talloc_append_string() with talloc_strdup_append_buffer()
metze (This used to be commit 8f2db3c130ce85d38f805836a7df039822ede066)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb_dn.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 41e70cffd1..f0bd72e009 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -1279,6 +1279,7 @@ static char *ldb_dn_canonical(void *mem_ctx, struct ldb_dn *dn, int ex_format) {
int i;
TALLOC_CTX *tmpctx;
char *cracked = NULL;
+ const char *format = (ex_format ? "\n" : "/" );
if ( ! ldb_dn_validate(dn)) {
return NULL;
@@ -1305,32 +1306,23 @@ static char *ldb_dn_canonical(void *mem_ctx, struct ldb_dn *dn, int ex_format) {
/* Only domain components? Finish here */
if (i < 0) {
- if (ex_format) {
- cracked = talloc_append_string(tmpctx, cracked, "\n");
- } else {
- cracked = talloc_append_string(tmpctx, cracked, "/");
- }
+ cracked = talloc_strdup_append_buffer(cracked, format);
talloc_steal(mem_ctx, cracked);
goto done;
}
/* Now walk backwards appending remaining components */
for (; i > 0; i--) {
- cracked = talloc_asprintf_append(cracked, "/%s",
- ldb_dn_escape_value(tmpctx, dn->components[i].value));
+ cracked = talloc_asprintf_append_buffer(cracked, "/%s",
+ ldb_dn_escape_value(tmpctx, dn->components[i].value));
if (!cracked) {
goto done;
}
}
/* Last one, possibly a newline for the 'ex' format */
- if (ex_format) {
- cracked = talloc_asprintf_append(cracked, "\n%s",
- ldb_dn_escape_value(tmpctx, dn->components[i].value));
- } else {
- cracked = talloc_asprintf_append(cracked, "/%s",
- ldb_dn_escape_value(tmpctx, dn->components[i].value));
- }
+ cracked = talloc_asprintf_append_buffer(cracked, "%s%s", format,
+ ldb_dn_escape_value(tmpctx, dn->components[i].value));
talloc_steal(mem_ctx, cracked);
done: