aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/f_sendcmd.c
diff options
context:
space:
mode:
authorMarvin Scholz <epirat07@gmail.com>2025-01-30 00:55:48 +0100
committerMarvin Scholz <epirat07@gmail.com>2025-06-11 19:26:22 +0200
commit2c3ac6e0faab98651085bbda825130c4b98ee615 (patch)
treea41cfb4164d9bb8d9ddb97d9d536f2d020262320 /libavfilter/f_sendcmd.c
parent93255f1c487fbf08e7bdbaa853e4e6d86b3882b5 (diff)
downloadffmpeg-2c3ac6e0faab98651085bbda825130c4b98ee615.tar.gz
lavfi/f_sendcmd: add helper to clear Command
Makes clearing the Command more explicit and consistent.
Diffstat (limited to 'libavfilter/f_sendcmd.c')
-rw-r--r--libavfilter/f_sendcmd.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/libavfilter/f_sendcmd.c b/libavfilter/f_sendcmd.c
index 9201fb5381..fc21a88bf4 100644
--- a/libavfilter/f_sendcmd.c
+++ b/libavfilter/f_sendcmd.c
@@ -138,6 +138,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)
{
@@ -217,9 +229,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;
}
@@ -471,9 +481,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);
}