[RFC] Making talloc_reference() safer.
Jeremy Allison
jra at samba.org
Tue Oct 25 15:13:19 MDT 2011
On Wed, Oct 26, 2011 at 07:26:11AM +1100, ronnie sahlberg wrote:
>
> The drawback is that without forcing the choice of API ar creation time you
> have situation where an object is sometimes a hierarical object and at
> other times it suddently switches to a different model and a different
> api.
> What if this is changed in an external module I call and that module
> decides for me "your object is now using a completely different
> model".
>
> The implication then is that all codepaths will have to change for
> these objects like this
>
> from
> talloc_free(object)
>
> into
>
> if (talloc_is_referenced(object)) {
> talloc_unref(parent, object)
> } else {
> talloc_free(object)
> }
>
> Or similar for "talloc_steal()" that would conditionally now become
> talloc_ref() instead.
> Teh horrors.
>
> I personally think that the "hierarcy" vs "multi-parent" has to be
> made at creation time and creation time only.
I completely agree with this.
Multi-parent is a specialized choice, that should not be
seen by simple talloc()/talloc_free() users.
> A bigger picture is that TALLOC is a hugely useful library which
> should be encouraged to be used also externally in non-samba projects
> as well.
> So API is really important. It is even more important that just "what
> API change is needed to solve a problem in samba", it is "what API
> makes sense to the average OSS developer working on his/her pet
> project".
+1 API's are *important*.
Jeremy.
More information about the samba-technical
mailing list