aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2011-02-01 20:02:17 +0100
committerMans Rullgard <mans@mansr.com>2011-02-04 02:55:11 +0000
commit4359288c565705d1734f63d277f8918ee5af5e54 (patch)
treef558512cc95ab6e2157bce2b56d6be911f0a0273 /libavfilter
parente8e5dde779fca80d86e00baea26d1baca333f4c0 (diff)
downloadffmpeg-4359288c565705d1734f63d277f8918ee5af5e54.tar.gz
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>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/avfiltergraph.c13
-rw-r--r--libavfilter/avfiltergraph.h5
2 files changed, 10 insertions, 8 deletions
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)
diff --git a/libavfilter/avfiltergraph.h b/libavfilter/avfiltergraph.h
index 1b0d242dc5..0140af0801 100644
--- a/libavfilter/avfiltergraph.h
+++ b/libavfilter/avfiltergraph.h
@@ -79,9 +79,10 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt,
int avfilter_graph_config(AVFilterGraph *graphctx, AVClass *log_ctx);
/**
- * Free a graph and destroy its links, graph may be NULL.
+ * Free a graph, destroy its links, and set *graph to NULL.
+ * If *graph is NULL, do nothing.
*/
-void avfilter_graph_free(AVFilterGraph *graph);
+void avfilter_graph_free(AVFilterGraph **graph);
/**
* A linked-list of the inputs/outputs of the filter chain.