From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTP id 92C3045C99
	for <ffmpegdev@gitmailbox.com>; Sun,  2 Jul 2023 08:47:42 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2680B68C09C;
	Sun,  2 Jul 2023 11:47:40 +0300 (EEST)
Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com
 [209.85.218.45])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 13F3568BE16
 for <ffmpeg-devel@ffmpeg.org>; Sun,  2 Jul 2023 11:47:34 +0300 (EEST)
Received: by mail-ej1-f45.google.com with SMTP id
 a640c23a62f3a-99364ae9596so17060066b.1
 for <ffmpeg-devel@ffmpeg.org>; Sun, 02 Jul 2023 01:47:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1688287652; x=1690879652;
 h=user-agent:in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:to:from:date:from:to:cc:subject
 :date:message-id:reply-to;
 bh=eoA1GKECXYM7djtclgRHtmxhCPIa1lBshgdAWA2Kl/c=;
 b=sDo6BPkSMSUY1m1vNvubySRL2xseS9rwoug69SnKT/1ZUV36sGGq8tgG75h0/k1NrE
 dLHro4XGNm4ExkzdDsCfxm08e0I4qOYcipWw5bgWPrUoDnICtGSPve7KnKSQXgKXbJQR
 zsr1Pp1dkyU9fJJ3xltTI1OhhrRuKlHpXKnPRQ4PMjczZPhJB7Y2zVfjd/DNN+t1XdKa
 6Yc1A6s5vs1PV7mPJ2iAUgha18dA4k4Vdb9/Sxvxv5W49xyXcH5rTatjkRJhR4CVffHH
 cHx9AjR/MiIfYSKSP3fTfP5rGj6vS+YS3kWsfcxadmk/gh1RE9UlqbAWy6ym3hwqcLTo
 0Ntg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1688287652; x=1690879652;
 h=user-agent:in-reply-to:content-disposition:mime-version:references
 :mail-followup-to:message-id:subject:to:from:date:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=eoA1GKECXYM7djtclgRHtmxhCPIa1lBshgdAWA2Kl/c=;
 b=Yst3d4oVPvDIkxO1/7XbU6P3IxLRwvH0vyt5Jxrp9hxoT8JTmp6QKP+TQu46Ljx35v
 362XX4U5ZbyAx6LiZZ81LQcg6TY3XvcrTQ18alNUZ18xOOZN4/LbeuXu62oIaYQnSUfG
 6IGmAhr8fV0hF6ukS4I+fTCseAASKP45R8evMdkB8uO+foHi6nbBf9xu4IDBp2hGSTn0
 N3OK5aDeGygjoio0HbqzcgfcqD5z74nshlMl5tVy0FUbbeAICxYGJCQqnmQy2kgriNK6
 uPolBXUFI+Tvu4IeEg4rZqMPoeTkqomw6G73omFbgdQDcdzcZZO6OzJX3hbpyDgYON0Z
 cZKg==
X-Gm-Message-State: ABy/qLZscG4j4xZTvBl/2tX/HM+RrFM1JS6oezwaVpoLLRktOBgJSfUg
 nK8/b07OrXrRjShKGhLz+8n7xYa6Csc=
X-Google-Smtp-Source: APBJJlEGMv8aCXBDoo/yuOkZhQfxbsitkTH4PDVIVEv3gvgyqvVVbqr5JY0aMgSJysKpjJ4aXQ27qA==
X-Received: by 2002:a17:907:76ce:b0:992:ef60:ab0d with SMTP id
 kf14-20020a17090776ce00b00992ef60ab0dmr4463478ejc.69.1688287652154; 
 Sun, 02 Jul 2023 01:47:32 -0700 (PDT)
Received: from mariano ([91.254.84.241]) by smtp.gmail.com with ESMTPSA id
 qx22-20020a170906fcd600b009931baa0d44sm1929091ejb.140.2023.07.02.01.47.31
 for <ffmpeg-devel@ffmpeg.org>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 02 Jul 2023 01:47:31 -0700 (PDT)
Received: by mariano (Postfix, from userid 1000)
 id 4B6ECBFB73; Sun,  2 Jul 2023 10:47:30 +0200 (CEST)
Date: Sun, 2 Jul 2023 10:47:30 +0200
From: Stefano Sabatini <stefasab@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Message-ID: <20230702084730.GB4218@mariano>
Mail-Followup-To: FFmpeg development discussions and patches
 <ffmpeg-devel@ffmpeg.org>
References: <20230501114456.13898-1-epirat07@gmail.com>
 <20230625104907.53071-1-epirat07@gmail.com>
 <20230625104907.53071-2-epirat07@gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <20230625104907.53071-2-epirat07@gmail.com>
User-Agent: Mutt/1.13.2 (2019-12-18)
Subject: Re: [FFmpeg-devel] [PATCH v2 2/3] avformat/tee: use av_dict_pop
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20230702084730.GB4218@mariano/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

On date Sunday 2023-06-25 12:49:06 +0200, Marvin Scholz wrote:
> This is a well-defined way to "steal" the value of the dict entry.
> ---
>  libavformat/tee.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/tee.c b/libavformat/tee.c
> index cb555f52fd..70f3f2eb29 100644
> --- a/libavformat/tee.c
> +++ b/libavformat/tee.c
> @@ -157,6 +157,7 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
>  {
>      int i, ret;
>      AVDictionary *options = NULL, *bsf_options = NULL;
> +    char *entry_val = NULL;
>      AVDictionaryEntry *entry;
>      char *filename;
>      char *format = NULL, *select = NULL, *on_fail = NULL;
> @@ -171,15 +172,15 @@ static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
>          return ret;
>  
>  #define CONSUME_OPTION(option, field, action) do {                      \
> -        if ((entry = av_dict_get(options, option, NULL, 0))) {          \
> -            field = entry->value;                                       \
> +        if ((!av_dict_pop(&options, option, NULL, &entry_val, 0))) {    \
> +            field = entry_val;                                          \
>              { action }                                                  \
> -            av_dict_set(&options, option, NULL, 0);                     \
> +            av_freep(&entry_val);                                       \
>          }                                                               \
>      } while (0)
>  #define STEAL_OPTION(option, field)                                     \
>      CONSUME_OPTION(option, field,                                       \
> -                   entry->value = NULL; /* prevent it from being freed */)
> +                   entry_val = NULL; /* prevent it from being freed */)
>  #define PROCESS_OPTION(option, field, function, on_error)               \
>      CONSUME_OPTION(option, field, if ((ret = function) < 0) { { on_error } goto end; })

LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".