Re: [SSGM 4.0 Plugin] RadioCommands [message #470764 is a reply to message #470748] |
Thu, 05 July 2012 04:23 |
|
cAmpa
Messages: 597 Registered: March 2006
Karma:
|
Colonel |
|
|
TT should remove WideCharToChar or replace it with this function.
This one doesn't create memleaks.
Quote: | const char* WideCharToChar
(const wchar_t* string)
{
struct AutoDelete
{
public:
char* pointer;
AutoDelete() : pointer(0) {}
~AutoDelete() { delete[] this->pointer; }
};
static AutoDelete _autoDelete[10];
static unsigned int _index = 0;
if (!string || !*string)
return "";
++_index;
if (_index >= 10)
_index = 0;
if (_autoDelete[_index].pointer)
delete[] _autoDelete[_index].pointer;
int length = ::wcslen (string);
char* text = new char[length + 1];
_autoDelete[_index].pointer = text;
::wcstombs (text, string, length + 1);
return text;
}
|
Bückstabü!
|
|
|