From ca942b88c295830544e03804666229e0e955f64b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 31 Aug 2016 12:19:31 +0000 Subject: - memory leak fixed; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@17226 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/BasicHistory/src/BasicHistory.cpp | 39 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'plugins/BasicHistory/src/BasicHistory.cpp') diff --git a/plugins/BasicHistory/src/BasicHistory.cpp b/plugins/BasicHistory/src/BasicHistory.cpp index 8c91b57629..4af03cc15c 100644 --- a/plugins/BasicHistory/src/BasicHistory.cpp +++ b/plugins/BasicHistory/src/BasicHistory.cpp @@ -25,7 +25,7 @@ HINSTANCE hInst; #define MS_HISTORY_EXECUTE_TASK "BasicHistory/ExecuteTask" HCURSOR hCurSplitNS, hCurSplitWE; -HANDLE g_hMainThread=NULL; +HANDLE g_hMainThread = NULL; HANDLE hServiceShowContactHistory, hServiceDeleteAllContactHistory, hServiceExecuteTask; HANDLE *hEventIcons = NULL; @@ -36,7 +36,7 @@ HGENMENU hTaskMainMenu; std::vector taskMenus; bool g_SmileyAddAvail = false; char* metaContactProto = NULL; -const IID IID_ITextDocument={0x8CC497C0, 0xA1DF, 0x11ce, {0x80, 0x98, 0x00, 0xAA, 0x00, 0x47, 0xBE, 0x5D}}; +const IID IID_ITextDocument = { 0x8CC497C0, 0xA1DF, 0x11ce, {0x80, 0x98, 0x00, 0xAA, 0x00, 0x47, 0xBE, 0x5D} }; #define MODULE "BasicHistory" @@ -67,7 +67,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) return &pluginInfo; } -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_UIHISTORY, MIID_LAST}; +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_UIHISTORY, MIID_LAST }; void InitScheduler(); void DeinitScheduler(); @@ -84,7 +84,7 @@ int PrebuildContactMenu(WPARAM hContact, LPARAM) return 0; } -int ToolbarModuleLoaded(WPARAM,LPARAM) +int ToolbarModuleLoaded(WPARAM, LPARAM) { TTBButton ttb = { 0 }; ttb.pszService = MS_HISTORY_SHOWCONTACTHISTORY; @@ -167,7 +167,7 @@ IconItem iconList[] = { LPGEN("Find Previous"), "BasicHistory_findprev", IDI_FINDPREV }, { LPGEN("Plus in export"), "BasicHistory_plusex", IDI_PLUSEX }, { LPGEN("Minus in export"), "BasicHistory_minusex", IDI_MINUSEX }, -}; +}; void InitIcolib() { @@ -175,8 +175,8 @@ void InitIcolib() HICON LoadIconEx(int iconId, bool big) { - for (int i=0; i < _countof(iconList); i++) - if ( iconList[i].defIconID == iconId) + for (int i = 0; i < _countof(iconList); i++) + if (iconList[i].defIconID == iconId) return IcoLib_GetIconByHandle(iconList[i].hIcolib, big); return 0; @@ -204,20 +204,20 @@ int HistoryContactDelete(WPARAM wParam, LPARAM) int ModulesLoaded(WPARAM, LPARAM) { InitMenuItems(); - + wchar_t ftpExe[MAX_PATH]; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, ftpExe))) { wcscat_s(ftpExe, L"\\WinSCP\\WinSCP.exe"); DWORD atr = GetFileAttributes(ftpExe); if (atr == INVALID_FILE_ATTRIBUTES || atr & FILE_ATTRIBUTE_DIRECTORY) { -#ifdef _WIN64 + #ifdef _WIN64 if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILESX86, NULL, SHGFP_TYPE_CURRENT, ftpExe))) { wcscat_s(ftpExe, L"\\WinSCP\\WinSCP.exe"); atr = GetFileAttributes(ftpExe); if (!(atr == INVALID_FILE_ATTRIBUTES || atr & FILE_ATTRIBUTE_DIRECTORY)) Options::instance->ftpExePathDef = ftpExe; } -#endif + #endif } else Options::instance->ftpExePathDef = ftpExe; } @@ -234,7 +234,7 @@ int ModulesLoaded(WPARAM, LPARAM) HookEvent(ME_DB_CONTACT_DELETED, HistoryContactDelete); HookEvent(ME_FONT_RELOAD, HistoryWindow::FontsChanged); HookEvent(ME_SYSTEM_OKTOEXIT, DoLastTask); - + if (ServiceExists(MS_SMILEYADD_REPLACESMILEYS)) g_SmileyAddAvail = true; @@ -248,7 +248,7 @@ extern "C" int __declspec(dllexport) Load(void) mir_getCLI(); hTaskMainMenu = NULL; - DuplicateHandle(GetCurrentProcess(),GetCurrentThread(),GetCurrentProcess(),&g_hMainThread,0,FALSE,DUPLICATE_SAME_ACCESS); + DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &g_hMainThread, 0, FALSE, DUPLICATE_SAME_ACCESS); hCurSplitNS = LoadCursor(NULL, IDC_SIZENS); hCurSplitWE = LoadCursor(NULL, IDC_SIZEWE); @@ -263,7 +263,7 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_OPT_INITIALISE, Options::InitOptions); HistoryEventList::Init(); - + Icon_Register(hInst, LPGEN("History"), iconList, _countof(iconList)); return 0; } @@ -272,23 +272,22 @@ extern "C" int __declspec(dllexport) Unload(void) { if (g_hMainThread) CloseHandle(g_hMainThread); - g_hMainThread=NULL; - + g_hMainThread = NULL; + DestroyServiceFunction(hServiceShowContactHistory); DestroyServiceFunction(hServiceDeleteAllContactHistory); DestroyServiceFunction(hServiceExecuteTask); - + HistoryWindow::Deinit(); - + DestroyCursor(hCurSplitNS); DestroyCursor(hCurSplitWE); - + if (Options::instance != NULL) { delete Options::instance; Options::instance = NULL; } - delete [] hEventIcons; - + delete[] hEventIcons; return 0; } -- cgit v1.2.3