History

lavfi/f_sendcmd: add helper to clear Command

Makes clearing the Command more explicit and consistent.

Marvin Scholz committed 1 year ago

Commit 2c3ac6e1 parent 93255f11 file · +14 −6Browse files

Unified · Split

libavfilter/f_sendcmd.c+14−6
@@ -138,6 +138,18 @@ static void skip_comments(const char **buf) · 137 unmodified lines
138138
139139 #define COMMAND_DELIMS " \f\t\n\r,;"
140140
141+/**
142+ * Clears fields and frees the buffers used by @p cmd
143+ */
144+static void clear_command(Command *cmd)
145+{
146+ cmd->flags = 0;
147+ cmd->index = 0;
148+ av_freep(&cmd->target);
149+ av_freep(&cmd->command);
150+ av_freep(&cmd->arg);
151+}
152+
141153 static int parse_command(Command *cmd, int cmd_count, int interval_count,
142154 const char **buf, void *log_ctx)
143155 {
@@ -217,9 +229,7 @@ static int parse_command(Command *cmd, int cmd_count, int interval_count, · 73 unmodified lines
217229 return 1;
218230
219231 fail:
220− av_freep(&cmd->target);
221− av_freep(&cmd->command);
222− av_freep(&cmd->arg);
232+ clear_command(cmd);
223233 return ret;
224234 }
225235
@@ -471,9 +481,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 245 unmodified lines
471481 Interval *interval = &s->intervals[i];
472482 for (j = 0; j < interval->nb_commands; j++) {
473483 Command *cmd = &interval->commands[j];
474− av_freep(&cmd->target);
475− av_freep(&cmd->command);
476− av_freep(&cmd->arg);
484+ clear_command(cmd);
477485 }
478486 av_freep(&interval->commands);
479487 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t