--- a/sources/mystring.cpp Sun May 17 22:07:48 2015 +0300 +++ b/sources/mystring.cpp Wed May 27 21:15:52 2015 +0300 @@ -31,7 +31,6 @@ #include <cstring> #include "main.h" #include "mystring.h" -#include "format.h" #include "md5.h" // ------------------------------------------------------------------------------------------------- @@ -313,21 +312,29 @@ // ------------------------------------------------------------------------------------------------- // -void String::sprintf (const char* fmtstr, ...) +void __cdecl String::sprintf (const char* fmtstr, ...) +{ + va_list args; + va_start (args, fmtstr); + this->vsprintf (fmtstr, args); + va_end (args); +} + +// ------------------------------------------------------------------------------------------------- +// +void String::vsprintf (const char* fmtstr, va_list args) { char* buf = nullptr; int bufsize = 256; - va_list va; - va_start (va, fmtstr); do { + bufsize *= 2; delete[] buf; buf = new char[bufsize]; } - while (vsnprintf (buf, bufsize, fmtstr, va) >= bufsize); + while (vsnprintf (buf, bufsize, fmtstr, args) >= bufsize); - va_end (va); m_string = buf; delete[] buf; }