History

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.

Stefano Sabatini committed 15 years ago

Commit 43592881 parent e8e5dde4 files · +12 −14Browse files

Unified · Split

4 files
  1. ffmpeg.c +1 −4
  2. ffplay.c +1 −2
  3. libavfilter/avfiltergraph.c +7 −6
  4. libavfilter/avfiltergraph.h +3 −2
ffmpeg.c+1−4
@@ -2698,10 +2698,7 @@ static int transcode(AVFormatContext **output_files, · 2697 unmodified lines
2698 }2698 }
2699 }2699 }
2700#if CONFIG_AVFILTER2700#if CONFIG_AVFILTER
2701 if (graph) {2701 avfilter_graph_free(&graph);
2702 avfilter_graph_free(graph);
2703 av_freep(&graph);
2704 }
2705#endif2702#endif
2706 2703
2707 /* finished ! */2704 /* finished ! */
ffplay.c+1−2
@@ -1899,8 +1899,7 @@ static int video_thread(void *arg) · 1898 unmodified lines
1899 }1899 }
1900 the_end:1900 the_end:
1901#if CONFIG_AVFILTER1901#if CONFIG_AVFILTER
1902 avfilter_graph_free(graph);1902 avfilter_graph_free(&graph);
1903 av_freep(&graph);
1904#endif1903#endif
1905 av_free(frame);1904 av_free(frame);
1906 return 0;1905 return 0;
libavfilter/avfiltergraph.c+7−6
@@ -32,14 +32,15 @@ AVFilterGraph *avfilter_graph_alloc(void) · 31 unmodified lines
32 return av_mallocz(sizeof(AVFilterGraph));32 return av_mallocz(sizeof(AVFilterGraph));
33}33}
34 34
35void avfilter_graph_free(AVFilterGraph *graph)35void avfilter_graph_free(AVFilterGraph **graph)
36{36{
37 if (!graph)37 if (!*graph)
38 return;38 return;
39 for (; graph->filter_count > 0; graph->filter_count --)39 for (; (*graph)->filter_count > 0; (*graph)->filter_count--)
40 avfilter_free(graph->filters[graph->filter_count - 1]);40 avfilter_free((*graph)->filters[(*graph)->filter_count - 1]);
41 av_freep(&graph->scale_sws_opts);41 av_freep(&(*graph)->scale_sws_opts);
42 av_freep(&graph->filters);42 av_freep(&(*graph)->filters);
43 av_freep(graph);
43}44}
44 45
45int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)46int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
libavfilter/avfiltergraph.h+3−2
@@ -79,9 +79,10 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, · 78 unmodified lines
79int avfilter_graph_config(AVFilterGraph *graphctx, AVClass *log_ctx);79int avfilter_graph_config(AVFilterGraph *graphctx, AVClass *log_ctx);
80 80
81/**81/**
82 * Free a graph and destroy its links, graph may be NULL.82 * Free a graph, destroy its links, and set *graph to NULL.
83 * If *graph is NULL, do nothing.
83 */84 */
84void avfilter_graph_free(AVFilterGraph *graph);85void avfilter_graph_free(AVFilterGraph **graph);
85 86
86/**87/**
87 * A linked-list of the inputs/outputs of the filter chain.88 * A linked-list of the inputs/outputs of the filter chain.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t