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 | return ret; | 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) { | 175 | return av_mallocz(sizeof(AVFilterInOut)); |
| 176 | AVFilterInOut *next = head->next; | 176 | } |
| 177 | av_free(head->name); | 177 | |
| 178 | av_free(head); | 178 | void avfilter_inout_free(AVFilterInOut **inout) |
| 179 | head = next; | 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 | for (; graph->filter_count > 0; graph->filter_count--) | 436 | for (; graph->filter_count > 0; graph->filter_count--) |
| 432 | avfilter_free(graph->filters[graph->filter_count - 1]); | 437 | avfilter_free(graph->filters[graph->filter_count - 1]); |
| 433 | av_freep(&graph->filters); | 438 | av_freep(&graph->filters); |
| 434 | free_inout(open_inputs); | 439 | avfilter_inout_free(&open_inputs); |
| 435 | free_inout(open_outputs); | 440 | avfilter_inout_free(&open_outputs); |
| 436 | free_inout(curr_inputs); | 441 | avfilter_inout_free(&curr_inputs); |
| 437 | 442 | ||
| 438 | *inputs = NULL; | 443 | *inputs = NULL; |
| 439 | *outputs = NULL; | 444 | *outputs = NULL; |
| @@ -467,7 +472,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 27 unmodified lines | |||
| 467 | continue; | 472 | continue; |
| 468 | ret = avfilter_link(match->filter_ctx, match->pad_idx, | 473 | ret = avfilter_link(match->filter_ctx, match->pad_idx, |
| 469 | cur->filter_ctx, cur->pad_idx); | 474 | cur->filter_ctx, cur->pad_idx); |
| 470 | free_inout(match); | 475 | avfilter_inout_free(&match); |
| 471 | if (ret < 0) | 476 | if (ret < 0) |
| 472 | goto fail; | 477 | goto fail; |
| 473 | } | 478 | } |
| @@ -487,7 +492,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 13 unmodified lines | |||
| 487 | continue; | 492 | continue; |
| 488 | ret = avfilter_link(cur->filter_ctx, cur->pad_idx, | 493 | ret = avfilter_link(cur->filter_ctx, cur->pad_idx, |
| 489 | match->filter_ctx, match->pad_idx); | 494 | match->filter_ctx, match->pad_idx); |
| 490 | free_inout(match); | 495 | avfilter_inout_free(&match); |
| 491 | if (ret < 0) | 496 | if (ret < 0) |
| 492 | goto fail; | 497 | goto fail; |
| 493 | } | 498 | } |
| @@ -498,9 +503,9 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 4 unmodified lines | |||
| 498 | avfilter_free(graph->filters[graph->filter_count - 1]); | 503 | avfilter_free(graph->filters[graph->filter_count - 1]); |
| 499 | av_freep(&graph->filters); | 504 | av_freep(&graph->filters); |
| 500 | } | 505 | } |
| 501 | free_inout(inputs); | 506 | avfilter_inout_free(&inputs); |
| 502 | free_inout(outputs); | 507 | avfilter_inout_free(&outputs); |
| 503 | free_inout(open_inputs); | 508 | avfilter_inout_free(&open_inputs); |
| 504 | free_inout(open_outputs); | 509 | avfilter_inout_free(&open_outputs); |
| 505 | return ret; | 510 | return ret; |
| 506 | } | 511 | } |