[MPlayer-dev-eng] [PATCH] Simplify frees in load_vob_subtitle.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Feb 5 22:27:52 CET 2011


On Sat, Feb 05, 2011 at 10:12:00PM +0100, Clément Bœsch wrote:
> Hi,
> 
> Small patch for the load_vob_subtitle function to cleanup a bit and
> simplify the ways frees are handled. If you don't mind (maybe you find the
> code no clearer after that or sth else), I'll commit this in 3 days.

I am not very convinced yet.
First, you missed the most obvious one, there is a "free(name); return;" at
the very beginning that could be replaced by a "goto out".
Next, there is a NULL check missing for the very last mp_path_join.

Lastly, not sure if it's better or worse, but this

> @@ -2182,25 +2182,24 @@ void load_vob_subtitle(const char *fname, const char * const ifo, void **spu,
>              if (!psub)
>                  goto out;
>  
> -            if (add_f(psub, ifo, 0, spu)) {
> -                free(psub);
> +            if (add_f(psub, ifo, 0, spu))
>                  goto out;
> -            }
>              free(psub);
> +            psub = NULL;

could also be handled like
res = add_f(psub, ifo, 0, spu);
free(psub);
if (res)
    goto out;


More information about the MPlayer-dev-eng mailing list