[PATCH] Change module interface to pass in a TALLOC_CTX pointer.
jra at samba.org
Fri Apr 21 03:01:41 UTC 2017
Currently the initialization function of all our modules are called with a
function signature of:
The following patch changes this to be:
NTSTATUS XXX_init(TALLOC_CTX *ctx)
instead. The patch (for 4.7.x naturally) merely changes
the definition of the initialization functions and their
callers, and implements *no* logic changes (all of the changed
callers in this patch pass NULL in as the new TALLOC_CTX *ctx
and the modules ignore it).
As it's a change to the module interfaces, I have also
incremented the version numbers for all loadable modules,
and added text to the WHATSNEW and to the module documentation.
The reason I want this change is that currently many modules
do something like:
and the called function looks like:
backend = talloc(talloc_autofree_context(), .... );
Essentially the modules don't get access to a long-lived
talloc context from their caller so end up using the global
talloc_autofree_context() so they look cleaner when run under
valgrind (i.e. at least someone frees this stuff on exit).
This is a nasty, lazy way of memory management and I really
want the calling program to hand them down a long-lived
talloc context (usually initialized in the main() function
of the program) and manage doing the talloc_free() just
before doing the exit itself.
I'd appreciate people looking this over to ensure I've
changed all the relevent version numbers, ABI numbers etc.
It passes a full autobuild make test. Once it gets in I
can start fixing the underlying memory management by
passing in a real talloc context that the modules can
use for their long-term initialization use instead of
Let me know what you think. It looks a bigger change
than it is, most of it is pure boilerplate changes.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 111701 bytes
Desc: not available
More information about the samba-technical