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
138 138
139#define COMMAND_DELIMS " \f\t\n\r,;"139#define COMMAND_DELIMS " \f\t\n\r,;"
140 140
141/**
142 * Clears fields and frees the buffers used by @p cmd
143 */
144static 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
141static int parse_command(Command *cmd, int cmd_count, int interval_count,153static int parse_command(Command *cmd, int cmd_count, int interval_count,
142 const char **buf, void *log_ctx)154 const char **buf, void *log_ctx)
143{155{
@@ -217,9 +229,7 @@ static int parse_command(Command *cmd, int cmd_count, int interval_count, · 73 unmodified lines
217 return 1;229 return 1;
218 230
219fail:231fail:
220 av_freep(&cmd->target);232 clear_command(cmd);
221 av_freep(&cmd->command);
222 av_freep(&cmd->arg);
223 return ret;233 return ret;
224}234}
225 235
@@ -471,9 +481,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 245 unmodified lines
471 Interval *interval = &s->intervals[i];481 Interval *interval = &s->intervals[i];
472 for (j = 0; j < interval->nb_commands; j++) {482 for (j = 0; j < interval->nb_commands; j++) {
473 Command *cmd = &interval->commands[j];483 Command *cmd = &interval->commands[j];
474 av_freep(&cmd->target);484 clear_command(cmd);
475 av_freep(&cmd->command);
476 av_freep(&cmd->arg);
477 }485 }
478 av_freep(&interval->commands);486 av_freep(&interval->commands);
479 }487 }

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