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/Scriver/src/msgdialog.cpp | 12 +++++------- plugins/Scriver/src/msglog.cpp | 13 ++++--------- 2 files changed, 9 insertions(+), 16 deletions(-) (limited to 'plugins/Scriver/src') 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; } -- cgit v1.2.3