sources/mystring.cpp

branch
protocol5
changeset 84
3bd32eec3d57
parent 79
62cfb7b97fc0
parent 83
08bfc3d9d2ae
child 103
b78c0ca832a9
--- 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;
 }

mercurial