talloc_stack.c?

Volker Lendecke Volker.Lendecke at SerNet.DE
Mon Jul 2 07:15:10 GMT 2007


On Mon, Jul 02, 2007 at 03:22:38PM +1000, tridge at samba.org wrote:
> linked lists work fine - I use them all the time with talloc
> destructors. 
> 
> You are right that the parent destructor is called first, but the
> memory is actually freed from the bottom up (ie. child is freed
> first). The recursion marks the memory for deletion on the way down
> (to prevent loops) and actually frees it on the way up.

I would like to set the top of the stack from the topmost
destructor, but the children's ones are called after it, so
they would overwrite the top.

> Regarding the talloc_stack.c idea, this is awfully similar to what we
> have had in the past with a "loop" memory context - a memory context
> that gets freed in the top level event loop. What advantage does
> talloc_stack have over that idea? (that idea is still present in the
> lp_TALLOC_FREE() call and tmp_talloc_ctx() in Samba3.

Sure. But with the talloc stack I want to make that more
fine grained. For example a routine to handle a single smb
request might have to do quite a bit of looping, and I want
to give that routine a chance to clean up memory earlier
than the main talloc loop would.

Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20070702/7886cfec/attachment.bin


More information about the samba-technical mailing list