summaryrefslogtreecommitdiff
path: root/plugins/Scriver/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/Scriver/src
parentffc5a3d7550528281976745279e77ac9faba551b (diff)
major code cleaning in regard to db_event_getBlobSize & event memory allocation
Diffstat (limited to 'plugins/Scriver/src')
-rw-r--r--plugins/Scriver/src/msgdialog.cpp12
-rw-r--r--plugins/Scriver/src/msglog.cpp13
2 files changed, 9 insertions, 16 deletions
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index c8b0f89f2e..b9a57e3f00 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -484,7 +484,7 @@ void CMsgDialog::onClick_Quote(CCtrlButton*)
if (m_hDbEventLast == 0)
return;
- SETTEXTEX st;
+ SETTEXTEX st;
st.flags = ST_SELECTION;
st.codepage = 1200;
@@ -495,12 +495,11 @@ void CMsgDialog::onClick_Quote(CCtrlButton*)
mir_free(buffer);
}
else {
- DBEVENTINFO dbei = {};
- dbei.cbBlob = db_event_getBlobSize(m_hDbEventLast);
- if (dbei.cbBlob == 0xFFFFFFFF)
+ DB::EventInfo dbei;
+ dbei.cbBlob = -1;
+ if (db_event_get(m_hDbEventLast, &dbei))
return;
- dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
- db_event_get(m_hDbEventLast, &dbei);
+
if (DbEventIsMessageOrCustom(&dbei)) {
buffer = DbEvent_GetTextW(&dbei, CP_ACP);
if (buffer != nullptr) {
@@ -509,7 +508,6 @@ void CMsgDialog::onClick_Quote(CCtrlButton*)
mir_free(buffer);
}
}
- mir_free(dbei.pBlob);
}
SetFocus(m_message.GetHwnd());
}
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp
index 062657a3ac..f0914bd2cd 100644
--- a/plugins/Scriver/src/msglog.cpp
+++ b/plugins/Scriver/src/msglog.cpp
@@ -78,17 +78,13 @@ int DbEventIsShown(DBEVENTINFO &dbei)
EventData* CMsgDialog::GetEventFromDB(MCONTACT hContact, MEVENT hDbEvent)
{
- DBEVENTINFO dbei = {};
- dbei.cbBlob = db_event_getBlobSize(hDbEvent);
- if (dbei.cbBlob == -1)
+ DB::EventInfo dbei;
+ dbei.cbBlob = -1;
+ if (db_event_get(hDbEvent, &dbei))
return nullptr;
- dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
- db_event_get(hDbEvent, &dbei);
- if (!DbEventIsShown(dbei)) {
- mir_free(dbei.pBlob);
+ if (!DbEventIsShown(dbei))
return nullptr;
- }
EventData *evt = (EventData*)mir_calloc(sizeof(EventData));
evt->custom = DbEventIsCustomForMsgWindow(&dbei);
@@ -125,7 +121,6 @@ EventData* CMsgDialog::GetEventFromDB(MCONTACT hContact, MEVENT hDbEvent)
if (!m_bUseRtl && Utils_IsRtl(evt->szText.w))
evt->dwFlags |= IEEDF_RTL;
- mir_free(dbei.pBlob);
return evt;
}