History

avfilter/avfiltergraph: Simplify adding filter to graph

By reallocating the array of pointers to the AVFilterContexts before allocating the new AVFilterContext one can avoid freeing the new AVFilterContext in case the array could not be reallocated. Also switch to av_realloc_array() while just at it.

Andreas Rheinhardt committed 5 years ago

Commit 22c4f331 parent 68815d61 file · +5 −7Browse files

Showing the changes to libavfilter/avfiltergraph.c (1 of 1 file). Show all

Unified · Split

libavfilter/avfiltergraph.c+5−7
@@ -183,17 +183,15 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, · 182 unmodified lines
183 }183 }
184 }184 }
185 185
186 s = ff_filter_alloc(filter, name);186 filters = av_realloc_array(graph->filters, graph->nb_filters + 1, sizeof(*filters));
187 if (!s)187 if (!filters)
188 return NULL;188 return NULL;
189 graph->filters = filters;
189 190
190 filters = av_realloc(graph->filters, sizeof(*filters) * (graph->nb_filters + 1));191 s = ff_filter_alloc(filter, name);
191 if (!filters) {192 if (!s)
192 avfilter_free(s);
193 return NULL;193 return NULL;
194 }
195 194
196 graph->filters = filters;
197 graph->filters[graph->nb_filters++] = s;195 graph->filters[graph->nb_filters++] = s;
198 196
199 s->graph = graph;197 s->graph = graph;

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