svn commit: samba r24809 - in branches: SAMBA_3_2/source SAMBA_3_2/source/include SAMBA_3_2/source/lib SAMBA_3_2/source/modules SAMBA_3_2/source/nmbd SAMBA_3_2/source/nsswitch SAMBA_3_2/source/param SAMBA_3_2/source/rpc_parse SAMBA_3_2/source/rpc_server SAMBA_3_2/source/smbd SAMBA_3_2/source/utils SAMBA_3_2_0/source SAMBA_3_2_0/source/include SAMBA_3_2_0/source/lib SAMBA_3_2_0/source/modules SAMBA_3_2_0/source/nmbd SAMBA_3_2_0/source/nsswitch SAMBA_3_2_0/source/param SAMBA_3_2_0/source/rpc_parse SAMBA_3_2_0/source/rpc_server SAMBA_3_2_0/source/smbd SAMBA_3_2_0/source/utils

vlendec at samba.org vlendec at samba.org
Thu Aug 30 19:48:52 GMT 2007


Author: vlendec
Date: 2007-08-30 19:48:31 +0000 (Thu, 30 Aug 2007)
New Revision: 24809

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

Log:
Consolidate the use of temporary talloc contexts.

This adds the two functions talloc_stackframe() and talloc_tos().

 * When a new talloc stackframe is allocated with talloc_stackframe(), then
 * the TALLOC_CTX returned with talloc_tos() is reset to that new
 * frame. Whenever that stack frame is TALLOC_FREE()'ed, then the reverse
 * happens: The previous talloc_tos() is restored.
 *
 * This API is designed to be robust in the sense that if someone forgets to
 * TALLOC_FREE() a stackframe, then the next outer one correctly cleans up and
 * resets the talloc_tos().

The original motivation for this patch was to get rid of the
sid_string_static & friends buffers. Explicitly passing talloc context
everywhere clutters code too much for my taste, so an implicit
talloc_tos() is introduced here. Many of these static buffers are
replaced by a single static pointer.

The intended use would thus be that low-level functions can rather
freely push stuff to talloc_tos, the upper layers clean up by freeing
the stackframe. The more of these stackframes are used and correctly
freed the more exact the memory cleanup happens.

This patch removes the main_loop_talloc_ctx, tmp_talloc_ctx and
lp_talloc_ctx (did I forget any?)

So, never do a

tmp_ctx = talloc_init("foo");

anymore, instead, use

tmp_ctx = talloc_stackframe()

:-)

Volker


Added:
   branches/SAMBA_3_2/source/include/talloc_stack.h
   branches/SAMBA_3_2/source/lib/talloc_stack.c
   branches/SAMBA_3_2_0/source/include/talloc_stack.h
   branches/SAMBA_3_2_0/source/lib/talloc_stack.c
Modified:
   branches/SAMBA_3_2/source/Makefile.in
   branches/SAMBA_3_2/source/include/includes.h
   branches/SAMBA_3_2/source/modules/nfs4_acls.c
   branches/SAMBA_3_2/source/modules/vfs_afsacl.c
   branches/SAMBA_3_2/source/modules/vfs_aixacl2.c
   branches/SAMBA_3_2/source/modules/vfs_gpfs.c
   branches/SAMBA_3_2/source/modules/vfs_zfsacl.c
   branches/SAMBA_3_2/source/nmbd/nmbd.c
   branches/SAMBA_3_2/source/nsswitch/winbindd.c
   branches/SAMBA_3_2/source/nsswitch/winbindd_dual.c
   branches/SAMBA_3_2/source/param/loadparm.c
   branches/SAMBA_3_2/source/rpc_parse/parse_lsa.c
   branches/SAMBA_3_2/source/rpc_parse/parse_misc.c
   branches/SAMBA_3_2/source/rpc_parse/parse_ntsvcs.c
   branches/SAMBA_3_2/source/rpc_parse/parse_spoolss.c
   branches/SAMBA_3_2/source/rpc_parse/parse_svcctl.c
   branches/SAMBA_3_2/source/rpc_server/srv_pipe.c
   branches/SAMBA_3_2/source/rpc_server/srv_spoolss_nt.c
   branches/SAMBA_3_2/source/rpc_server/srv_srvsvc_nt.c
   branches/SAMBA_3_2/source/smbd/blocking.c
   branches/SAMBA_3_2/source/smbd/lanman.c
   branches/SAMBA_3_2/source/smbd/negprot.c
   branches/SAMBA_3_2/source/smbd/notify.c
   branches/SAMBA_3_2/source/smbd/nttrans.c
   branches/SAMBA_3_2/source/smbd/open.c
   branches/SAMBA_3_2/source/smbd/posix_acls.c
   branches/SAMBA_3_2/source/smbd/process.c
   branches/SAMBA_3_2/source/smbd/server.c
   branches/SAMBA_3_2/source/smbd/trans2.c
   branches/SAMBA_3_2/source/utils/net_lookup.c
   branches/SAMBA_3_2/source/utils/net_sam.c
   branches/SAMBA_3_2_0/source/Makefile.in
   branches/SAMBA_3_2_0/source/include/includes.h
   branches/SAMBA_3_2_0/source/modules/nfs4_acls.c
   branches/SAMBA_3_2_0/source/modules/vfs_afsacl.c
   branches/SAMBA_3_2_0/source/modules/vfs_aixacl2.c
   branches/SAMBA_3_2_0/source/modules/vfs_gpfs.c
   branches/SAMBA_3_2_0/source/modules/vfs_zfsacl.c
   branches/SAMBA_3_2_0/source/nmbd/nmbd.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd_dual.c
   branches/SAMBA_3_2_0/source/param/loadparm.c
   branches/SAMBA_3_2_0/source/rpc_parse/parse_lsa.c
   branches/SAMBA_3_2_0/source/rpc_parse/parse_misc.c
   branches/SAMBA_3_2_0/source/rpc_parse/parse_ntsvcs.c
   branches/SAMBA_3_2_0/source/rpc_parse/parse_reg.c
   branches/SAMBA_3_2_0/source/rpc_parse/parse_spoolss.c
   branches/SAMBA_3_2_0/source/rpc_parse/parse_srv.c
   branches/SAMBA_3_2_0/source/rpc_parse/parse_svcctl.c
   branches/SAMBA_3_2_0/source/rpc_server/srv_pipe.c
   branches/SAMBA_3_2_0/source/rpc_server/srv_spoolss_nt.c
   branches/SAMBA_3_2_0/source/rpc_server/srv_srvsvc_nt.c
   branches/SAMBA_3_2_0/source/smbd/blocking.c
   branches/SAMBA_3_2_0/source/smbd/lanman.c
   branches/SAMBA_3_2_0/source/smbd/negprot.c
   branches/SAMBA_3_2_0/source/smbd/notify.c
   branches/SAMBA_3_2_0/source/smbd/nttrans.c
   branches/SAMBA_3_2_0/source/smbd/open.c
   branches/SAMBA_3_2_0/source/smbd/posix_acls.c
   branches/SAMBA_3_2_0/source/smbd/process.c
   branches/SAMBA_3_2_0/source/smbd/server.c
   branches/SAMBA_3_2_0/source/smbd/trans2.c
   branches/SAMBA_3_2_0/source/utils/net_lookup.c
   branches/SAMBA_3_2_0/source/utils/net_sam.c


Changeset:
Sorry, the patch is too large (2976 lines) to include; please use WebSVN to see it!
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24809


More information about the samba-cvs mailing list