Makes clearing the Command more explicit and consistent.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -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 | */ | ||
| 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 | |||
| 141 | static int parse_command(Command *cmd, int cmd_count, int interval_count, | 153 | static 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 | ||
| 219 | fail: | 231 | fail: |
| 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 | } |