Quoting wm4 (2017-05-26 20:03:07)
> On Fri, 26 May 2017 19:30:40 +0200
> Anton Khirnov <an...@khirnov.net> wrote:
> 
> > Quoting Luca Barbato (2017-05-23 22:08:49)
> > > On 5/17/17 7:46 PM, Vittorio Giovara wrote:  
> > > > +    av_channel_layout_uninit(dst);
> > > > +    return av_channel_layout_copy(dst, channel_layout);  
> > > 
> > > Maybe put the uninit directly in the layout_copy so there isn't risk to
> > > leak memory if you forget.  
> > 
> > I am against this. Freeing memory should be explicit.
> > 
> 
> Makes for hard to use API.
> 
> Like I never know whether AVFrame dest parameters require the frame to
> be "initialized" or whatever.

Hard? I'd agree with "more verbose", but not hard.
AVFrame should always be in one of two states:
- empty, after it's allocated or unreffed or move_ref()ed from or such
- filled, when somebody put something in it
When you pass it to any APIs that write into it, it should be empty. I
don't see how that is hard, it seems pretty intuitive to me.

OTOH implicit frees make it easy to leak stuff, because then it becomes
unclear what you do or don't have to free explicitily.

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to