From 4d6c3b34abe6ee2c5161a490cac64f6f20fc2b1d Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sat, 3 Jul 2010 03:12:34 +0300 Subject: dynamic lists for hContact's cleaning, not finished --- utilities.cpp | 53 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 18 deletions(-) (limited to 'utilities.cpp') diff --git a/utilities.cpp b/utilities.cpp index b7475f6..b1d3415 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -65,29 +65,40 @@ int CreateCListGroup(TCHAR* szGroupName) return hGroup; } +struct hContact_entry +{ + HANDLE hContact; + struct hContact_entry *next; +}; void RemoveExcludedUsers() { HANDLE hContact; - HANDLE ToRemove[4096]; - int i = 0,a = 0; + hContact_entry first, *plist; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + plist = &first; + plist->hContact = INVALID_HANDLE_VALUE; if(hContact) { do { if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) && DBGetContactSettingByte(hContact, pluginName, "Excluded", 0)) { - ToRemove[i] = hContact; - i++; + plist->hContact = hContact; + plist->next = new hContact_entry; + plist = plist->next; + plist->hContact = INVALID_HANDLE_VALUE; } } - while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0)); - ToRemove[i] = INVALID_HANDLE_VALUE; - while(ToRemove[a] != INVALID_HANDLE_VALUE) + while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0)) + ; + plist = &first; + while(plist->hContact != INVALID_HANDLE_VALUE) { - CallService(MS_DB_CONTACT_DELETE, (WPARAM)ToRemove[a], 0); - a++; + CallService(MS_DB_CONTACT_DELETE, (WPARAM)plist->hContact, 0); + hContact_entry *tmp = plist; + plist = plist->next; +// delete tmp; //something wrong here %) } } } @@ -95,25 +106,31 @@ void RemoveExcludedUsers() void RemoveTemporaryUsers() { HANDLE hContact; - HANDLE ToRemove[4096]; - int i = 0, a= 0; + hContact_entry first, *plist, *tmp; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + plist = &first; + plist->hContact = INVALID_HANDLE_VALUE; if(hContact) { do { if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)) { - ToRemove[i] = hContact; - i++; + plist->hContact = hContact; + plist->next = new hContact_entry; + plist = plist->next; + plist->hContact = INVALID_HANDLE_VALUE; } } - while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0)); - ToRemove[i] = INVALID_HANDLE_VALUE; - while(ToRemove[a] != INVALID_HANDLE_VALUE) + while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0)) + ; + plist = &first; + while(plist->hContact != INVALID_HANDLE_VALUE) { - CallService(MS_DB_CONTACT_DELETE, (WPARAM)ToRemove[a], 0); - a++; + CallService(MS_DB_CONTACT_DELETE, (WPARAM)plist->hContact, 0); + tmp = plist; + plist = plist->next; +// delete tmp; delete tmp; //something wrong here %) } } } -- cgit v1.2.3 From 907f341825ad56ca4ea3e5a7e4410a40d28f7818 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sat, 3 Jul 2010 03:16:11 +0300 Subject: modified: utilities.cpp --- utilities.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utilities.cpp') diff --git a/utilities.cpp b/utilities.cpp index b1d3415..6354dce 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -74,7 +74,7 @@ struct hContact_entry void RemoveExcludedUsers() { HANDLE hContact; - hContact_entry first, *plist; + hContact_entry first, *plist, *tmp; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); plist = &first; plist->hContact = INVALID_HANDLE_VALUE; @@ -96,7 +96,7 @@ void RemoveExcludedUsers() while(plist->hContact != INVALID_HANDLE_VALUE) { CallService(MS_DB_CONTACT_DELETE, (WPARAM)plist->hContact, 0); - hContact_entry *tmp = plist; + tmp = plist; plist = plist->next; // delete tmp; //something wrong here %) } -- cgit v1.2.3 From 5e3da2678f94c3bb033cc24d399817cfd149a835 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sat, 3 Jul 2010 18:47:51 +0300 Subject: modified: utilities.cpp --- utilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utilities.cpp') diff --git a/utilities.cpp b/utilities.cpp index 6354dce..7f59ce4 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -130,7 +130,7 @@ void RemoveTemporaryUsers() CallService(MS_DB_CONTACT_DELETE, (WPARAM)plist->hContact, 0); tmp = plist; plist = plist->next; -// delete tmp; delete tmp; //something wrong here %) +// delete tmp; //something wrong here %) } } } -- cgit v1.2.3 From 9bcf384669cc213c80e35c6d4f48969ce17d4676 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sat, 3 Jul 2010 19:30:19 +0300 Subject: fixed cleaning dynamic list of temporary users --- utilities.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'utilities.cpp') diff --git a/utilities.cpp b/utilities.cpp index 7f59ce4..90f8a7e 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -74,9 +74,10 @@ struct hContact_entry void RemoveExcludedUsers() { HANDLE hContact; - hContact_entry first, *plist, *tmp; + hContact_entry *first, *plist, *tmp; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - plist = &first; + first = new hContact_entry; + plist = first; plist->hContact = INVALID_HANDLE_VALUE; if(hContact) { @@ -92,13 +93,13 @@ void RemoveExcludedUsers() } while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0)) ; - plist = &first; + plist = first; while(plist->hContact != INVALID_HANDLE_VALUE) { CallService(MS_DB_CONTACT_DELETE, (WPARAM)plist->hContact, 0); tmp = plist; plist = plist->next; -// delete tmp; //something wrong here %) + delete tmp; } } } @@ -106,9 +107,10 @@ void RemoveExcludedUsers() void RemoveTemporaryUsers() { HANDLE hContact; - hContact_entry first, *plist, *tmp; + hContact_entry *first, *plist, *tmp; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - plist = &first; + first = new hContact_entry; + plist = first; plist->hContact = INVALID_HANDLE_VALUE; if(hContact) { @@ -124,13 +126,13 @@ void RemoveTemporaryUsers() } while(hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0)) ; - plist = &first; + plist = first; while(plist->hContact != INVALID_HANDLE_VALUE) { CallService(MS_DB_CONTACT_DELETE, (WPARAM)plist->hContact, 0); tmp = plist; plist = plist->next; -// delete tmp; //something wrong here %) + delete tmp; } } } -- cgit v1.2.3 From 6eb97740351520cf36a5c2bf24b621353a8ebe9e Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Mon, 12 Jul 2010 20:21:55 +0300 Subject: fixed small memory leak --- utilities.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'utilities.cpp') diff --git a/utilities.cpp b/utilities.cpp index 90f8a7e..adf82d7 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -101,6 +101,7 @@ void RemoveExcludedUsers() plist = plist->next; delete tmp; } + delete tmp; } } @@ -134,6 +135,7 @@ void RemoveTemporaryUsers() plist = plist->next; delete tmp; } + delete tmp; } } int RemoveTmp(WPARAM,LPARAM) @@ -262,4 +264,4 @@ BOOL IsUrlContains(TCHAR * Str) mir_free(StrLower); } return 0; -} \ No newline at end of file +} -- cgit v1.2.3