do not allocate mem for s in ToString on heap since it has const size

This commit is contained in:
Andrzej Rybczak
2009-09-06 05:41:41 +02:00
parent c0fcac9b1d
commit b8c9d149b1

View File

@@ -866,14 +866,13 @@ Window * Window::EmptyClone() const
std::string ToString(const std::wstring &ws) std::string ToString(const std::wstring &ws)
{ {
std::string result; std::string result;
char *s = new char[MB_CUR_MAX]; char s[MB_CUR_MAX];
for (size_t i = 0; i < ws.length(); ++i) for (size_t i = 0; i < ws.length(); ++i)
{ {
int n = wcrtomb(s, ws[i], 0); int n = wcrtomb(s, ws[i], 0);
if (n > 0) if (n > 0)
result.append(s, n); result.append(s, n);
} }
delete [] s;
return result; return result;
} }