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
140140 return ret;
141141 fail:
142142 if (ret) {
143− av_freep(&ret->refs);
143+ av_assert1(!ret->refs);
144144 av_freep(&ret->formats);
145+ av_freep(&ret);
145146 }
146− av_freep(&ret);
147147 return NULL;
148148 }
149149
@@ -167,10 +167,10 @@ AVFilterFormats *ff_merge_samplerates(AVFilterFormats *a, · 17 unmodified lines
167167 return ret;
168168 fail:
169169 if (ret) {
170− av_freep(&ret->refs);
170+ av_assert1(!ret->refs);
171171 av_freep(&ret->formats);
172+ av_freep(&ret);
172173 }
173− av_freep(&ret);
174174 return NULL;
175175 }
176176
@@ -260,10 +260,10 @@ AVFilterChannelLayouts *ff_merge_channel_layouts(AVFilterChannelLayouts *a, · 83 unmodified lines
260260
261261 fail:
262262 if (ret) {
263− av_freep(&ret->refs);
263+ av_assert1(!ret->refs);
264264 av_freep(&ret->channel_layouts);
265+ av_freep(&ret);
265266 }
266− av_freep(&ret);
267267 return NULL;
268268 }
269269

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