[libdvdnav-devel] [PATCH] Free pointers regardless of related integers
Steve Dibb
beandog at gentoo.org
Sat Jan 3 17:29:40 CET 2015
On Sat, 3 Jan 2015 17:02:41 +0100
Jean-Baptiste Kempf <jb at videolan.org> wrote:
OK. What's the best approach?
>
> This is bad. free(NULL) is a no-op. if(a) free(a) is a known
> anti-pattern.
>
> On 03 Jan, Steve Dibb wrote :
> > diff --git a/src/ifo_read.c b/src/ifo_read.c
> > index 807ebac..11ab661 100644
> > --- a/src/ifo_read.c
> > +++ b/src/ifo_read.c
> > @@ -797,11 +797,11 @@ static int
> > ifoRead_PGC_COMMAND_TBL(ifo_handle_t *ifofile,
> > static void ifoFree_PGC_COMMAND_TBL(pgc_command_tbl_t *cmd_tbl) {
> > if(cmd_tbl) {
> > - if(cmd_tbl->nr_of_pre && cmd_tbl->pre_cmds)
> > + if(cmd_tbl->pre_cmds)
> > free(cmd_tbl->pre_cmds);
> > - if(cmd_tbl->nr_of_post && cmd_tbl->post_cmds)
> > + if(cmd_tbl->post_cmds)
> > free(cmd_tbl->post_cmds);
> > - if(cmd_tbl->nr_of_cell && cmd_tbl->cell_cmds)
> > + if(cmd_tbl->cell_cmds)
> > free(cmd_tbl->cell_cmds);
> > free(cmd_tbl);
> > }
> > --
> > 2.0.4
> > _______________________________________________
> > libdvdnav-devel mailing list
> > libdvdnav-devel at videolan.org
> > https://mailman.videolan.org/listinfo/libdvdnav-devel
>
More information about the libdvdnav-devel
mailing list