diff --git a/src/lib/deskflow/IKeyState.cpp b/src/lib/deskflow/IKeyState.cpp index 7c69c7db0..287d696bf 100644 --- a/src/lib/deskflow/IKeyState.cpp +++ b/src/lib/deskflow/IKeyState.cpp @@ -26,7 +26,7 @@ IKeyState::IKeyState(const IEventQueue *) 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_mask = mask; info->m_button = button; @@ -44,7 +44,7 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc( const char *buffer = screens.c_str(); // build structure - auto *info = (KeyInfo *)malloc(sizeof(KeyInfo) + screens.size()); + auto *info = new KeyInfo(); info->m_key = id; info->m_mask = mask; info->m_button = button; @@ -57,7 +57,7 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc( IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(const KeyInfo &x) { 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_mask = x.m_mask; info->m_button = x.m_button;