History

avfilter/formats: Simplify cleanup for ff_merge_* functions

Now that the output's refs-array is only allocated once, it is NULL in any error case and therefore needn't be freed at all; Instead an av_assert1() has been added to guarantee it to be NULL. Furthermore, it is unnecessary to av_freep(&ptr) when ptr == NULL.

Andreas Rheinhardt committed 6 years ago

Commit 9d1bf9c1 parent 195a25a1 file · +6 −6Browse files

Unified · Split

libavfilter/formats.c+6−6
@@ -140,10 +140,10 @@ AVFilterFormats *ff_merge_formats(AVFilterFormats *a, AVFilterFormats *b, · 139 unmodified lines
140 return ret;140 return ret;
141fail:141fail:
142 if (ret) {142 if (ret) {
143 av_freep(&ret->refs);143 av_assert1(!ret->refs);
144 av_freep(&ret->formats);144 av_freep(&ret->formats);
145 av_freep(&ret);
145 }146 }
146 av_freep(&ret);
147 return NULL;147 return NULL;
148}148}
149 149
@@ -167,10 +167,10 @@ AVFilterFormats *ff_merge_samplerates(AVFilterFormats *a, · 17 unmodified lines
167 return ret;167 return ret;
168fail:168fail:
169 if (ret) {169 if (ret) {
170 av_freep(&ret->refs);170 av_assert1(!ret->refs);
171 av_freep(&ret->formats);171 av_freep(&ret->formats);
172 av_freep(&ret);
172 }173 }
173 av_freep(&ret);
174 return NULL;174 return NULL;
175}175}
176 176
@@ -260,10 +260,10 @@ AVFilterChannelLayouts *ff_merge_channel_layouts(AVFilterChannelLayouts *a, · 83 unmodified lines
260 260
261fail:261fail:
262 if (ret) {262 if (ret) {
263 av_freep(&ret->refs);263 av_assert1(!ret->refs);
264 av_freep(&ret->channel_layouts);264 av_freep(&ret->channel_layouts);
265 av_freep(&ret);
265 }266 }
266 av_freep(&ret);
267 return NULL;267 return NULL;
268}268}
269 269

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