diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-08-21 01:54:46 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:14 -0500 |
commit | b83ba93eaeb2dcb0bf11615591d886fda84e4162 (patch) | |
tree | b2fe3c5a6ea7a9bd1f5f416e545ee26d4a207ac5 /source4/torture/raw | |
parent | 326f562e72c0776f469a8af93e25a2cc94dff60e (diff) | |
download | samba-b83ba93eaeb2dcb0bf11615591d886fda84e4162.tar.gz samba-b83ba93eaeb2dcb0bf11615591d886fda84e4162.tar.bz2 samba-b83ba93eaeb2dcb0bf11615591d886fda84e4162.zip |
r1983: a completely new implementation of talloc
This version does the following:
1) talloc_free(), talloc_realloc() and talloc_steal() lose their
(redundent) first arguments
2) you can use _any_ talloc pointer as a talloc context to allocate
more memory. This allows you to create complex data structures
where the top level structure is the logical parent of the next
level down, and those are the parents of the level below
that. Then destroy either the lot with a single talloc_free() or
destroy any sub-part with a talloc_free() of that part
3) you can name any pointer. Use talloc_named() which is just like
talloc() but takes the printf style name argument as well as the
parent context and the size.
The whole thing ends up being a very simple piece of code, although
some of the pointer walking gets hairy.
So far, I'm just using the new talloc() like the old one. The next
step is to actually take advantage of the new interface
properly. Expect some new commits soon that simplify some common
coding styles in samba4 by using the new talloc().
(This used to be commit e35bb094c52e550b3105dd1638d8d90de71d854f)
Diffstat (limited to 'source4/torture/raw')
-rw-r--r-- | source4/torture/raw/open.c | 12 | ||||
-rw-r--r-- | source4/torture/raw/search.c | 3 |
2 files changed, 7 insertions, 8 deletions
diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c index 8cdc18fe2f..2cb39b3231 100644 --- a/source4/torture/raw/open.c +++ b/source4/torture/raw/open.c @@ -150,7 +150,7 @@ static BOOL test_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) union smb_fileinfo finfo; const char *fname = BASEDIR "\\torture_open.txt"; NTSTATUS status; - int fnum, fnum2; + int fnum = -1, fnum2; BOOL ret = True; printf("Checking RAW_OPEN_OPEN\n"); @@ -261,7 +261,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) union smb_fileinfo finfo; const char *fname = BASEDIR "\\torture_openx.txt"; NTSTATUS status; - int fnum, fnum2; + int fnum = -1, fnum2; BOOL ret = True; int i; struct { @@ -579,7 +579,7 @@ static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *fname = BASEDIR "\\torture_ntcreatex.txt"; const char *dname = BASEDIR "\\torture_ntcreatex.dir"; NTSTATUS status; - int fnum; + int fnum = -1; BOOL ret = True; int i; struct { @@ -822,7 +822,7 @@ static BOOL test_mknew(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) union smb_open io; const char *fname = BASEDIR "\\torture_mknew.txt"; NTSTATUS status; - int fnum; + int fnum = -1; BOOL ret = True; time_t basetime = (time(NULL) + 3600*24*3) & ~1; union smb_fileinfo finfo; @@ -876,7 +876,7 @@ static BOOL test_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) union smb_open io; const char *fname = BASEDIR "\\torture_create.txt"; NTSTATUS status; - int fnum; + int fnum = -1; BOOL ret = True; time_t basetime = (time(NULL) + 3600*24*3) & ~1; union smb_fileinfo finfo; @@ -930,7 +930,7 @@ static BOOL test_ctemp(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; NTSTATUS status; - int fnum; + int fnum = -1; BOOL ret = True; time_t basetime = (time(NULL) + 3600*24*3) & ~1; union smb_fileinfo finfo; diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c index f1d51a8c69..19dfcc51d4 100644 --- a/source4/torture/raw/search.c +++ b/source4/torture/raw/search.c @@ -377,8 +377,7 @@ static BOOL multiple_search_callback(void *private, union smb_search_data *file) data->count++; - data->list = talloc_realloc(data->mem_ctx, - data->list, + data->list = talloc_realloc(data->list, data->count * (sizeof(data->list[0]))); data->list[data->count-1] = *file; |