summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-22 10:58:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:57 -0500
commit2c457eca252fd62a3429ca3db172b85c534bd2d7 (patch)
treeac3e5d3205748f6661fe7af4b936026029dede39
parentf4691cf6f64644d48d895b9aaa7cd9b2faae4ffc (diff)
downloadsamba-2c457eca252fd62a3429ca3db172b85c534bd2d7.tar.gz
samba-2c457eca252fd62a3429ca3db172b85c534bd2d7.tar.bz2
samba-2c457eca252fd62a3429ca3db172b85c534bd2d7.zip
r8712: cleanup old search test code to use talloc
(This used to be commit 1d830bcd473a2166b6f89281faabb001697e35d4)
-rw-r--r--source4/torture/raw/search.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c
index cb6cf6336e..235ce81660 100644
--- a/source4/torture/raw/search.c
+++ b/source4/torture/raw/search.c
@@ -625,14 +625,14 @@ static BOOL test_many_files(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("Creating %d files\n", num_files);
for (i=0;i<num_files;i++) {
- asprintf(&fname, BASEDIR "\\t%03d-%d.txt", i, i);
+ fname = talloc_asprintf(cli, BASEDIR "\\t%03d-%d.txt", i, i);
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
- free(fname);
+ talloc_free(fname);
smbcli_close(cli->tree, fnum);
}
@@ -685,13 +685,13 @@ static BOOL test_many_files(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
} else {
s = result.list[i].search.name;
}
- asprintf(&fname, "t%03d-%d.txt", i, i);
+ fname = talloc_asprintf(cli, "t%03d-%d.txt", i, i);
if (strcmp(fname, s)) {
printf("Incorrect name %s at entry %d\n", s, i);
ret = False;
break;
}
- free(fname);
+ talloc_free(fname);
}
talloc_free(result.mem_ctx);
}
@@ -758,14 +758,14 @@ static BOOL test_modify_search(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("Creating %d files\n", num_files);
for (i=num_files-1;i>=0;i--) {
- asprintf(&fname, BASEDIR "\\t%03d-%d.txt", i, i);
+ fname = talloc_asprintf(cli, BASEDIR "\\t%03d-%d.txt", i, i);
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
- free(fname);
+ talloc_free(fname);
smbcli_close(cli->tree, fnum);
}
@@ -876,14 +876,14 @@ static BOOL test_sorted(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("Creating %d files\n", num_files);
for (i=0;i<num_files;i++) {
- asprintf(&fname, BASEDIR "\\%s.txt", generate_random_str_list(mem_ctx, 10, "abcdefgh"));
+ fname = talloc_asprintf(cli, BASEDIR "\\%s.txt", generate_random_str_list(mem_ctx, 10, "abcdefgh"));
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
- free(fname);
+ talloc_free(fname);
smbcli_close(cli->tree, fnum);
}
@@ -939,7 +939,7 @@ static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("Creating %d dirs\n", num_dirs);
for (i=0;i<num_dirs;i++) {
- asprintf(&dname, BASEDIR "\\d%d", i);
+ dname = talloc_asprintf(cli, BASEDIR "\\d%d", i);
status = smbcli_mkdir(cli->tree, dname);
if (!NT_STATUS_IS_OK(status)) {
printf("(%s) Failed to create %s - %s\n",
@@ -949,7 +949,7 @@ static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
}
for (n=0;n<3;n++) {
- asprintf(&fname, BASEDIR "\\d%d\\f%d-%d.txt", i, i, n);
+ fname = talloc_asprintf(cli, BASEDIR "\\d%d\\f%d-%d.txt", i, i, n);
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
printf("(%s) Failed to create %s - %s\n",
@@ -957,11 +957,11 @@ static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
ret = False;
goto done;
}
- free(fname);
+ talloc_free(fname);
smbcli_close(cli->tree, fnum);
}
- free(dname);
+ talloc_free(dname);
}
file = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
@@ -1103,14 +1103,14 @@ static BOOL test_os2_delete(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("Testing OS/2 style delete on %d files\n", num_files);
for (i=0;i<num_files;i++) {
- asprintf(&fname, BASEDIR "\\file%u.txt", i);
+ fname = talloc_asprintf(cli, BASEDIR "\\file%u.txt", i);
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
ret = False;
goto done;
}
- free(fname);
+ talloc_free(fname);
smbcli_close(cli->tree, fnum);
}
@@ -1130,10 +1130,11 @@ static BOOL test_os2_delete(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
CHECK_STATUS(status, NT_STATUS_OK);
for (i=0;i<MIN(result.count, delete_count);i++) {
- asprintf(&fname, BASEDIR "\\%s", result.list[i].ea_size.name.s);
+ fname = talloc_asprintf(cli, BASEDIR "\\%s", result.list[i].ea_size.name.s);
status = smbcli_unlink(cli->tree, fname);
CHECK_STATUS(status, NT_STATUS_OK);
total_deleted++;
+ talloc_free(fname);
}
io2.t2fnext.level = RAW_SEARCH_EA_SIZE;
@@ -1154,10 +1155,11 @@ static BOOL test_os2_delete(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
}
for (i=0;i<MIN(result.count, delete_count);i++) {
- asprintf(&fname, BASEDIR "\\%s", result.list[i].ea_size.name.s);
+ fname = talloc_asprintf(cli, BASEDIR "\\%s", result.list[i].ea_size.name.s);
status = smbcli_unlink(cli->tree, fname);
CHECK_STATUS(status, NT_STATUS_OK);
total_deleted++;
+ talloc_free(fname);
}
if (i>0) {