On Thu, 2003-03-06 at 23:55, Henrik Nordstrom wrote:
> tor 2003-03-06 klockan 12.47 skrev Robert Collins:
>
> > As a side effect, I may have broken FTP, due to FTP's use of a
> > cbdataFree handler - which really doesn't work well with C++, as the
> > compiler may zero objects after delete is called, or otherwise tramp on
> > the memory.
>
> Ug.. if you break cbdataFree handlers then quite many things will fail,
> and making safe cbdata constructs becomes significantly harder..
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.
> In C++ the cbdataFree handler should be called before delete.
Yes - in fact, in C++ it becomes the destructor
(FtpStateData::~FtpStateData in this case).
> On the other hand, we can probably get rid of cbdataFree handlers
> entirely in C++ as there is the delete operation which serves the same
> purpose. Only need a construct where delete is deferred until the last
> reference has gone away.
Why do we need to defer the delete? That sounds like reference counting,
which is very different need to callback protection.
Rob
-- GPG key available at: <http://users.bigpond.net.au/robertc/keys.txt>.
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:19:30 MST