Re: cbdataFree() in -HEAD ?

From: Alex Rousskov <rousskov@dont-contact.us>
Date: Tue, 13 Mar 2001 07:26:17 -0700 (MST)

On Tue, 13 Mar 2001, Adrian Chadd wrote:

> On Tue, Mar 13, 2001, Henrik Nordstrom wrote:
> > Interesting that x = (cbdataInternalFree(x), NULL) bombs out on IRIX. I
> > can only quess to the cause, and the more I look at it, the more it
> > smells a compiler bug..
> >
> > Anyway, either of the proposed would do, but I think we should stick to
> > the same definition as used by safe_free:
> >
> > #define cbdataFree(x) if (x) { cbdataInternalFree(x); (x) = NULL; }
>
> Well, the reason I did it my way is because cbdataFree() will then
> work in strange if/while/for setups. Granted, that doesn't happen
> in squid with cb*(), but the FreeBSD people I've chatted to about this
> indicate you can get into some realy weird stuff thats hard to
> track down.

Yeah. The above statement (and the one I suggested) are probably
illegal inside parens of "for (a;b;c)" or "while()" because it is not
an operator like "(a,b)" you used to have, but a statement. I am not a
C guru though.

Alex.

P.S. On the bright side, we will not have these problems in Squid 3.0
     where we could have references instead of these ugly macros. :)
        template <class T> inline
        void safeDelete(T *&x) {
                delete x;
                x = 0;
        }
Received on Tue Mar 13 2001 - 07:26:28 MST

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