[FFmpeg-devel] [PATCH] lavu: add snprintf(), vsnprint() and strtod() replacements for MS runtime.
jamal
jamrial at gmail.com
Mon Aug 27 07:27:47 CEST 2012
On 26/08/12 11:55 PM, Ronald S. Bultje wrote:
> +int avpriv_vsnprintf(char *restrict s, size_t n, const char *restrict fmt,
> + va_list ap)
> +{
> + int ret;
> +
> + if (n == 0)
> + return 0;
> + else if (n > INT_MAX)
> + return AVERROR(EINVAL);
> +
> + /* we use n - 1 here because if the buffer is not big enough, the MS
> + * runtime libraries don't add a terminating zero at the end. MSDN
> + * recommends to provide _snprintf/_vsnprintf() a buffer size that
> + * is one less than the actual buffer, and zero it before calling
> + * _snprintf/_vsnprintf() to workaround this problem.
> + * See http://msdn.microsoft.com/en-us/library/1kt27hek(v=vs.80).aspx */
> + memset(s, 0, n);
> + ret = vsnprintf(s, n - 1, fmt, ap);
This should be _vsnprintf.
I just noticed it now, sorry for sending two emails.
Regards.
More information about the ffmpeg-devel
mailing list