talloc_tos() vs talloc_stackframe()
jra at samba.org
Fri Jun 22 16:38:25 UTC 2018
On Fri, Jun 22, 2018 at 03:35:22PM +1200, Andrew Bartlett via samba-technical wrote:
> On Fri, 2018-06-15 at 08:36 +0200, Volker Lendecke via samba-technical
> > On Fri, Jun 15, 2018 at 12:10:50AM +0200, David Disseldorp via samba-technical wrote:
> > > Hi Metze,
> > >
> > > On Thu, 14 Jun 2018 20:54:26 +0200, Stefan Metzmacher wrote:
> > >
> > > > For async code we always have the 'state' variable to use for temporary
> > > > memory, so we don't need talloc_stackframes...
> > >
> > > Indeed, we just need to encourage people to use it instead of the
> > > talloc_tos() context, and begin migrating over helper functions :)
> > Do you really want to pass down temporary talloc contexts everywhere?
> > That's exactly what talloc_tos() was designed for.
> Yes, we should. If memory is returned, it should be on a context.
> The problem with silently allocating memory on talloc_tos() is 'how
> long is this valid for?'.
Only for the containing function. If it gets passed out of
the stackframe without an explicit talloc_move(), then
that's a bug.
Yes, we probably have old code that does this, but new
code should not.
More information about the samba-technical