[DVDnav-discuss] [libdvdnav-devel] [PATCH] Free pointers regardless of related integers

Jean-Baptiste Kempf jb at videolan.org
Sat Jan 3 17:02:41 CET 2015


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

-- 
With my kindest regards,

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device


More information about the DVDnav-discuss mailing list