On Fri, 2003-03-07 at 10:07, Henrik Nordstrom wrote: > On Thursday 06 March 2003 20.41, Robert Collins wrote: > > > Why? Cbdata is used for handing off to async calls. All such calls > > should check for cbdataReferenceValid() before accessing the handed > > off data, and it will be invalid --- no problem. > > It is also used in a couple of cases where there is combined > refcounting and cbdata for the same structure.
OK, so we can follow the refcounting instructions in the programmers
manual - they coexist quite well.
> > > In C++ the cbdataFree handler should be called before delete.
> >
> > Yes - in fact, in C++ it becomes the destructor
> > (FtpStateData::~FtpStateData in this case).
>
> >From what I can tell in the code the situation today is the reverse..
> cbdataFree called by the delete operator.
cbdataFree is called by the delete operator, which is called after the
destructor.
The call path is:
ftpStateDataPointer->deleteSelf()
delete this;
FtpStateData::~FtpStateData()
FtpStateData::operator delete
cbdataFree
where an indent == a stack frame.
> > Why do we need to defer the delete? That sounds like reference
> > counting, which is very different need to callback protection.
>
> You are probably correct if cbdata and refcounting can be combined
> cleanly for the same object in such way that delete is deferred while
> there is refcounted references but not if there only is cbdata
> references.
Yes they can, see the programmers guide on refcounting, as let me know
if the examples are not sufficient.
Rob
--
GPG key available at: <http://users.bigpond.net.au/robertc/keys.txt>.
signature.asc
Description: This is a digitally signed message part
