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/TabSRMM/src/eventpopups.cpp | 22 ++++++---------------- plugins/TabSRMM/src/msglog.cpp | 6 +----- 2 files changed, 7 insertions(+), 21 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index fd2538208a..c69982526f 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -313,11 +313,9 @@ static int PopupUpdateT(MCONTACT hContact, MEVENT hEvent) else szHeader[0] = 0; - DBEVENTINFO dbe = {}; - if (pdata->pluginOptions->bPreview && hContact) { - dbe.cbBlob = db_event_getBlobSize(hEvent); - dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob); - } + DB::EventInfo dbe; + if (pdata->pluginOptions->bPreview && hContact) + dbe.cbBlob = -1; db_event_get(hEvent, &dbe); wchar_t timestamp[MAX_DATASIZE]; @@ -360,8 +358,6 @@ static int PopupUpdateT(MCONTACT hContact, MEVENT hEvent) pdata->nrEventsAlloced += 5; pdata->eventData = (EVENT_DATAT *)mir_realloc(pdata->eventData, pdata->nrEventsAlloced * sizeof(EVENT_DATAT)); } - if (dbe.pBlob) - mir_free(dbe.pBlob); PUChangeTextW(pdata->hWnd, lpzText); return 0; @@ -373,12 +369,10 @@ static int PopupShowT(NEN_OPTIONS *pluginOptions, MCONTACT hContact, MEVENT hEve if (arPopupList.getCount() >= MAX_POPUPS) return 2; - DBEVENTINFO dbe = {}; + DB::EventInfo dbe; // fix for a crash - if (hEvent && (pluginOptions->bPreview || hContact == 0)) { - dbe.cbBlob = db_event_getBlobSize(hEvent); - dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob); - } + if (hEvent && (pluginOptions->bPreview || hContact == 0)) + dbe.cbBlob = -1; db_event_get(hEvent, &dbe); if (hEvent == 0 && hContact == 0) @@ -437,10 +431,6 @@ static int PopupShowT(NEN_OPTIONS *pluginOptions, MCONTACT hContact, MEVENT hEve pdata->nrMerged = 1; PUAddPopupW(&pud); arPopupList.insert(pdata); - - if (dbe.pBlob) - mir_free(dbe.pBlob); - return 0; } diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index 49d03fa2bd..1d9a5d56c2 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -437,11 +437,7 @@ static char* Template_CreateRTFFromDbEvent(CMsgDialog *dat, MCONTACT hContact, M if (streamData->dbei != nullptr) dbei = *(streamData->dbei); else { - dbei.cbBlob = db_event_getBlobSize(hDbEvent); - if (dbei.cbBlob == -1) - return nullptr; - - dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); + dbei.cbBlob = -1; db_event_get(hDbEvent, &dbei); if (!DbEventIsShown(&dbei)) { mir_free(dbei.pBlob); -- cgit v1.2.3