svn commit: samba r25215 - in branches/SAMBA_4_0/source/lib/ldb: common ldb_tdb

metze at samba.org metze at samba.org
Tue Sep 18 13:41:50 GMT 2007


Author: metze
Date: 2007-09-18 13:41:50 +0000 (Tue, 18 Sep 2007)
New Revision: 25215

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25215

Log:
replace talloc_append_string() with talloc_strdup_append_buffer()

metze
Modified:
   branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c	2007-09-18 13:33:44 UTC (rev 25214)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_dn.c	2007-09-18 13:41:50 UTC (rev 25215)
@@ -1279,6 +1279,7 @@
 	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 @@
 
 	/* 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:

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c	2007-09-18 13:33:44 UTC (rev 25214)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c	2007-09-18 13:41:50 UTC (rev 25215)
@@ -145,7 +145,7 @@
 		goto failed;
 	}
 
-	key_str = talloc_append_string(ldb, key_str, dn_folded);
+	key_str = talloc_strdup_append_buffer(key_str, dn_folded);
 	if (!key_str) {
 		goto failed;
 	}



More information about the samba-cvs mailing list