On Tue, Oct 06, 2015 at 04:40:36PM +0200, Nicolas George wrote: > Le quartidi 14 vendémiaire, an CCXXIV, Ganesh Ajjanagadde a écrit : > > - ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); > > + if (!layouts) > > + return AVERROR(ENOMEM); > > + if ((ret = ff_channel_layouts_ref(layouts, > > &inlink->out_channel_layouts)) < 0) { > > + ff_channel_layouts_unref(&layouts); > > + return ret; > > This is a pattern that comes frequently, there is probably room for code > factorization. > > How about this: currently, ff_formats_ref() and cousins reject NULL with > AVERROR_BUG. If it is changed to return AVERROR(ENOMEM) instead, then all > the "if (!formats) return AVERROR(ENOMEM);" become unnecessary. > > Second, if ff_formats_ref() is changed to unref the format list on failure, > then all the unref become unnecessary. The changed code would be just: > > layouts = ff_all_channel_counts(); > - ff_channel_layouts_ref(layouts, &inlink->out_channel_layouts); > + if ((ret = ff_channel_layouts_ref(layouts, > &inlink->out_channel_layouts)) < 0) > + return ret; > > That is rather less cluttered.
+1 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The worst form of inequality is to try to make unequal things equal. -- Aristotle
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel