[FFmpeg-devel] [PATCH 2/5] lavf/mkv: use av_dynarray_alloc_elem().
Stefano Sabatini
stefasab at gmail.com
Mon Apr 15 22:42:06 CEST 2013
On date Sunday 2013-04-14 03:07:55 +0200, Clément Bœsch encoded:
> ---
> libavformat/matroskadec.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index ad0401a..041e526 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -943,18 +943,14 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
> uint32_t id = syntax->id;
> uint64_t length;
> int res;
> - void *newelem;
>
> data = (char *)data + syntax->data_offset;
> if (syntax->list_elem_size) {
> EbmlList *list = data;
> - newelem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size);
> - if (!newelem)
> + data = av_dynarray_alloc_elem(&list->elem, &list->nb_elem, syntax->list_elem_size);
> + if (!data)
> return AVERROR(ENOMEM);
> - list->elem = newelem;
> - data = (char*)list->elem + list->nb_elem*syntax->list_elem_size;
> memset(data, 0, syntax->list_elem_size);
> - list->nb_elem++;
> }
LGTM if tested.
--
FFmpeg = Fostering & Faithless Martial Perfectionist Epic Gargoyle
More information about the ffmpeg-devel
mailing list