diff options
author | George Hazan <ghazan@miranda.im> | 2021-06-05 17:50:34 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-06-05 17:50:34 +0300 |
commit | d7c9eb34f80f207efd47d2fc65e31aedf166c323 (patch) | |
tree | 338b9b905674dc31b1efab739dfcedeed3d8d7b3 /plugins/HistoryLinkListPlus/src/linklist_fct.cpp | |
parent | ffc5a3d7550528281976745279e77ac9faba551b (diff) |
major code cleaning in regard to db_event_getBlobSize & event memory allocation
Diffstat (limited to 'plugins/HistoryLinkListPlus/src/linklist_fct.cpp')
-rw-r--r-- | plugins/HistoryLinkListPlus/src/linklist_fct.cpp | 58 |
1 files changed, 21 insertions, 37 deletions
diff --git a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp index dcfbe5711f..63fbd15fa3 100644 --- a/plugins/HistoryLinkListPlus/src/linklist_fct.cpp +++ b/plugins/HistoryLinkListPlus/src/linklist_fct.cpp @@ -380,17 +380,13 @@ void WriteLinkList(HWND hDlg, BYTE params, LISTELEMENT *listStart, LPCTSTR searc // Perform deep scan
if (actualElement->hEvent != NULL)
{
- DBEVENTINFO dbe = {};
- dbe.cbBlob = db_event_getBlobSize(actualElement->hEvent);
- dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob + 1);
+ DB::EventInfo dbe;
+ dbe.cbBlob = -1;
db_event_get(actualElement->hEvent, &dbe);
- dbe.pBlob[dbe.cbBlob] = 0;
- LPTSTR msg = DbEvent_GetTextW(&dbe, CP_ACP);
+
+ ptrW msg(DbEvent_GetTextW(&dbe, CP_ACP));
if (wcsstr(msg, searchString))
filter3 = 1;
-
- mir_free(dbe.pBlob);
- mir_free(msg);
}
else filter3 = 0;
}
@@ -614,16 +610,12 @@ void WriteMessage(HWND hDlg, LISTELEMENT *listStart, int actLinePos) if (actualElement->linePos == actLinePos) {
MEVENT hEvent = actualElement->hEvent;
if (hEvent != NULL) {
- DBEVENTINFO dbe = {};
- dbe.cbBlob = db_event_getBlobSize(hEvent);
- dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob + 1);
+ DB::EventInfo dbe;
+ dbe.cbBlob = -1;
db_event_get(hEvent, &dbe);
- dbe.pBlob[dbe.cbBlob] = 0;
- LPCTSTR msg = DbEvent_GetTextW(&dbe, CP_ACP);
- SetDlgItemText(hDlg, IDC_MESSAGE, nullptr);
- SendDlgItemMessage(hDlg, IDC_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg);
- mir_free((void*)msg);
- mir_free(dbe.pBlob);
+
+ SetDlgItemTextW(hDlg, IDC_MESSAGE, L"");
+ SendDlgItemMessage(hDlg, IDC_MESSAGE, EM_REPLACESEL, FALSE, ptrW(DbEvent_GetTextW(&dbe, CP_ACP)));
}
break;
}
@@ -771,18 +763,14 @@ void GetListInfo(BYTE params, LISTELEMENT *listStart, LPCTSTR searchString, size // Perform deep scan
if (actualElement->hEvent != NULL)
{
- DBEVENTINFO dbe = {};
- dbe.cbBlob = db_event_getBlobSize(actualElement->hEvent);
- dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob + 1);
+ DB::EventInfo dbe;
+ dbe.cbBlob = -1;
db_event_get(actualElement->hEvent, &dbe);
- dbe.pBlob[dbe.cbBlob] = 0;
+
if (wcsstr((LPTSTR)dbe.pBlob, searchString))
filter3 = 1;
-
- mir_free(dbe.pBlob);
}
- else
- filter3 = 0;
+ else filter3 = 0;
}
else
{
@@ -790,8 +778,7 @@ void GetListInfo(BYTE params, LISTELEMENT *listStart, LPCTSTR searchString, size filter3 = 1;
}
}
- else
- filter3 = 1;
+ else filter3 = 1;
if ((filter1 == 1) && (filter2 == 1) && (filter3 == 1))
{
@@ -1171,27 +1158,24 @@ This function is derived from his Wordlookup Plugin int DBUpdate(WPARAM wParam, LPARAM hEvent)
{
HWND hDlg = WindowList_Find(hWindowList, wParam);
- DIALOGPARAM *DlgParam;
HMENU listMenu = GetMenu(hDlg);
- int linkNum = 0;
-
- DlgParam = (DIALOGPARAM *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
+ DIALOGPARAM *DlgParam = (DIALOGPARAM *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
if (GetUpdateSetting() != 1)
return 0;
if (hDlg) {
- DBEVENTINFO dbe = {};
- dbe.cbBlob = db_event_getBlobSize(hEvent);
- dbe.pBlob = (PBYTE)mir_alloc((size_t)dbe.cbBlob + 1);
- db_event_get(hEvent, &dbe);
+ DB::EventInfo dbe;
+ dbe.cbBlob = -1;
+ if (db_event_get(hEvent, &dbe))
+ return 0;
+
if (dbe.eventType == EVENTTYPE_MESSAGE) {
// Call function to find URIs
- linkNum = ExtractURI(&dbe, hEvent, DlgParam->listStart);
+ int linkNum = ExtractURI(&dbe, hEvent, DlgParam->listStart);
if (linkNum > 0)
WriteLinkList(hDlg, GetFlags(listMenu), DlgParam->listStart, nullptr, linkNum);
}
- mir_free(dbe.pBlob);
}
return 0;
}
|