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

Clément Bœsch ubitux at gmail.com
Wed Feb 16 16:38:34 CET 2011


On Wed, Feb 16, 2011 at 04:16:15PM +0100, ib wrote:
> Author: ib
> Date: Wed Feb 16 16:16:15 2011
> New Revision: 32906
> 
> Log:
> Use gfree().
> 

What about using av_malloc and av_free/av_freep?

> Modified: trunk/gui/skin/font.c
> ==============================================================================
> --- trunk/gui/skin/font.c	Wed Feb 16 13:25:39 2011	(r32905)
> +++ trunk/gui/skin/font.c	Wed Feb 16 16:16:15 2011	(r32906)
> @@ -24,6 +24,7 @@
>  #include "font.h"
>  #include "cut.h"
>  #include "mp_msg.h"
> +#include "../interface.h"

Shouldn't this fixed adding the correct -I?

>  #include "libavutil/avstring.h"
>  
>  bmpFont * Fonts[MAX_FONTS] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };

I know this is not relative to the current patch, but:

   bmpFont *Fonts[MAX_FONTS] = {0};

is enough.

> @@ -53,10 +54,8 @@ void fntFreeFont( void )
>    {
>     if ( Fonts[i] )
>      {
> -     free( Fonts[i]->Bitmap.Image );
> -     Fonts[i]->Bitmap.Image=NULL;
> -     free( Fonts[i] );
> -     Fonts[i]=NULL;
> +     gfree( (void **) &Fonts[i]->Bitmap.Image );
> +     gfree( (void **) &Fonts[i] );

The cast seems useless (yes I know it's like that everywhere).

>      }
>    }
>  }
> @@ -78,8 +77,7 @@ int fntRead( char * path,char * fname )
>   av_strlcat( tmp,fname,sizeof( tmp ) ); av_strlcat( tmp,".fnt",sizeof( tmp ) );
>   if ( ( f=fopen( tmp,"rt" ) ) == NULL )
>    {
> -   free( Fonts[id] );
> -   Fonts[id] = NULL;
> +   gfree( (void **) &Fonts[id] );

ditto

>     return -3;
>    }
>  
> @@ -131,12 +129,8 @@ int fntRead( char * path,char * fname )
>          if ( skinBPRead( tmp,&Fonts[id]->Bitmap ) )
>           {
>            if (Fonts[id]->Bitmap.Image)
> -          {
> -            free(Fonts[id]->Bitmap.Image);
> -            Fonts[id]->Bitmap.Image = NULL;
> -          }
> -          free(Fonts[id]);
> -          Fonts[id] = NULL;
> +            gfree((void **) &Fonts[id]->Bitmap.Image);

The if looks pointless:

    void gfree( void ** p )
    {
     free( *p ); *p=NULL;
    }

[...]

-- 
Clément B.


More information about the MPlayer-cvslog mailing list