[FFmpeg-devel] [PATCH 3/5] lavu/dict: use intermediate variable for value assignment.
Stefano Sabatini
stefasab at gmail.com
Mon Apr 15 22:43:46 CEST 2013
On date Sunday 2013-04-14 03:07:56 +0200, Clément Bœsch encoded:
> ---
> libavutil/dict.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/libavutil/dict.c b/libavutil/dict.c
> index 3a0e84c..64ddffd 100644
> --- a/libavutil/dict.c
> +++ b/libavutil/dict.c
> @@ -85,12 +85,14 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
> return AVERROR(ENOMEM);
> }
> if (value) {
> + AVDictionaryEntry *e = &m->elems[m->count++];
> +
> if (flags & AV_DICT_DONT_STRDUP_KEY) {
> - m->elems[m->count].key = (char*)(intptr_t)key;
> + e->key = (char*)(intptr_t)key;
> } else
> - m->elems[m->count].key = av_strdup(key);
> + e->key = av_strdup(key);
> if (flags & AV_DICT_DONT_STRDUP_VAL) {
> - m->elems[m->count].value = (char*)(intptr_t)value;
> + e->value = (char*)(intptr_t)value;
> } else if (oldval && flags & AV_DICT_APPEND) {
> int len = strlen(oldval) + strlen(value) + 1;
> char *newval = av_mallocz(len);
> @@ -99,10 +101,9 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
> av_strlcat(newval, oldval, len);
> av_freep(&oldval);
> av_strlcat(newval, value, len);
> - m->elems[m->count].value = newval;
> + e->value = newval;
> } else
> - m->elems[m->count].value = av_strdup(value);
> - m->count++;
> + e->value = av_strdup(value);
> }
> if (!m->count) {
> av_free(m->elems);
LGTM, thanks.
--
FFmpeg = Fiendish and Fantastic Meaningful Purposeless Evil Guru
More information about the ffmpeg-devel
mailing list