Using talloc in vfs modules

Richard Sharpe realrichardsharpe at gmail.com
Sun Mar 25 13:35:23 MDT 2012


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.

Does anyone have any comments on this or further rules of thumb or any
objections?

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)


More information about the samba-technical mailing list