Makes clearing the Command more explicit and consistent.
Unified · Split
| @@ -138,6 +138,18 @@ static void skip_comments(const char **buf) · 137 unmodified lines | ||
| 138 | 138 | |
| 139 | 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 | 153 | static int parse_command(Command *cmd, int cmd_count, int interval_count, |
| 142 | 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 | 229 | return 1; |
| 218 | 230 | |
| 219 | 231 | fail: |
| 220 | − av_freep(&cmd->target); | |
| 221 | − av_freep(&cmd->command); | |
| 222 | − av_freep(&cmd->arg); | |
| 232 | + clear_command(cmd); | |
| 223 | 233 | return ret; |
| 224 | 234 | } |
| 225 | 235 | |
| @@ -471,9 +481,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 245 unmodified lines | ||
| 471 | 481 | Interval *interval = &s->intervals[i]; |
| 472 | 482 | for (j = 0; j < interval->nb_commands; j++) { |
| 473 | 483 | Command *cmd = &interval->commands[j]; |
| 474 | − av_freep(&cmd->target); | |
| 475 | − av_freep(&cmd->command); | |
| 476 | − av_freep(&cmd->arg); | |
| 484 | + clear_command(cmd); | |
| 477 | 485 | } |
| 478 | 486 | av_freep(&interval->commands); |
| 479 | 487 | } |