1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

lavfi/f_sendcmd: add helper to clear Command

Makes clearing the Command more explicit and
consistent.
This commit is contained in:
Marvin Scholz
2025-01-30 00:55:48 +01:00
parent 93255f1c48
commit 2c3ac6e0fa

View File

@ -138,6 +138,18 @@ static void skip_comments(const char **buf)
#define COMMAND_DELIMS " \f\t\n\r,;" #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, static int parse_command(Command *cmd, int cmd_count, int interval_count,
const char **buf, void *log_ctx) const char **buf, void *log_ctx)
{ {
@ -217,9 +229,7 @@ static int parse_command(Command *cmd, int cmd_count, int interval_count,
return 1; return 1;
fail: fail:
av_freep(&cmd->target); clear_command(cmd);
av_freep(&cmd->command);
av_freep(&cmd->arg);
return ret; return ret;
} }
@ -471,9 +481,7 @@ static av_cold void uninit(AVFilterContext *ctx)
Interval *interval = &s->intervals[i]; Interval *interval = &s->intervals[i];
for (j = 0; j < interval->nb_commands; j++) { for (j = 0; j < interval->nb_commands; j++) {
Command *cmd = &interval->commands[j]; Command *cmd = &interval->commands[j];
av_freep(&cmd->target); clear_command(cmd);
av_freep(&cmd->command);
av_freep(&cmd->arg);
} }
av_freep(&interval->commands); av_freep(&interval->commands);
} }