From 8b6824e3ec3ed7340db33bcbe592321b6afb0a00 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 21 Sep 2013 13:37:19 +0000 Subject: - warning fixes; - memleak fixes; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@6154 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AssocMgr/src/reg.cpp | 54 ++++++++++++++++--------------- plugins/IEView/src/HistoryHTMLBuilder.cpp | 4 +-- plugins/IEView/src/Options.cpp | 19 +++++------ plugins/IEView/src/ScriverHTMLBuilder.cpp | 4 +-- plugins/IEView/src/TabSRMMHTMLBuilder.cpp | 6 ++-- plugins/IEView/src/Template.cpp | 32 +++++++++--------- plugins/IEView/src/Template.h | 37 ++++++++++----------- 7 files changed, 80 insertions(+), 76 deletions(-) (limited to 'plugins') diff --git a/plugins/AssocMgr/src/reg.cpp b/plugins/AssocMgr/src/reg.cpp index be921d8c3a..c285c65221 100644 --- a/plugins/AssocMgr/src/reg.cpp +++ b/plugins/AssocMgr/src/reg.cpp @@ -535,37 +535,39 @@ static void DeleteRegTreeBackup(const char *pszSubKey,const char *pszDbPrefix) void CleanupRegTreeBackupSettings(void) { + /* delete old bak_* settings and try to restore backups */ int nSettingsCount; char **ppszSettings; - char *pszClassName,*pszBuf,*pszFileExt; - int i,j; - - /* delete old bak_* settings and try to restore backups */ - if (EnumDbPrefixSettings("AssocMgr","bak_",&ppszSettings,&nSettingsCount)) { - for(i=0;icount || event->count==-1); eventData = eventData->next, eventIdx++) { int outputSize; char *output = NULL; - int isSent = eventData->dwFlags & IEEDF_SENT; - int isRTL = eventData->dwFlags & IEEDF_RTL; + bool isSent = (eventData->dwFlags & IEEDF_SENT) != 0; + bool isRTL = (eventData->dwFlags & IEEDF_RTL) != 0; if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_STATUSCHANGE || eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_FILE) { diff --git a/plugins/IEView/src/Options.cpp b/plugins/IEView/src/Options.cpp index d5df0ca6c3..ecde244899 100644 --- a/plugins/IEView/src/Options.cpp +++ b/plugins/IEView/src/Options.cpp @@ -644,7 +644,7 @@ static INT_PTR CALLBACK IEViewSRMMOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar ProtocolSettings *proto = (ProtocolSettings *)GetItemParam((HWND)wParam, (HTREEITEM) lParam); if (proto != NULL) if (strcmpi(proto->getProtocolName(), "_default_")) - proto->setSRMMEnableTemp( TreeView_GetCheckState((HWND)wParam, (HTREEITEM) lParam)); + proto->setSRMMEnableTemp(0 != TreeView_GetCheckState((HWND)wParam, (HTREEITEM) lParam)); if ((HTREEITEM) lParam != TreeView_GetSelection((HWND)wParam)) TreeView_SelectItem((HWND)wParam, (HTREEITEM) lParam); @@ -777,7 +777,7 @@ static INT_PTR CALLBACK IEViewHistoryOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w ProtocolSettings *proto = (ProtocolSettings *)GetItemParam((HWND)wParam, (HTREEITEM) lParam); if (proto != NULL) if (strcmpi(proto->getProtocolName(), "_default_")) - proto->setHistoryEnableTemp(TreeView_GetCheckState((HWND)wParam, (HTREEITEM) lParam)); + proto->setHistoryEnableTemp(0 != TreeView_GetCheckState((HWND)wParam, (HTREEITEM) lParam)); if ((HTREEITEM) lParam != TreeView_GetSelection((HWND)wParam)) TreeView_SelectItem((HWND)wParam, (HTREEITEM) lParam); @@ -911,7 +911,7 @@ static INT_PTR CALLBACK IEViewGroupChatsOptDlgProc(HWND hwndDlg, UINT msg, WPARA ProtocolSettings *proto = (ProtocolSettings *)GetItemParam((HWND)wParam, (HTREEITEM) lParam); if (proto != NULL) if (strcmpi(proto->getProtocolName(), "_default_")) - proto->setChatEnableTemp(TreeView_GetCheckState((HWND)wParam, (HTREEITEM) lParam)); + proto->setChatEnableTemp(0 != TreeView_GetCheckState((HWND)wParam, (HTREEITEM) lParam)); if ((HTREEITEM) lParam != TreeView_GetSelection((HWND)wParam)) { TreeView_SelectItem((HWND)wParam, (HTREEITEM) lParam); @@ -1495,7 +1495,7 @@ void Options::init() } /* SRMM settings */ mir_snprintf(dbsName, SIZEOF(dbsName), "%s.%s", proto->getProtocolName(), DBS_SRMM_ENABLE); - proto->setSRMMEnable(i==0 ? true : db_get_b(NULL, ieviewModuleName, dbsName, FALSE)); + proto->setSRMMEnable(i==0 ? true : 0 != db_get_b(NULL, ieviewModuleName, dbsName, FALSE)); mir_snprintf(dbsName, SIZEOF(dbsName), "%s.%s", proto->getProtocolName(), DBS_SRMM_MODE); proto->setSRMMMode(db_get_b(NULL, ieviewModuleName, dbsName, FALSE)); mir_snprintf(dbsName, SIZEOF(dbsName), "%s.%s", proto->getProtocolName(), DBS_SRMM_FLAGS); @@ -1528,7 +1528,7 @@ void Options::init() /* Group chat settings */ mir_snprintf(dbsName, SIZEOF(dbsName), "%s.%s", proto->getProtocolName(), DBS_CHAT_ENABLE); - proto->setChatEnable(i==0 ? true : db_get_b(NULL, ieviewModuleName, dbsName, FALSE)); + proto->setChatEnable(i==0 ? true : 0 != db_get_b(NULL, ieviewModuleName, dbsName, FALSE)); mir_snprintf(dbsName, SIZEOF(dbsName), "%s.%s", proto->getProtocolName(), DBS_CHAT_MODE); proto->setChatMode(db_get_b(NULL, ieviewModuleName, dbsName, FALSE)); mir_snprintf(dbsName, SIZEOF(dbsName), "%s.%s", proto->getProtocolName(), DBS_CHAT_FLAGS); @@ -1561,7 +1561,7 @@ void Options::init() /* History settings */ mir_snprintf(dbsName, SIZEOF(dbsName), "%s.%s", proto->getProtocolName(), DBS_HISTORY_ENABLE); - proto->setHistoryEnable(i==0 ? true : db_get_b(NULL, ieviewModuleName, dbsName, FALSE)); + proto->setHistoryEnable(i==0 ? true : 0 != db_get_b(NULL, ieviewModuleName, dbsName, FALSE)); mir_snprintf(dbsName, SIZEOF(dbsName), "%s.%s", proto->getProtocolName(), DBS_HISTORY_MODE); proto->setHistoryMode(db_get_b(NULL, ieviewModuleName, dbsName, FALSE)); mir_snprintf(dbsName, SIZEOF(dbsName), "%s.%s", proto->getProtocolName(), DBS_HISTORY_FLAGS); @@ -1600,8 +1600,8 @@ void Options::init() lastProto = proto; } - bMathModule = (bool) ServiceExists(MTH_GET_GIF_UNICODE); - bSmileyAdd = (bool) ServiceExists(MS_SMILEYADD_BATCHPARSE); + bMathModule = 0 != ServiceExists(MTH_GET_GIF_UNICODE); + bSmileyAdd = 0 != ServiceExists(MS_SMILEYADD_BATCHPARSE); avatarServiceFlags = 0; if (ServiceExists(MS_AV_GETAVATARBITMAP)) avatarServiceFlags = AVATARSERVICE_PRESENT; @@ -1614,6 +1614,7 @@ void Options::uninit() p1 = p->getNext(); delete p; } + TemplateMap::dropTemplates(); if (hImageList != NULL) ImageList_Destroy(hImageList); if (hProtocolImageList != NULL) @@ -1626,7 +1627,7 @@ void Options::setGeneralFlags(int flags) db_set_dw(NULL, ieviewModuleName, DBS_BASICFLAGS, (DWORD) flags); } -int Options::getGeneralFlags() +int Options::getGeneralFlags() { return generalFlags; } diff --git a/plugins/IEView/src/ScriverHTMLBuilder.cpp b/plugins/IEView/src/ScriverHTMLBuilder.cpp index 6aa5f904e9..25b96f76f7 100644 --- a/plugins/IEView/src/ScriverHTMLBuilder.cpp +++ b/plugins/IEView/src/ScriverHTMLBuilder.cpp @@ -287,8 +287,8 @@ void ScriverHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event int outputSize; char *output; output = NULL; - int isSent = eventData->dwFlags & IEEDF_SENT; - int isRTL = eventData->dwFlags & IEEDF_RTL; + bool isSent = (eventData->dwFlags & IEEDF_SENT) != 0; + bool isRTL = (eventData->dwFlags & IEEDF_RTL) != 0; showColon = false; if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_STATUSCHANGE || eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_FILE) diff --git a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp index 41bd1680b9..bbdbd497c9 100644 --- a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp +++ b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp @@ -315,9 +315,9 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event int outputSize; char *output = NULL; if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_FILE || eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_STATUSCHANGE) { - int isGroupBreak = TRUE; - int isSent = (eventData->dwFlags & IEEDF_SENT); - int isRTL = eventData->dwFlags & IEEDF_RTL; + bool isGroupBreak = true; + bool isSent = (eventData->dwFlags & IEEDF_SENT) != 0; + bool isRTL = (eventData->dwFlags & IEEDF_RTL) != 0; int isHistory = (eventData->time < (DWORD)getStartedTime() && (eventData->dwFlags & IEEDF_READ || eventData->dwFlags & IEEDF_SENT)); if (dwFlags & MWF_LOG_GROUPMODE && eventData->dwFlags == LOWORD(getLastEventType()) && eventData->iType == IEED_EVENT_MESSAGE && HIWORD(getLastEventType()) == IEED_EVENT_MESSAGE && diff --git a/plugins/IEView/src/Template.cpp b/plugins/IEView/src/Template.cpp index 20a3dd2cc9..158249762f 100644 --- a/plugins/IEView/src/Template.cpp +++ b/plugins/IEView/src/Template.cpp @@ -42,10 +42,7 @@ Token::Token(int type, const char *text, int escape) next = NULL; this->type = type; this->escape = escape; - if (text!=NULL) - this->text = mir_strdup(text); - else - this->text = NULL; + this->text = mir_strdup(text); } Token::~Token() @@ -373,10 +370,7 @@ TemplateMap* TemplateMap::loadTemplateFile(const char *id, const char *filename, if (wasTemplate) tmap->addTemplate(lastTemplate, templateText); - if (templateText != NULL) - free (templateText); - - templateText = NULL; + replaceStr(templateText, NULL); templateTextSize = 0; wasTemplate = true; sscanf(store, "