This is required for letting applications to create and destroy AVFilterInOut structs in a convenient way.
Showing the changes to libavfilter/graphparser.c (1 of 6 files). Show all
Unified · Split
| @@ -170,13 +170,18 @@ static int parse_filter(AVFilterContext **filt_ctx, const char **buf, AVFilterGr · 169 unmodified lines | ||
| 170 | 170 | return ret; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | −static void free_inout(AVFilterInOut *head) | |
| 173 | +AVFilterInOut *avfilter_inout_alloc(void) | |
| 174 | 174 | { |
| 175 | − while (head) { | |
| 176 | − AVFilterInOut *next = head->next; | |
| 177 | − av_free(head->name); | |
| 178 | − av_free(head); | |
| 179 | − head = next; | |
| 175 | + return av_mallocz(sizeof(AVFilterInOut)); | |
| 176 | +} | |
| 177 | + | |
| 178 | +void avfilter_inout_free(AVFilterInOut **inout) | |
| 179 | +{ | |
| 180 | + while (*inout) { | |
| 181 | + AVFilterInOut *next = (*inout)->next; | |
| 182 | + av_freep(&(*inout)->name); | |
| 183 | + av_freep(inout); | |
| 184 | + *inout = next; | |
| 180 | 185 | } |
| 181 | 186 | } |
| 182 | 187 | |
| @@ -431,9 +436,9 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, · 248 unmodified lines | ||
| 431 | 436 | for (; graph->filter_count > 0; graph->filter_count--) |
| 432 | 437 | avfilter_free(graph->filters[graph->filter_count - 1]); |
| 433 | 438 | av_freep(&graph->filters); |
| 434 | − free_inout(open_inputs); | |
| 435 | − free_inout(open_outputs); | |
| 436 | − free_inout(curr_inputs); | |
| 439 | + avfilter_inout_free(&open_inputs); | |
| 440 | + avfilter_inout_free(&open_outputs); | |
| 441 | + avfilter_inout_free(&curr_inputs); | |
| 437 | 442 | |
| 438 | 443 | *inputs = NULL; |
| 439 | 444 | *outputs = NULL; |
| @@ -467,7 +472,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 27 unmodified lines | ||
| 467 | 472 | continue; |
| 468 | 473 | ret = avfilter_link(match->filter_ctx, match->pad_idx, |
| 469 | 474 | cur->filter_ctx, cur->pad_idx); |
| 470 | − free_inout(match); | |
| 475 | + avfilter_inout_free(&match); | |
| 471 | 476 | if (ret < 0) |
| 472 | 477 | goto fail; |
| 473 | 478 | } |
| @@ -487,7 +492,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 13 unmodified lines | ||
| 487 | 492 | continue; |
| 488 | 493 | ret = avfilter_link(cur->filter_ctx, cur->pad_idx, |
| 489 | 494 | match->filter_ctx, match->pad_idx); |
| 490 | − free_inout(match); | |
| 495 | + avfilter_inout_free(&match); | |
| 491 | 496 | if (ret < 0) |
| 492 | 497 | goto fail; |
| 493 | 498 | } |
| @@ -498,9 +503,9 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 4 unmodified lines | ||
| 498 | 503 | avfilter_free(graph->filters[graph->filter_count - 1]); |
| 499 | 504 | av_freep(&graph->filters); |
| 500 | 505 | } |
| 501 | − free_inout(inputs); | |
| 502 | − free_inout(outputs); | |
| 503 | − free_inout(open_inputs); | |
| 504 | − free_inout(open_outputs); | |
| 506 | + avfilter_inout_free(&inputs); | |
| 507 | + avfilter_inout_free(&outputs); | |
| 508 | + avfilter_inout_free(&open_inputs); | |
| 509 | + avfilter_inout_free(&open_outputs); | |
| 505 | 510 | return ret; |
| 506 | 511 | } |