The precise meaning of talloc_tos()

Richard Sharpe realrichardsharpe at
Sat Apr 7 13:41:23 MDT 2012

Hi folks,

I noticed this comment in lib/util/talloc_stack.h

 * Implement a stack of talloc frames.
 * When a new talloc stackframe is allocated with talloc_stackframe(), then
 * the TALLOC_CTX returned with talloc_tos() is reset to that new
 * frame. Whenever that stack frame is TALLOC_FREE()'ed, then the reverse
 * happens: The previous talloc_tos() is restored.

My question hinges around the use of the word reset above in "the
TALLOC_CTX returned with talloc_tos() is *reset* to that new frame."

I think that the code in talloc_stackframe.c shows that reset is the
wrong word there and it simply returns the context associated with the
current top of the talloc stack or a new one if no stack yet exists,
however, given my recent demonstrated ability to mis-read code, can
someone confirm :-)

Richard Sharpe

More information about the samba-technical mailing list