[QUICK] talloc bugs

Rusty Russell rusty at rustcorp.com.au
Mon Jun 29 05:29:36 MDT 2009


On Mon, 29 Jun 2009 07:29:17 pm ronnie sahlberg wrote:
> Example : A circular linked list. A circular linked list today with
> talloc is treated as one meta-object owning the metadata for the list
> och which all list elements are child objects to that linked list
> metadata object. This can be argued to be a very unnatural hierarchy
> for a list.

Not at all.  The talloc hierarchy is a hierarchy of lifetimes, of ownership.  
This can overlap with the structural hierarchy.  Samba (ab)uses this in places 
to save on pointers to things which in practice are always talloc parents.

But don't conflate the two!  Each node owning the next one is nonsensical.

Similarly, transferring ownership should be explicit.  register/unregister is 
a common pattern, which should *not* transfer ownership.  talloc_steal is 
dangerous in general because it's taking ownership: it only works if the givee 
is a parent of convenience.  Interfaces are usually better to take an explicit 
context argument, than using such a parent.

I'd like to see a simple example of where talloc_reference is required, so we 
can get less abstract in this discussion.

Thanks,
Rusty.


More information about the samba-technical mailing list