[FFmpeg-devel] [PATCH v1 4/4] avformat/hlsenc: use av_asprintf()
Steven Liu
lq at chinaffmpeg.org
Wed Apr 8 18:42:04 EEST 2020
> 2020年4月8日 下午10:48,Nicolas George <george at nsup.org> 写道:
>
> Steven Liu (12020-04-08):
>> I cannot get the mean of BPrint where should or when should use it, maybe you can introduce it,
>> I always think BPrint is used to instead of av_[a]sprintf,
>> because I saw mkver submit 3 patches to modify from snprintf to BPrint
>
> BPrint brings three benefits:
>
> - It keeps track of the string length. It is therefore useful when you
> have several snprintf(). If you have only one, this benefit is
> negated.
>
> - It switches to dynamic allocation if the buffer is too small. If your
> string does not have a bounded size and keeping it entirely is
> important, then replacing a buffer with an arbitrary high limit with
> BPrint is useful.
>
> - Before switching to dynamic allocation, it uses a local buffer in the
> structure (probably on stack). If the string does not need to outlive
> its creation very far, it works. If we need to keep the string, a
> dynamic allocation is necessary anyway.
>
> For this case: (1) there is only one snprintf(), (2) we don't use a
> fixed-size buffer and (3) we'll keep the string.
very clear, I understand it now, Thanks Nicolas.
>
> Regards,
>
> --
> Nicolas George
Thanks
Steven Liu
More information about the ffmpeg-devel
mailing list