summaryrefslogtreecommitdiff
path: root/libavutil/dict.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavutil/dict.c')
-rw-r--r--libavutil/dict.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/libavutil/dict.c b/libavutil/dict.c
index e4ea7769e0..aea8910541 100644
--- a/libavutil/dict.c
+++ b/libavutil/dict.c
@@ -1,20 +1,20 @@
/*
* copyright (c) 2009 Michael Niedermayer
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -35,7 +35,7 @@ int av_dict_count(const AVDictionary *m)
return m ? m->count : 0;
}
-AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key,
+AVDictionaryEntry *av_dict_get(FF_CONST_AVUTIL53 AVDictionary *m, const char *key,
const AVDictionaryEntry *prev, int flags)
{
unsigned int i, j;
@@ -90,24 +90,26 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
} else {
AVDictionaryEntry *tmp = av_realloc(m->elems,
(m->count + 1) * sizeof(*m->elems));
- if (tmp)
- m->elems = tmp;
- else
+ if (!tmp)
return AVERROR(ENOMEM);
+ m->elems = tmp;
}
if (value) {
if (flags & AV_DICT_DONT_STRDUP_KEY)
- m->elems[m->count].key = key;
+ m->elems[m->count].key = (char*)(intptr_t)key;
else
m->elems[m->count].key = av_strdup(key);
if (flags & AV_DICT_DONT_STRDUP_VAL) {
- m->elems[m->count].value = value;
+ m->elems[m->count].value = (char*)(intptr_t)value;
} else if (oldval && flags & AV_DICT_APPEND) {
int len = strlen(oldval) + strlen(value) + 1;
- if (!(oldval = av_realloc(oldval, len)))
+ char *newval = av_mallocz(len);
+ if (!newval)
return AVERROR(ENOMEM);
- av_strlcat(oldval, value, len);
- m->elems[m->count].value = oldval;
+ av_strlcat(newval, oldval, len);
+ av_freep(&oldval);
+ av_strlcat(newval, value, len);
+ m->elems[m->count].value = newval;
} else
m->elems[m->count].value = av_strdup(value);
m->count++;
@@ -181,7 +183,7 @@ void av_dict_free(AVDictionary **pm)
av_freep(pm);
}
-void av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
+void av_dict_copy(AVDictionary **dst, FF_CONST_AVUTIL53 AVDictionary *src, int flags)
{
AVDictionaryEntry *t = NULL;