summaryrefslogtreecommitdiff
path: root/plugins/Boltun/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-06-05 17:50:34 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-06-05 17:50:34 +0300
commitd7c9eb34f80f207efd47d2fc65e31aedf166c323 (patch)
tree338b9b905674dc31b1efab739dfcedeed3d8d7b3 /plugins/Boltun/src
parentffc5a3d7550528281976745279e77ac9faba551b (diff)
major code cleaning in regard to db_event_getBlobSize & event memory allocation
Diffstat (limited to 'plugins/Boltun/src')
-rw-r--r--plugins/Boltun/src/boltun.cpp16
1 files changed, 3 insertions, 13 deletions
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;
}