Derek Buitenhuis <derek.buitenh...@gmail.com> writes:

> On 13/06/2012 11:40 PM, Derek Buitenhuis wrote:
>> On 13/06/2012 7:59 PM, Ronald S. Bultje wrote:
>>> - the include of mathematics.h, avconfig.h and avstring.h everywhere
>>> is (I think) legit, to account for snprintf(), M_PI or inline.
>> 
>> We don't need to do this for mathematics.h, as discussed on IRC.
>> 
>> If we define _USE_MATH_DEFINES, we have access to teh usual M_PI, etc.
>> in MSVC's math.h.
>
> And a followup with:
>
> http://msdn.microsoft.com/en-us/library/2ts7cx93%28v=vs.80%29.aspx
>
> or
>
> http://msdn.microsoft.com/en-us/library/f30dzcf6%28v=vs.80%29.aspx

We can't use the Windows _snprintf() since it has the wrong semantics.
The standard snprintf() always null-terminates the output and returns
the full length of the formatted string.  The Windows version does not
null-terminate if the buffer fills up and returns a negative value if
the formatted string is longer than the buffer.  Windows vsnprintf has
the same problem, but wrapping this function, it is at least possible
to ensure the output is null-terminated.  I don't think we rely on the
return value to indicate the would-be size of a truncated output.  We
do, however, use it in ways (x += snprintf()) that would break in case
the buffer fills up and the return value is negative because of this.

-- 
Måns Rullgård
m...@mansr.com
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to