[MPlayer-dev-eng] [PATCH] simplify/refactor code to grow array in demux_mkv.c

Aurelien Jacobs aurel at gnuage.org
Tue Oct 10 00:29:48 CEST 2006


On Mon, 9 Oct 2006 22:21:50 +0200
Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:

> Hello,
> maybe somebody could have a quick look at/test attached patch to check
> that I didn't mess up.

After a quick look, it seems perfectly OK.

> Since realloc works fine with NULL, the old way was unnecessarily
> complicated I think.

Agree.

> @@ -1549,12 +1549,7 @@
>  
>                mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + an attachment...\n");
>  
> -              if (mkv_d->attachments == NULL)
> -                mkv_d->attachments = malloc (32*sizeof(*mkv_d->attachments));
> -              else if (!(mkv_d->num_attachments % 32))
> -                mkv_d->attachments = realloc (mkv_d->attachments,
> -                                           (mkv_d->num_attachments + 32)
> -                                           * sizeof(*mkv_d->attachments));
> +              grow_array(&mkv_d->attachments, mkv_d->num_attachments, sizeof(*mkv_d->attachments));
>  
>                while (len > 0)
>                  {

Maybe try to keep line size <80 characters if possible ?

Aurel



More information about the MPlayer-dev-eng mailing list