[FFmpeg-devel] [PATCH 1/2] avutil/bprint: add av_vbprintf()
Nicolas George
nicolas.george at normalesup.org
Sat Aug 10 16:34:56 CEST 2013
Le tridi 23 thermidor, an CCXXI, Michael Niedermayer a écrit :
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
> libavutil/bprint.c | 23 +++++++++++++++++++++++
> libavutil/bprint.h | 7 +++++++
> 2 files changed, 30 insertions(+)
>
> diff --git a/libavutil/bprint.c b/libavutil/bprint.c
> index fd7611a..e779956 100644
> --- a/libavutil/bprint.c
> +++ b/libavutil/bprint.c
> @@ -113,6 +113,29 @@ void av_bprintf(AVBPrint *buf, const char *fmt, ...)
> av_bprint_grow(buf, extra_len);
> }
>
> +void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
> +{
> + unsigned room;
> + char *dst;
> + int extra_len;
> + va_list vl;
> +
> + while (1) {
> + room = av_bprint_room(buf);
> + dst = room ? buf->str + buf->len : NULL;
> + va_copy(vl, vl_arg);
> + extra_len = vsnprintf(dst, room, fmt, vl);
> + va_end(vl);
> + if (extra_len <= 0)
> + return;
> + if (extra_len < room)
> + break;
> + if (av_bprint_alloc(buf, extra_len))
> + break;
> + }
> + av_bprint_grow(buf, extra_len);
> +}
Looks ok.
av_bprintf() could be rewritten to call it instead of duplicating the code,
but that can be done later.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130810/144c7dcc/attachment.asc>
More information about the ffmpeg-devel
mailing list