From 32165f5b58312a2884de1a4e31242303e577d6bd Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Mon, 4 Aug 2025 22:11:48 -0400 Subject: [PATCH] refactor: IKeyState remove need for malloc in alloc methods --- src/lib/deskflow/IKeyState.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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;