summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/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/TabSRMM/src
parentffc5a3d7550528281976745279e77ac9faba551b (diff)
major code cleaning in regard to db_event_getBlobSize & event memory allocation
Diffstat (limited to 'plugins/TabSRMM/src')
-rw-r--r--plugins/TabSRMM/src/eventpopups.cpp22
-rw-r--r--plugins/TabSRMM/src/msglog.cpp6
2 files changed, 7 insertions, 21 deletions
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);