]> git.sesse.net Git - ffmpeg/commitdiff
lavu/dict: Add new flag to allow multiple equal keys.
authorThilo Borgmann <thilo.borgmann@mail.de>
Sat, 12 Mar 2016 13:52:17 +0000 (14:52 +0100)
committerThilo Borgmann <thilo.borgmann@mail.de>
Fri, 25 Mar 2016 16:08:11 +0000 (17:08 +0100)
libavutil/dict.c
libavutil/dict.h

index 12035627f9c91750c51a1b7b4eb73fb2daa81517..3b509a41c707093fb66fb10d663e708b32899bd5 100644 (file)
@@ -70,9 +70,12 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
                 int flags)
 {
     AVDictionary *m = *pm;
-    AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
+    AVDictionaryEntry *tag = NULL;
     char *oldval = NULL, *copy_key = NULL, *copy_value = NULL;
 
+    if (!(flags & AV_DICT_MULTIKEY)) {
+        tag = av_dict_get(m, key, NULL, flags);
+    }
     if (flags & AV_DICT_DONT_STRDUP_KEY)
         copy_key = (void *)key;
     else
index 542d540f9f7348e5789af82cc44c2f9032b3317b..118f1f00ed2046fa5ae5a2440a5961190d923e3a 100644 (file)
@@ -76,6 +76,7 @@
 #define AV_DICT_DONT_OVERWRITE 16   ///< Don't overwrite existing entries.
 #define AV_DICT_APPEND         32   /**< If the entry already exists, append to it.  Note that no
                                       delimiter is added, the strings are simply concatenated. */
+#define AV_DICT_MULTIKEY       64   /**< Allow to store several equal keys in the dictionary */
 
 typedef struct AVDictionaryEntry {
     char *key;
@@ -121,8 +122,8 @@ int av_dict_count(const AVDictionary *m);
  *
  * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
  * a dictionary struct is allocated and put in *pm.
- * @param key entry key to add to *pm (will be av_strduped depending on flags)
- * @param value entry value to add to *pm (will be av_strduped depending on flags).
+ * @param key entry key to add to *pm (will either be av_strduped or added as a new key depending on flags)
+ * @param value entry value to add to *pm (will be av_strduped or added as a new key depending on flags).
  *        Passing a NULL value will cause an existing entry to be deleted.
  * @return >= 0 on success otherwise an error code <0
  */