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
26982698 }
26992699 }
27002700 #if CONFIG_AVFILTER
2701− if (graph) {
2702− avfilter_graph_free(graph);
2703− av_freep(&graph);
2704− }
2701+ avfilter_graph_free(&graph);
27052702 #endif
27062703
27072704 /* finished ! */
ffplay.c+1−2
@@ -1899,8 +1899,7 @@ static int video_thread(void *arg) · 1898 unmodified lines
18991899 }
19001900 the_end:
19011901 #if CONFIG_AVFILTER
1902− avfilter_graph_free(graph);
1903− av_freep(&graph);
1902+ avfilter_graph_free(&graph);
19041903 #endif
19051904 av_free(frame);
19061905 return 0;
libavfilter/avfiltergraph.c+7−6
@@ -32,14 +32,15 @@ AVFilterGraph *avfilter_graph_alloc(void) · 31 unmodified lines
3232 return av_mallocz(sizeof(AVFilterGraph));
3333 }
3434
35−void avfilter_graph_free(AVFilterGraph *graph)
35+void avfilter_graph_free(AVFilterGraph **graph)
3636 {
37− if (!graph)
37+ if (!*graph)
3838 return;
39− for (; graph->filter_count > 0; graph->filter_count --)
40− avfilter_free(graph->filters[graph->filter_count - 1]);
41− av_freep(&graph->scale_sws_opts);
42− av_freep(&graph->filters);
39+ for (; (*graph)->filter_count > 0; (*graph)->filter_count--)
40+ avfilter_free((*graph)->filters[(*graph)->filter_count - 1]);
41+ av_freep(&(*graph)->scale_sws_opts);
42+ av_freep(&(*graph)->filters);
43+ av_freep(graph);
4344 }
4445
4546 int 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
7979 int avfilter_graph_config(AVFilterGraph *graphctx, AVClass *log_ctx);
8080
8181 /**
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.
8384 */
84−void avfilter_graph_free(AVFilterGraph *graph);
85+void avfilter_graph_free(AVFilterGraph **graph);
8586
8687 /**
8788 * 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