- /* MSVCRT _vsnprintf does not:
- * - null terminate string if insufficient storage
- * - return the number of characters that would've been written
- */
- int ret = _vsnprintf (str, size-1, format, ap);
- str[size-1] = 0; /* ensure the null gets written */
- if (ret == -1)
- {
- /* work out the number of chars that should've been written */
- ret = vasprintf (&str, format, ap);
- if (ret >= 0 && str) free (str);
- }
+ int ret = _vsnprintf (str, size, format, ap);