[MPlayer-cvslog] r32906 - trunk/gui/skin/font.c

Clément Bœsch ubitux at gmail.com
Wed Feb 16 19:57:28 CET 2011


On Wed, Feb 16, 2011 at 06:56:52PM +0100, Ingo Brückl wrote:
> Clément Boesch wrote on Wed, 16 Feb 2011 17:55:07 +0100:
> 
> > Mmmh, I didn't look well to the gfree prototype: it should be:
> 
> >     gfree(void *p);
> 
> > with a cast into void ** in this function.
> 
> No, I disagree.
> 
> > It will avoid a lot of cast all over the code.
> 
> Yes, that's true, but it "lies" about the parameter and gives the compiler no
> chance to warn me if I call gfree(p) instead of gfree(&p)! (And naming it
> gfreep() won't help much as long as nobody can use the "p" in the function
> name for checks. I, of course, could/should but tend to forget and make
> mistakes and that's were the compiler assists with its warnings.)
> 
> Thinking about avoiding the cast, maybe a macro like
> 
>   #define nfree(p) { free(p); p = NULL; }
> 
> would be a suitable replacement for gfree()?
> 

I don't know, it was just a proposition. Not sure a macro will enlight the
situation though. Actually, I don't really care, so do as you wish.

But if you want to use a macro, capitalize it, and since there is a block
scope, use the do { ... } while (0) form.

-- 
Clément B.


More information about the MPlayer-cvslog mailing list