Make avfilter_graph_free() free the graph.

Make avfilter_graph_free() free not only the internal structures, but
also the allocated graph, and set the graph pointer to NULL for
increased safety.

Simplify usage.

Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
Stefano Sabatini
2011-02-01 20:02:17 +01:00
committed by Mans Rullgard
parent e8e5dde779
commit 4359288c56
4 changed files with 12 additions and 14 deletions

View File

@@ -32,14 +32,15 @@ AVFilterGraph *avfilter_graph_alloc(void)
return av_mallocz(sizeof(AVFilterGraph));
}
void avfilter_graph_free(AVFilterGraph *graph)
void avfilter_graph_free(AVFilterGraph **graph)
{
if (!graph)
if (!*graph)
return;
for (; graph->filter_count > 0; graph->filter_count --)
avfilter_free(graph->filters[graph->filter_count - 1]);
av_freep(&graph->scale_sws_opts);
av_freep(&graph->filters);
for (; (*graph)->filter_count > 0; (*graph)->filter_count--)
avfilter_free((*graph)->filters[(*graph)->filter_count - 1]);
av_freep(&(*graph)->scale_sws_opts);
av_freep(&(*graph)->filters);
av_freep(graph);
}
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)