refactor: On windows use the old malloc method to prevent random test failure in IKeyState
This commit is contained in:
parent
d6b53ea718
commit
8d92a8df68
1 changed files with 13 additions and 0 deletions
|
|
@ -44,7 +44,13 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(
|
||||||
const char *buffer = screens.c_str();
|
const char *buffer = screens.c_str();
|
||||||
|
|
||||||
// build structure
|
// build structure
|
||||||
|
#if SYSAPI_WIN32
|
||||||
|
// On windows we use malloc to avoid random test failures
|
||||||
|
auto *info = (KeyInfo *)malloc(sizeof(KeyInfo) + screens.size());
|
||||||
|
#else
|
||||||
auto *info = new KeyInfo();
|
auto *info = new KeyInfo();
|
||||||
|
#endif
|
||||||
|
|
||||||
info->m_key = id;
|
info->m_key = id;
|
||||||
info->m_mask = mask;
|
info->m_mask = mask;
|
||||||
info->m_button = button;
|
info->m_button = button;
|
||||||
|
|
@ -57,7 +63,14 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(
|
||||||
IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(const KeyInfo &x)
|
IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(const KeyInfo &x)
|
||||||
{
|
{
|
||||||
auto bufferLen = strnlen(x.m_screensBuffer, SIZE_MAX);
|
auto bufferLen = strnlen(x.m_screensBuffer, SIZE_MAX);
|
||||||
|
|
||||||
|
#if SYSAPI_WIN32
|
||||||
|
// On windows we use malloc to avoid random test failures
|
||||||
|
auto info = (KeyInfo *)malloc(sizeof(KeyInfo) + bufferLen);
|
||||||
|
#else
|
||||||
auto *info = new KeyInfo();
|
auto *info = new KeyInfo();
|
||||||
|
#endif
|
||||||
|
|
||||||
info->m_key = x.m_key;
|
info->m_key = x.m_key;
|
||||||
info->m_mask = x.m_mask;
|
info->m_mask = x.m_mask;
|
||||||
info->m_button = x.m_button;
|
info->m_button = x.m_button;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue