Merge pull request #46900 from Ev1lbl0w/bugfix-malloc_calls
Replace malloc's with Godot's memalloc macro
This commit is contained in:
commit
7015027cbf
6 changed files with 37 additions and 26 deletions
|
|
@ -110,12 +110,11 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
|
|||
if (GetRawInputDeviceList(nullptr, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == (UINT)-1) {
|
||||
return false;
|
||||
}
|
||||
dev_list = (PRAWINPUTDEVICELIST)malloc(sizeof(RAWINPUTDEVICELIST) * dev_list_count);
|
||||
if (!dev_list)
|
||||
return false;
|
||||
dev_list = (PRAWINPUTDEVICELIST)memalloc(sizeof(RAWINPUTDEVICELIST) * dev_list_count);
|
||||
ERR_FAIL_NULL_V_MSG(dev_list, false, "Out of memory.");
|
||||
|
||||
if (GetRawInputDeviceList(dev_list, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == (UINT)-1) {
|
||||
free(dev_list);
|
||||
memfree(dev_list);
|
||||
return false;
|
||||
}
|
||||
for (unsigned int i = 0; i < dev_list_count; i++) {
|
||||
|
|
@ -130,11 +129,11 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) {
|
|||
(MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == (LONG)p_guid->Data1) &&
|
||||
(GetRawInputDeviceInfoA(dev_list[i].hDevice, RIDI_DEVICENAME, &dev_name, &nameSize) != (UINT)-1) &&
|
||||
(strstr(dev_name, "IG_") != nullptr)) {
|
||||
free(dev_list);
|
||||
memfree(dev_list);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
free(dev_list);
|
||||
memfree(dev_list);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ void WindowsTerminalLogger::logv(const char *p_format, va_list p_list, bool p_er
|
|||
if (wlen < 0)
|
||||
return;
|
||||
|
||||
wchar_t *wbuf = (wchar_t *)malloc((len + 1) * sizeof(wchar_t));
|
||||
wchar_t *wbuf = (wchar_t *)memalloc((len + 1) * sizeof(wchar_t));
|
||||
ERR_FAIL_NULL_MSG(wbuf, "Out of memory.");
|
||||
MultiByteToWideChar(CP_UTF8, 0, buf, len, wbuf, wlen);
|
||||
wbuf[wlen] = 0;
|
||||
|
||||
|
|
@ -62,7 +63,7 @@ void WindowsTerminalLogger::logv(const char *p_format, va_list p_list, bool p_er
|
|||
else
|
||||
wprintf(L"%ls", wbuf);
|
||||
|
||||
free(wbuf);
|
||||
memfree(wbuf);
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
fflush(stdout);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue