[MPlayer-cvslog] CVS: main/libvo vo_sdl.c,1.118,1.119

D Richard Felker III dalias at aerifal.cx
Tue Mar 1 18:44:50 CET 2005


On Tue, Mar 01, 2005 at 05:38:01PM +0100, Alexander Strasser wrote:
> Michael Niedermayer wrote ( On Tue, Mar 01, 2005 at 05:24:09PM +0100 ):
> > Hi
> > 
> > On Tuesday 01 March 2005 12:24, Reimar D?ffinger wrote:
> > > Hi,
> > >
> > > On Tue, Mar 01, 2005 at 04:51:50AM +0100, Ivo van Poorten CVS wrote:
> > > > +    if(sdl_driver) setenv("SDL_VIDEODRIVER", sdl_driver, 1);
> > > > +    free(sdl_driver);
> > >
> > > Most MPlayer code checks if a pointer is null before freeing - but
> > 
> > IMHO a
> > #define free(x) if(x) free(x)
> > somewhere would be a better idea, or a mp_free() maybe ...
> 
> What is this good for?
> 
> I always thought freeing a NULL pointer was safe and even guaranteed
> to be so by the standard. But of course i may be wrong, this is why
> I ask for the reason? Are there systems where it isn't save to free
> NULL pointers? Or are there performance considerations behind it?
> Of course then it wouldn't matter in this case.

It is guaranteed to be safe by the standard, but supposedly there are
broken systems that don't follow the standard. I've never seen one
myself, and honestly I don't think it's worth obfuscating our code to
support them. One could instead just link against a custom nonbroken
malloc implementation on such systems.

Rich




More information about the MPlayer-cvslog mailing list