[FFmpeg-devel] [PATCH 4/5] lavu/dict: use av_dynarray_alloc_elem().

Stefano Sabatini stefasab at gmail.com
Mon Apr 15 22:47:52 CEST 2013


On date Sunday 2013-04-14 03:07:57 +0200, Clément Bœsch encoded:
> ---
>  libavutil/dict.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/libavutil/dict.c b/libavutil/dict.c
> index 64ddffd..7a92c56 100644
> --- a/libavutil/dict.c
> +++ b/libavutil/dict.c
> @@ -78,11 +78,9 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
>          av_free(tag->key);
>          *tag = m->elems[--m->count];
>      } else {
> -        AVDictionaryEntry *tmp = av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
> -        if(tmp) {
> -            m->elems = tmp;
> -        } else
> +        if (!av_dynarray_alloc_elem((void **)&m->elems, &m->count, sizeof(*m->elems)))
>              return AVERROR(ENOMEM);
> +        m->count--;

>      }
>      if (value) {
>          AVDictionaryEntry *e = &m->elems[m->count++];

LGTM.
-- 
FFmpeg = Fundamental & Formidable Mean Peaceful Easy Gargoyle


More information about the ffmpeg-devel mailing list