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

master
Andrzej Rybczak 17 years ago
parent c0fcac9b1d
commit b8c9d149b1
  1. 3
      src/window.cpp

@ -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;
} }

Loading…
Cancel
Save