From d7c9eb34f80f207efd47d2fc65e31aedf166c323 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 5 Jun 2021 17:50:34 +0300 Subject: major code cleaning in regard to db_event_getBlobSize & event memory allocation --- plugins/Boltun/src/boltun.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'plugins/Boltun/src') diff --git a/plugins/Boltun/src/boltun.cpp b/plugins/Boltun/src/boltun.cpp index 82a9994073..f764e3fc84 100644 --- a/plugins/Boltun/src/boltun.cpp +++ b/plugins/Boltun/src/boltun.cpp @@ -195,26 +195,16 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) if (!BoltunAutoChat(hContact)) return 0; - DBEVENTINFO dbei = {}; - dbei.cbBlob = db_event_getBlobSize(hDbEvent); - if (dbei.cbBlob == -1) - return 0; - - dbei.pBlob = (PBYTE)malloc(dbei.cbBlob); - if (dbei.pBlob == nullptr) - return 0; - + DB::EventInfo dbei; + dbei.cbBlob = -1; db_event_get(hDbEvent, &dbei); if (dbei.flags & DBEF_SENT || dbei.flags & DBEF_READ || dbei.eventType != EVENTTYPE_MESSAGE) return 0; - wchar_t *s = DbEvent_GetTextW(&dbei, CP_ACP); - free(dbei.pBlob); if (Config.MarkAsRead) db_event_markRead(hContact, hDbEvent); - AnswerToContact(hContact, s); - mir_free(s); + AnswerToContact(hContact, ptrW(DbEvent_GetTextW(&dbei, CP_ACP))); return 0; } -- cgit v1.2.3