[FFmpeg-devel] [PATCH v2 11/14] avfilter/avfilter: Use AV_DICT_DONT_STRDUP_(KEY|VAL) when possible

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Sep 14 02:23:36 EEST 2021


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavfilter/avfilter.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 11d4e01807..cc499fd5ed 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -822,6 +822,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
 
     while (*args) {
         const char *shorthand = NULL;
+        int flags = AV_DICT_DONT_STRDUP_VAL;
 
         o = av_opt_next(ctx->priv, o);
         if (o) {
@@ -846,6 +847,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
             args++;
         if (parsed_key) {
             key = parsed_key;
+            flags |= AV_DICT_DONT_STRDUP_KEY;
             while ((o = av_opt_next(ctx->priv, o))); /* discard all remaining shorthand */
         } else {
             key = shorthand;
@@ -853,10 +855,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options,
 
         av_log(ctx, AV_LOG_DEBUG, "Setting '%s' to value '%s'\n", key, value);
 
-            av_dict_set(options, key, value, 0);
-
-        av_free(value);
-        av_free(parsed_key);
+        av_dict_set(options, key, value, flags);
     }
 
     return 0;
-- 
2.30.2



More information about the ffmpeg-devel mailing list