tor 2010-10-28 klockan 22:26 +0200 skrev Kinkie:
> Well, my aim is a very modest "let the damn thing build".
> I do not yet understand the intricacies of cbdata, and thus I am not
> able to understand when it is abused and when the abuse is benign.
There is two cbdata roles
a) Object owner, using "plain pointer" and freeing the object using
cbdataFree when done.
b) Other code needing to to a callback to the object owner passing the
object for owner state info. Uses cbdataReference to track the object
and cbdataReferenceValid & cbdataReferenceDone (or usually preferred the
combined cbdataReferenceValidDone) when making the callback.
Different cases of abuse:
* use of the return value of cbdataReference as a pointer to some
specific type of object. The API intention is to consider it anonymois
"void *" where the actual data type is only known by the object owner.
* use of cbdataReference as a refcount substitute. (we did not have
refcount when cbdata was added)
* no clear separation between "owner" and "other code needing to do a
callback".
* Direct uses of cbdataInternal* calls.
* use of cbdata as a simple way to set up pooled allocation even when
the object is never intended to be used in callbacks.
> > Keep in mind that a lot of cbdata-using code violates these very good rules,
I would not say "a lot". There is some abuses, but most of the code uses
it right, at least last time I audited cbdata usage.
Regards
Henrik
Received on Fri Oct 29 2010 - 09:28:50 MDT
This archive was generated by hypermail 2.2.0 : Sat Oct 30 2010 - 12:00:05 MDT