Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Release Forum » [SSGM 4.0 Plugin] RadioCommands
Re: [SSGM 4.0 Plugin] RadioCommands [message #470764 is a reply to message #470748] Thu, 05 July 2012 04:23 Go to previous messageGo to previous message
cAmpa is currently offline  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ü!
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [TOOL] chunky
Next Topic: Westwood Scripts [M02]
Goto Forum:
  


Current Time: Sat Jan 11 10:32:37 MST 2025

Total time taken to generate the page: 0.00988 seconds