WIN32: Use malloc instead of new in string conversion functions
This commit is contained in:
parent
27a2b94687
commit
30f2c2f3cd
5 changed files with 15 additions and 29 deletions
|
@ -85,7 +85,7 @@ wchar_t *ansiToUnicode(const char *s, uint codePage) {
|
|||
DWORD size = MultiByteToWideChar(codePage, 0, s, -1, NULL, 0);
|
||||
|
||||
if (size > 0) {
|
||||
LPWSTR result = new WCHAR[size];
|
||||
LPWSTR result = (LPWSTR)calloc(size, sizeof(WCHAR));
|
||||
if (MultiByteToWideChar(codePage, 0, s, -1, result, size) != 0)
|
||||
return result;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ char *unicodeToAnsi(const wchar_t *s, uint codePage) {
|
|||
DWORD size = WideCharToMultiByte(codePage, 0, s, -1, NULL, 0, 0, 0);
|
||||
|
||||
if (size > 0) {
|
||||
char *result = new char[size];
|
||||
char *result = (char *)calloc(size, sizeof(char));
|
||||
if (WideCharToMultiByte(codePage, 0, s, -1, result, size, 0, 0) != 0)
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue