diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2015-10-04 14:27:15 +0300 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2015-10-12 14:35:01 +0300 |
commit | 11c5f438ff83da5040e85bfa6299f56b321d32ef (patch) | |
tree | 8c2570de0ae47c60d02b67432aa326f2c4d0e3c9 | |
parent | c1aac39eaccd32dc3b74ccfcce701d3d888fbc6b (diff) |
dict: Change return type of av_dict_copy()
av_dict_set() could return an error, so forward it appropriately.
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
-rw-r--r-- | doc/APIchanges | 4 | ||||
-rw-r--r-- | libavutil/dict.c | 11 | ||||
-rw-r--r-- | libavutil/dict.h | 4 | ||||
-rw-r--r-- | libavutil/version.h | 2 |
4 files changed, 16 insertions, 5 deletions
diff --git a/doc/APIchanges b/doc/APIchanges index 144eb792b4..26f88161fa 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,10 @@ libavutil: 2015-08-28 API changes, most recent first: +2015-xx-xx - xxxxxxx - lavu 55.2.0 - dict.h + Change return type of av_dict_copy() from void to int, so that a proper + error code can be reported. + 2015-xx-xx - xxxxxxx - lavc 57.0.0 - avcodec.h Change type of AVPacket.duration from int to int64_t. diff --git a/libavutil/dict.c b/libavutil/dict.c index 7f4832092a..7213bf2519 100644 --- a/libavutil/dict.c +++ b/libavutil/dict.c @@ -186,10 +186,15 @@ void av_dict_free(AVDictionary **pm) av_freep(pm); } -void av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags) +int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags) { AVDictionaryEntry *t = NULL; - while ((t = av_dict_get(src, "", t, AV_DICT_IGNORE_SUFFIX))) - av_dict_set(dst, t->key, t->value, flags); + while ((t = av_dict_get(src, "", t, AV_DICT_IGNORE_SUFFIX))) { + int ret = av_dict_set(dst, t->key, t->value, flags); + if (ret < 0) + return ret; + } + + return 0; } diff --git a/libavutil/dict.h b/libavutil/dict.h index e4aee27ca3..b3277ab77c 100644 --- a/libavutil/dict.h +++ b/libavutil/dict.h @@ -130,8 +130,10 @@ int av_dict_parse_string(AVDictionary **pm, const char *str, * @param src pointer to source AVDictionary struct * @param flags flags to use when setting entries in *dst * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag + * @return 0 on success, negative AVERROR code on failure. If dst was allocated + * by this function, callers should free the associated memory. */ -void av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags); +int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags); /** * Free all the memory allocated for an AVDictionary struct diff --git a/libavutil/version.h b/libavutil/version.h index 20059c4678..14a1ded07b 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -54,7 +54,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 1 +#define LIBAVUTIL_VERSION_MINOR 2 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |