-----Original Message----- From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Carl Eugen Hoyos Sent: Saturday, March 9, 2019 5:07 AM To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH v7 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper.
2019-03-08 11:36 GMT+01:00, Jing SUN <jing.a....@intel.com>: > +static void free_buffer(SvtContext *svt_enc) { > + EB_H265_ENC_INPUT *in_data = > (EB_H265_ENC_INPUT *)svt_enc->in_buf.pBuffer; Is the cast necessary? Or actually: Can't in_data be whatever doesn't produce a warning? [SUN, Jing] Yes, it's necessary, because the type of pBuffer is uint8_t* in libsvt_hevc. > + > + if (in_data) > + av_freep(&in_data); The condition is unnecessary. [SUN, Jing] If av_mallocz fails, free_buffer will be called with in_data being NULL. Checking it avoids unnecessary calling to av_freep in that case. static void free_buffer(SvtContext *svt_enc) { ... if (in_data) av_freep(&in_data); } static int alloc_buffer(EB_H265_ENC_CONFIGURATION *config, SvtContext *svt_enc) { ... in_data = av_mallocz(sizeof(*in_data)); if (!in_data) goto failed; ... failed: free_buffer(svt_enc); ... } _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel