Re: cbdata

From: Adrian Chadd <adrian@dont-contact.us>
Date: Fri, 13 Jul 2001 01:43:12 +0800

On Thu, Jul 12, 2001, Alex Rousskov wrote:
> On Thu, 12 Jul 2001, Henrik Nordstrom wrote:
>
> > In an attempt to address this cbdataReferenceDone() was introduced,
> > allowing code like
> >
> > fooDone(...)
> > {
> > void *cbdata;
> > ...
> > if ((cbdata = cbdataReferenceDone(mystate->calllback_data)) != NULL)
> > mystate->callback(..., cbdata);
> > }
> >
> >
> > which tries to join the best of both approaches.
>
> Right. And in C++, you can write an even more consise and efficient
> code:
>
> fooDone(...)
> {
> ...
> if (void *cbdata = cbdataAbandon(mystate->calllback_data))
> mystate->callback(..., cbdata);
> }
>
> Given the above, GCC may eliminate cbdata variable from existance and
> there is no danger in using cbdata after it is passed on to a
> callback. :)

It might be this really long meeting, but in all cases isn't cbdata
potentially *free* data at this stage?

I've been trying to get into the habit of:

if (cbdataValid(cbdata)) {
    callback(cbdata);
}
cbdataUnlock(cbdata);

.. oh. I see what you're doing in the API now. Yup, it was the meeting. :-)
However, isn't the callback data still potentially invalid data?

I've never liked how that worked, even though it does.

-- 
Adrian Chadd			Yeah, for me its (XML) like the movie Titanic.
<adrian@creative.net.au>	  Everybody loves it.
				    I want to be different, so I hate it.
					--Duane Wessels
Received on Thu Jul 12 2001 - 11:43:18 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:07 MST