From b83ba93eaeb2dcb0bf11615591d886fda84e4162 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 21 Aug 2004 01:54:46 +0000 Subject: 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) --- source4/ntvfs/simple/vfs_simple.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/ntvfs/simple/vfs_simple.c') diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c index ad889daf36..ae64c96c75 100644 --- a/source4/ntvfs/simple/vfs_simple.c +++ b/source4/ntvfs/simple/vfs_simple.c @@ -580,8 +580,8 @@ static NTSTATUS svfs_close(struct smbsrv_request *req, union smb_close *io) } DLIST_REMOVE(private->open_files, f); - talloc_free(req->tcon->mem_ctx, f->name); - talloc_free(req->tcon->mem_ctx, f); + talloc_free(f->name); + talloc_free(f); return NT_STATUS_OK; } @@ -766,7 +766,7 @@ static NTSTATUS svfs_search_first(struct smbsrv_request *req, union smb_search_f dir = svfs_list(mem_ctx, req, io->t2ffirst.in.pattern); if (!dir) { - talloc_destroy_pool(mem_ctx); + talloc_free(mem_ctx); return NT_STATUS_FOOBAR; } -- cgit