summaryrefslogtreecommitdiff
path: root/plugins/NewsAggregator
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-11-06 14:00:03 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-11-06 14:00:03 +0000
commitf0899cc7909c130426af35ba1ef0689d35a708f7 (patch)
tree6af8977f4920d9615e3996c388e235d0dbb4528c /plugins/NewsAggregator
parent51d69d9c51d35a7f1de4d1d8f659fa377a9f1f26 (diff)
- fix for major memory leak;
- event cycle optimization git-svn-id: http://svn.miranda-ng.org/main/trunk@10915 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/NewsAggregator')
-rw-r--r--plugins/NewsAggregator/Src/CheckFeed.cpp26
-rw-r--r--plugins/NewsAggregator/Src/Version.h16
2 files changed, 23 insertions, 19 deletions
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 <stdver.h>
#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"