[QUICK] talloc bugs

ronnie sahlberg ronniesahlberg at gmail.com
Mon Jun 29 07:28:14 MDT 2009

Hey simo,
Im really with you here.

I personally think graphs and talloc_reference() are broken by design
and just confusing and too hard to use correctly and safely,
and talloc_reference() should just be removed.
Meaning, massage your data model to match a proper tree or surprises will arise.

Im just trying to come up with examples where a non-tree model a.k.a.
talloc_reference() may be useful.


On Mon, Jun 29, 2009 at 11:16 PM, simo<idra at samba.org> wrote:
> On Mon, 2009-06-29 at 22:58 +1000, ronnie sahlberg wrote:
>> The reason that a linked list in talloc today requires that you do
>> walk the list when you need to fix up the dangling reference is
>> because of talloc being a tree structure and certain data models like
>> linked lists are not tree structured but graphs.
> Sorry Ronnie, but I totally disagree here.
> The reason you have to walk a list is that you really needed a double
> linked list and instead went for a single linked list.
> What you are doing with talloc_reference() here is really just creating
> a double linked list, only you do one part explicitly (the ->next part)
> and tie the second to memory allocation ( -> parent part).
> I think this is a *very* good example of a *very* bad way to use memory
> hierarchies or references.
> Not only you have nothing more than a double linked list, but you have
> to deal with the 2 pointers (next/prev) in 2 completely different ways.
> Not to think about the weirdness of using 2 different ways to deal with
> list removal depending on whether you want to free the object or simply
> remove it from the list and use it elsewhere.
> A double linked list element should simply use a destructor and
> The only case where this usage could be of use is if the actual object
> structure is imposed on you. But in most cases where that happens you
> have to deal with other code that uses normal malloc/free most probably.
> Simo.
> --
> Simo Sorce
> Samba Team GPL Compliance Officer <simo at samba.org>
> Principal Software Engineer at Red Hat, Inc. <simo at redhat.com>

More information about the samba-technical mailing list