Using talloc in vfs modules

Jeremy Allison jra at samba.org
Tue Mar 27 16:32:05 MDT 2012


On Sun, Mar 25, 2012 at 12:35:23PM -0700, Richard Sharpe wrote:
> Hi folks,
> 
> I am updating the Samba VFS document with some comments on using talloc.
> 
> My rules of thumb are:
> 
> 1. Always use talloc.
> 2. Use the most appropriate talloc context.
> 2a. If a talloc context was passed into the function you are in, it is
> usually appropriate to use that context.
> 2b. If the memory has to survive for the duration of the connection,
> use handle->conn as the context.
> 2c If the memory is for an FSP extension, use the fsp as the talloc context.
> 2d. If the memory only needs to survive until the current command
> completes, use talloc_tos().
> 2e. If the memory must survive across multiple connections, you
> probably want a new talloc context.

Or use the NULL context if it's a singleton pattern initialization.

Jeremy.


More information about the samba-technical mailing list