diff mbox series

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

Message ID AM7PR03MB6660CD23879ADDDFF01946DD8FD99@AM7PR03MB6660.eurprd03.prod.outlook.com
State New
Headers show
Series [FFmpeg-devel,v2,01/14] avfilter/vsrc_testsrc: Deduplicate AVClasses | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 13, 2021, 11:23 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/avfilter.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Nicolas George Sept. 16, 2021, 12:43 p.m. UTC | #1
Andreas Rheinhardt (12021-09-14):
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavfilter/avfilter.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

LGTM.

Regards,
diff mbox series

Patch

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;