svn commit: samba r2536 - in branches/SAMBA_4_0/source/torture/basic: .

abartlet at samba.org abartlet at samba.org
Wed Sep 22 22:06:21 GMT 2004


Author: abartlet
Date: 2004-09-22 22:06:21 +0000 (Wed, 22 Sep 2004)
New Revision: 2536

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/torture/basic&rev=2536&nolog=1

Log:
This is a classic case for the use of our new talloc code, and
convert_string_talloc().

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/torture/basic/charset.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/basic/charset.c
===================================================================
--- branches/SAMBA_4_0/source/torture/basic/charset.c	2004-09-22 21:50:49 UTC (rev 2535)
+++ branches/SAMBA_4_0/source/torture/basic/charset.c	2004-09-22 22:06:21 UTC (rev 2536)
@@ -40,8 +40,9 @@
 	int i;
 	NTSTATUS status;
 
-	ucs_name = malloc((1+u_name_len)*2);
+	ucs_name = talloc(NULL, (1+u_name_len)*2);
 	if (!ucs_name) {
+		printf("Failed to create UCS2 Name - talloc() failure\n");
 		return NT_STATUS_NO_MEMORY;
 	}
 
@@ -50,16 +51,16 @@
 	}
 	SSVAL(ucs_name, i*2, 0);
 
-	i = convert_string_allocate(CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname);
+	i = convert_string_talloc(ucs_name, CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname);
 	if (i == -1) {
-		free(ucs_name);
+		printf("Failed to convert UCS2 Name into unix - convert_string_talloc() failure\n");
+		talloc_free(ucs_name);
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	asprintf(&fname2, "%s%s", BASEDIR, fname);
+	fname2 = talloc_asprintf(ucs_name, "%s%s", BASEDIR, fname);
 	if (!fname2) {
-		free(fname);
-		free(ucs_name);
+		talloc_free(ucs_name);
 		return NT_STATUS_NO_MEMORY;
 	}
 
@@ -79,9 +80,7 @@
 
 	status = smb_raw_open(tree, mem_ctx, &io);
 
-	free(fname);
-	free(fname2);
-	free(ucs_name);
+	talloc_free(ucs_name);
 
 	return status;
 }



More information about the samba-cvs mailing list