[MPlayer-dev-eng] [PATCH] Useless if NULL before free: libmp{codecs, demux}
Clément Bœsch
ubitux at gmail.com
Fri Nov 12 11:02:06 CET 2010
On Tue, Nov 09, 2010 at 10:20:01PM +0100, Diego Biurrun wrote:
> On Mon, Nov 08, 2010 at 11:51:33PM +0100, Clément Bœsch wrote:
> >
> > If no one object until sunday (do you need more time?) I'll commit it.
> > Patch reattached without the gzip compression since it does not seem to be
> > limited anymore.
> >
> > --- a/gui/mplayer/gtk/pl.c
> > +++ b/gui/mplayer/gtk/pl.c
> > @@ -160,7 +160,7 @@ void ShowPlayList( void )
> > DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( CTDirTree ),node );
> > current_path=DirNode->path;
> > scan_dir( DirNode->path );
> > - if ( CLFileSelected ) free( CLFileSelected ); CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) );
> > + free( CLFileSelected ); CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) );
>
> Please break this line while you're at it.
>
> > @@ -195,7 +195,7 @@ void HidePlayList( void )
> > NrOfSelected=NrOfEntrys=0;
> > gfree( (void **)&CLListSelected ); gfree( (void **)&CLFileSelected );
> > - if ( old_path ) free( old_path ); old_path=strdup( current_path );
> > + free( old_path ); old_path=strdup( current_path );
>
> ditto
>
> > @@ -406,7 +406,7 @@ static void plCTRow(GtkWidget * widget, gint row, gint column, GdkEventButton *
> > gtk_ctree_expand( GTK_CTREE( widget ),node );
> > scan_dir( DirNode->path );
> > - if ( CLFileSelected ) free( CLFileSelected ); CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) );
> > + free( CLFileSelected ); CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) );
>
> again
>
Fixed all of them (but style kept).
> > --- a/libmpcodecs/vf_fspp.c
> > +++ b/libmpcodecs/vf_fspp.c
> > @@ -576,13 +576,13 @@ static void uninit(struct vf_instance *vf)
> >
> > - if(vf->priv->temp) av_free(vf->priv->temp);
> > + av_free(vf->priv->temp);
> > vf->priv->temp= NULL;
> > - if(vf->priv->src) av_free(vf->priv->src);
> > + av_free(vf->priv->src);
> > vf->priv->src= NULL;
> > - //if(vf->priv->avctx) free(vf->priv->avctx);
> > + //free(vf->priv->avctx);
> > //vf->priv->avctx= NULL;
> > - if(vf->priv->non_b_qp) free(vf->priv->non_b_qp);
> > + free(vf->priv->non_b_qp);
> > vf->priv->non_b_qp= NULL;
> >
> > --- a/libmpcodecs/vf_geq.c
> > +++ b/libmpcodecs/vf_geq.c
> > @@ -128,8 +128,6 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
> >
> > static void uninit(struct vf_instance *vf){
> > - if(!vf->priv) return;
> > -
> > av_free(vf->priv);
>
> Maybe the av_free should go in another commit.
>
Well, too much pain sorry. Also, I edited other free-like functions, it
won't make sense to split only av_free. There is no reason av_free will a
day require a pointer check being called. And even if it comes to that,
all the call will have to be changed anyway since the function will become
av_free2 :p
> > --- a/libmpdemux/demux_realaud.c
> > +++ b/libmpdemux/demux_realaud.c
> > @@ -334,14 +334,12 @@ static demuxer_t* demux_open_ra(demuxer_t* demuxer)
> >
> > static void demux_close_ra(demuxer_t *demuxer)
> > {
> > - ra_priv_t* ra_priv = demuxer->priv;
> > + ra_priv_t* ra_priv = demuxer->priv;
>
> unrelated cosmetics
>
I needed to change the indentation of the following code block (as you
asked for) but then this line was the only one inconsistent in the
function.
>
> Patch looks OK otherwise, commit anytime.
>
OK, but I'll maintain the Sunday deadline.
The changes requested in the other mail are also applied.
--
Clément B.
Not sent from a jesusPhone.
More information about the MPlayer-dev-eng
mailing list