avoid multiple reallocations in wxString::PrintfV() if vsnprintf() returns the total required size
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36303 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1836,14 +1836,20 @@ int wxString::PrintfV(const wxChar* pszFormat, va_list argptr)
|
|||||||
// vsnprintf() may return either -1 (traditional Unix behaviour) or the
|
// vsnprintf() may return either -1 (traditional Unix behaviour) or the
|
||||||
// total number of characters which would have been written if the
|
// total number of characters which would have been written if the
|
||||||
// buffer were large enough (newer standards such as Unix98)
|
// buffer were large enough (newer standards such as Unix98)
|
||||||
if ( len >= 0 && len <= size )
|
if ( len < 0 )
|
||||||
|
{
|
||||||
|
// still not enough, as we don't know how much we need, double the
|
||||||
|
// current size of the buffer
|
||||||
|
size *= 2;
|
||||||
|
}
|
||||||
|
else if ( len > size )
|
||||||
|
{
|
||||||
|
size = len;
|
||||||
|
}
|
||||||
|
else // ok, there was enough space
|
||||||
{
|
{
|
||||||
// ok, there was enough space
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// still not enough, double it again
|
|
||||||
size *= 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we could have overshot
|
// we could have overshot
|
||||||
|
Reference in New Issue
Block a user