From: Marvin Scholz <epirat07@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Marvin Scholz <epirat07@gmail.com> Subject: [FFmpeg-devel] [PATCH 1/2] lavfi/f_sendcmd: add helper to clear Command Date: Thu, 30 Jan 2025 01:25:51 +0100 Message-ID: <20250130002552.49220-1-epirat07@gmail.com> (raw) Makes clearing the Command more explicit and consistent. --- libavfilter/f_sendcmd.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavfilter/f_sendcmd.c b/libavfilter/f_sendcmd.c index d5d72e6410..8a0c368108 100644 --- a/libavfilter/f_sendcmd.c +++ b/libavfilter/f_sendcmd.c @@ -144,6 +144,18 @@ static void skip_comments(const char **buf) #define COMMAND_DELIMS " \f\t\n\r,;" +/** + * Clears fields and frees the buffers used by @p cmd + */ +static void clear_command(Command *cmd) +{ + cmd->flags = 0; + cmd->index = 0; + av_freep(&cmd->target); + av_freep(&cmd->command); + av_freep(&cmd->arg); +} + static int parse_command(Command *cmd, int cmd_count, int interval_count, const char **buf, void *log_ctx) { @@ -223,9 +235,7 @@ static int parse_command(Command *cmd, int cmd_count, int interval_count, return 1; fail: - av_freep(&cmd->target); - av_freep(&cmd->command); - av_freep(&cmd->arg); + clear_command(cmd); return ret; } @@ -477,9 +487,7 @@ static av_cold void uninit(AVFilterContext *ctx) Interval *interval = &s->intervals[i]; for (j = 0; j < interval->nb_commands; j++) { Command *cmd = &interval->commands[j]; - av_freep(&cmd->target); - av_freep(&cmd->command); - av_freep(&cmd->arg); + clear_command(cmd); } av_freep(&interval->commands); } -- 2.39.5 (Apple Git-154) _______________________________________________ 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".
next reply other threads:[~2025-01-30 0:26 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-01-30 0:25 Marvin Scholz [this message] 2025-01-30 0:25 ` [FFmpeg-devel] [PATCH 2/2] lavfi/f_sendcmd: clear Command on alloc failure Marvin Scholz
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=20250130002552.49220-1-epirat07@gmail.com \ --to=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