talloc_tos() in common code
Volker.Lendecke at SerNet.DE
Thu Apr 14 00:23:37 MDT 2011
On Thu, Apr 14, 2011 at 09:15:09AM +1000, tridge at samba.org wrote:
> > I wonder why we can't use the talloc_tos() infrastructure in common code?
> One of the main problems is it getting into public interfaces. A lot
> of our common code is used by external projects (both via libsmbclient
> and openchange usage). If we used talloc_tos() in any call that is
> exposed publicly then those projects would need a mechanism for
> cleaning up the allocation.
> Either that or we would need to have a cleanup routine in every exit
> point from our public API calls. There are a lot of those! If we miss
> one, then we will have created a memory leak in an external project.
That's not different from the current situation, except that
with more proper use of talloc_stackframe in public
functions the inner functions are safer from generating
memleaks if due to a bug a temporary talloc context is not
freed. Just see talloc_stackframe() as the normal way to
allocate temporary talloc contexts. With every proper use of
talloc_free(frame) at the exit of a function you gain a
little bit of safety for the functions called from there.
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
More information about the samba-technical