From f0899cc7909c130426af35ba1ef0689d35a708f7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 6 Nov 2014 14:00:03 +0000 Subject: - fix for major memory leak; - event cycle optimization git-svn-id: http://svn.miranda-ng.org/main/trunk@10915 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/NewsAggregator/Src/CheckFeed.cpp | 26 +++++++++++++++----------- plugins/NewsAggregator/Src/Version.h | 16 ++++++++-------- 2 files changed, 23 insertions(+), 19 deletions(-) (limited to 'plugins/NewsAggregator/Src') diff --git a/plugins/NewsAggregator/Src/CheckFeed.cpp b/plugins/NewsAggregator/Src/CheckFeed.cpp index d357599a1b..6518acb559 100644 --- a/plugins/NewsAggregator/Src/CheckFeed.cpp +++ b/plugins/NewsAggregator/Src/CheckFeed.cpp @@ -355,22 +355,26 @@ void CheckCurrentFeed(MCONTACT hContact) mir_free(category); } - bool MesExist = false; - ptrA pszTemp(mir_utf8encodeT(message)); - for (HANDLE hDbEvent = db_event_first(hContact);hDbEvent;hDbEvent = db_event_next(hContact, hDbEvent)) { - DBEVENTINFO olddbei = { sizeof(olddbei) }; + DBEVENTINFO olddbei = { 0 }; + olddbei.cbSize = sizeof(olddbei); + + bool MesExist = false; + ptrA pszTemp(mir_utf8encodeT(message)); + DWORD cbMemoLen = 10000, cbOrigLen = lstrlenA(pszTemp); + BYTE *pbBuffer = (BYTE*)mir_alloc(cbMemoLen); + for (HANDLE hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent)) { olddbei.cbBlob = db_event_getBlobSize(hDbEvent); - olddbei.pBlob = (PBYTE)mir_alloc(olddbei.cbBlob); + if (olddbei.cbBlob > cbMemoLen) + pbBuffer = (PBYTE)mir_realloc(pbBuffer, cbMemoLen = olddbei.cbBlob); + olddbei.pBlob = pbBuffer; db_event_get(hDbEvent, &olddbei); - char *pszTemp = mir_utf8encodeT(message); - if (olddbei.cbBlob == lstrlenA(pszTemp) + 1 && !lstrcmpA((char *)olddbei.pBlob, pszTemp)) { + + if (olddbei.cbBlob == cbOrigLen+1 && !lstrcmpA((char*)olddbei.pBlob, pszTemp)) { MesExist = true; - } - - mir_free(olddbei.pBlob); - if (MesExist) break; + } } + mir_free(pbBuffer); if (!MesExist) { if (stamp == 0) diff --git a/plugins/NewsAggregator/Src/Version.h b/plugins/NewsAggregator/Src/Version.h index 5424fdb344..52b0b9799e 100644 --- a/plugins/NewsAggregator/Src/Version.h +++ b/plugins/NewsAggregator/Src/Version.h @@ -1,14 +1,14 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 0 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 1 +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 1 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 2 #include #define __PLUGIN_NAME "News aggregator" #define __FILENAME "NewsAggregator.dll" -#define __DESCRIPTION "RSS/Atom news aggregator." -#define __AUTHOR "Mataes, FREAK_THEMIGHTY" +#define __DESCRIPTION "RSS/Atom news aggregator." +#define __AUTHOR "Mataes, FREAK_THEMIGHTY" #define __AUTHOREMAIL "mataes2007@gmail.com" -#define __AUTHORWEB "http://miranda-ng.org/p/NewsAggregator/" -#define __COPYRIGHT "© 2012 Mataes, FREAK_THEMIGHTY" +#define __AUTHORWEB "http://miranda-ng.org/p/NewsAggregator/" +#define __COPYRIGHT "© 2012 Mataes, FREAK_THEMIGHTY" -- cgit v1.2.3