sources/mystring.cpp

changeset 83
08bfc3d9d2ae
parent 73
07dda51a7a8e
child 84
3bd32eec3d57
child 88
08ccaf26cffd
--- a/sources/mystring.cpp	Tue May 26 18:19:27 2015 +0300
+++ b/sources/mystring.cpp	Tue May 26 18:46:24 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;
 }

mercurial