refactor: IKeyState remove need for malloc in alloc methods
This commit is contained in:
parent
1968669a39
commit
32165f5b58
1 changed files with 3 additions and 3 deletions
|
|
@ -26,7 +26,7 @@ IKeyState::IKeyState(const IEventQueue *)
|
||||||
|
|
||||||
IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(KeyID id, KeyModifierMask mask, KeyButton button, int32_t count)
|
IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(KeyID id, KeyModifierMask mask, KeyButton button, int32_t count)
|
||||||
{
|
{
|
||||||
auto *info = (KeyInfo *)malloc(sizeof(KeyInfo));
|
auto *info = new KeyInfo();
|
||||||
info->m_key = id;
|
info->m_key = id;
|
||||||
info->m_mask = mask;
|
info->m_mask = mask;
|
||||||
info->m_button = button;
|
info->m_button = button;
|
||||||
|
|
@ -44,7 +44,7 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(
|
||||||
const char *buffer = screens.c_str();
|
const char *buffer = screens.c_str();
|
||||||
|
|
||||||
// build structure
|
// build structure
|
||||||
auto *info = (KeyInfo *)malloc(sizeof(KeyInfo) + screens.size());
|
auto *info = new KeyInfo();
|
||||||
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 +57,7 @@ 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);
|
||||||
auto info = (KeyInfo *)malloc(sizeof(KeyInfo) + bufferLen);
|
auto *info = new KeyInfo();
|
||||||
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