From 4359288c565705d1734f63d277f8918ee5af5e54 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Tue, 1 Feb 2011 20:02:17 +0100 Subject: 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 --- libavfilter/avfiltergraph.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libavfilter/avfiltergraph.c') diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index a62fe2f79d..bdf22b3df9 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -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) -- cgit v1.2.3