refactor: IKeyState remove need for malloc in alloc methods

This commit is contained in:
sithlord48
2025-08-04 22:11:48 -04:00
committed by Nick Bolton
parent 1968669a39
commit 32165f5b58

View File

@ -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;