Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "\"zhilizhao(赵志立)\"" <quinkblack@foxmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Marvin Scholz <epirat07@gmail.com>
Subject: Re: [FFmpeg-devel] [PATCH 2/3] avformat/tee: use av_dict_pop
Date: Sun, 25 Jun 2023 20:07:31 +0800
Message-ID: <tencent_30D5CF88D5192717B8AC162C4D78205A4D07@qq.com> (raw)
In-Reply-To: <20230501114456.13898-2-epirat07@gmail.com>



> On May 1, 2023, at 19:44, Marvin Scholz <epirat07@gmail.com> 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;                                          \

Nit: You can remove the extra level of parentheses now.

>             { 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; })
> 
> -- 
> 2.37.0 (Apple Git-136)
> 
> _______________________________________________
> 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".

_______________________________________________
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".

  reply	other threads:[~2023-06-25 12:08 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-01 11:44 [FFmpeg-devel] [PATCH 1/3] avutil/dict: add av_dict_pop Marvin Scholz
2023-05-01 11:44 ` [FFmpeg-devel] [PATCH 2/3] avformat/tee: use av_dict_pop Marvin Scholz
2023-06-25 12:07   ` "zhilizhao(赵志立)" [this message]
2023-05-01 11:44 ` [FFmpeg-devel] [PATCH 3/3] avutil/dict: constify av_dict_get return Marvin Scholz
2023-06-05 10:05   ` Anton Khirnov
2023-05-21 23:52 ` [FFmpeg-devel] [PATCH 1/3] avutil/dict: add av_dict_pop Stefano Sabatini
2023-05-22  9:23   ` Marvin Scholz
2023-05-26  6:05     ` Stefano Sabatini
2023-05-26  9:11       ` Marvin Scholz
2023-05-26 20:02         ` Michael Niedermayer
2023-05-26 20:51           ` Marvin Scholz
2023-05-26 20:06         ` James Almer
2023-06-04 14:25         ` Stefano Sabatini
2023-06-04 14:34           ` Marvin Scholz
2023-06-05  8:08             ` Stefano Sabatini
2023-06-05 10:09               ` Anton Khirnov
2023-06-05 10:04 ` Anton Khirnov
2023-06-25 10:49 ` [FFmpeg-devel] [PATCH v2 " Marvin Scholz
2023-06-25 10:49   ` [FFmpeg-devel] [PATCH v2 2/3] avformat/tee: use av_dict_pop Marvin Scholz
2023-07-02  8:47     ` Stefano Sabatini
2023-06-25 10:49   ` [FFmpeg-devel] [PATCH v2 3/3] avutil/dict: constify av_dict_get return Marvin Scholz
2023-07-02  9:06     ` Stefano Sabatini
2023-07-02  8:43   ` [FFmpeg-devel] [PATCH v2 1/3] avutil/dict: add av_dict_pop Stefano Sabatini
2023-07-02 11:49     ` Marvin Scholz
2023-07-03  0:18   ` Andreas Rheinhardt
2023-07-03  9:11     ` Marvin Scholz
2023-07-03 18:02       ` Andreas Rheinhardt
2023-07-03 22:41         ` Marvin Scholz
2023-10-20  8:18         ` Anton Khirnov
2023-10-20 14:00           ` Andreas Rheinhardt
2023-10-20 14:33             ` Anton Khirnov
2023-10-20 15:42               ` Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_30D5CF88D5192717B8AC162C4D78205A4D07@qq.com \
    --to=quinkblack@foxmail.com \
    --cc=epirat07@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git