From d77850e44b6d38380c08896ba5f2e043c7c69fb2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 30 Jun 2012 17:45:03 +0000 Subject: mir_free won again! git-svn-id: http://svn.miranda-ng.org/main/trunk@701 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/modern_cachefuncs.cpp | 198 +++++++++++++---------------- plugins/Nudge/main.cpp | 24 +--- plugins/StatusPlugins/commonstatus.cpp | 6 +- plugins/StatusPlugins/confirmdialog.cpp | 2 +- plugins/TipperYM/subst.cpp | 13 +- plugins/Variables/trigger_variables.cpp | 196 +++++++++++++--------------- 6 files changed, 192 insertions(+), 247 deletions(-) diff --git a/plugins/Clist_modern/modern_cachefuncs.cpp b/plugins/Clist_modern/modern_cachefuncs.cpp index 6eb0338acb..9beb1da22d 100644 --- a/plugins/Clist_modern/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/modern_cachefuncs.cpp @@ -454,124 +454,104 @@ int Cache_GetLineText(PDNCE pdnce, int type, LPTSTR text, int text_size, TCHAR * BOOL show_status_if_no_away, BOOL show_listening_if_no_away, BOOL use_name_and_message_for_xstatus, BOOL pdnce_time_show_only_if_different) { - text[0] = '\0'; - switch(type) - { - case TEXT_STATUS: - { - if (GetStatusName(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus) - { - DBVARIANT dbv={0}; + text[0] = '\0'; + switch(type) { + case TEXT_STATUS: + if (GetStatusName(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus) { + DBVARIANT dbv={0}; + + // Try to get XStatusMsg + if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) { + if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0) { + TCHAR *tmp = mir_tstrdup(text); + mir_sntprintf(text, text_size, TEXT("%s: %s"), tmp, dbv.pszVal); + mir_free_and_nill(tmp); + CopySkipUnprintableChars(text, text, text_size-1); + } + db_free(&dbv); + } + } - // Try to get XStatusMsg - if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusMsg", &dbv)) - { - if (dbv.ptszVal != NULL && dbv.ptszVal[0] != 0) - { - TCHAR *tmp = mir_tstrdup(text); - mir_sntprintf(text, text_size, TEXT("%s: %s"), tmp, dbv.pszVal); - mir_free_and_nill(tmp); - CopySkipUnprintableChars(text, text, text_size-1); - } - db_free(&dbv); - } - } + return TEXT_STATUS; - return TEXT_STATUS; - } - case TEXT_NICKNAME: - { - if (pdnce->m_cache_hContact && pdnce->m_cache_cszProto) - { - DBVARIANT dbv={0}; - if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) - { - lstrcpyn(text, dbv.ptszVal, text_size); - db_free(&dbv); - CopySkipUnprintableChars(text, text, text_size-1); - } - } + case TEXT_NICKNAME: + if (pdnce->m_cache_hContact && pdnce->m_cache_cszProto) { + DBVARIANT dbv={0}; + if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) { + lstrcpyn(text, dbv.ptszVal, text_size); + db_free(&dbv); + CopySkipUnprintableChars(text, text, text_size-1); + } + } - return TEXT_NICKNAME; - } - case TEXT_STATUS_MESSAGE: - { - if (GetStatusMessage(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus) - { - DBVARIANT dbv={0}; + return TEXT_NICKNAME; - // Try to get XStatusName - if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) - { - if (dbv.pszVal != NULL && dbv.pszVal[0] != 0) - { - TCHAR *tmp = mir_tstrdup(text); - - mir_sntprintf(text, text_size, TEXT("%s: %s"), dbv.pszVal, tmp); - mir_free_and_nill(tmp); - } - CopySkipUnprintableChars(text, text, text_size-1); - db_free(&dbv); - } - } - else if (use_name_and_message_for_xstatus && xstatus_has_priority) - { - DBVARIANT dbv={0}; - // Try to get XStatusName - if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) - { - if (dbv.pszVal != NULL && dbv.pszVal[0] != 0) - mir_sntprintf(text, text_size, TEXT("%s"), dbv.pszVal); - CopySkipUnprintableChars(text, text, text_size-1); - db_free(&dbv); - } - } + case TEXT_STATUS_MESSAGE: + if (GetStatusMessage(text, text_size, pdnce, xstatus_has_priority) == -1 && use_name_and_message_for_xstatus) { + DBVARIANT dbv={0}; - if (text[0] == '\0') - { - if (show_listening_if_no_away) - { - Cache_GetLineText(pdnce, TEXT_LISTENING_TO, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different); - if (text[0] != '\0') - return TEXT_LISTENING_TO; - } + // Try to get XStatusName + if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) { + if (dbv.pszVal != NULL && dbv.pszVal[0] != 0) { + TCHAR *tmp = mir_tstrdup(text); - if (show_status_if_no_away) - { - //re-request status if no away - return Cache_GetLineText(pdnce, TEXT_STATUS, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different); - } - } - return TEXT_STATUS_MESSAGE; - } - case TEXT_LISTENING_TO: - { - GetListeningTo(text, text_size, pdnce); - return TEXT_LISTENING_TO; - } - case TEXT_TEXT: - { - TCHAR *tmp = variables_parsedup(variable_text, pdnce->m_cache_tcsName, pdnce->m_cache_hContact); - lstrcpyn(text, tmp, text_size); - if (tmp) free(tmp); - CopySkipUnprintableChars(text, text, text_size-1); + mir_sntprintf(text, text_size, TEXT("%s: %s"), dbv.pszVal, tmp); + mir_free_and_nill(tmp); + } + CopySkipUnprintableChars(text, text, text_size-1); + db_free(&dbv); + } + } + else if (use_name_and_message_for_xstatus && xstatus_has_priority) { + DBVARIANT dbv={0}; + // Try to get XStatusName + if (!DBGetContactSettingTString(pdnce->m_cache_hContact, pdnce->m_cache_cszProto, "XStatusName", &dbv)) { + if (dbv.pszVal != NULL && dbv.pszVal[0] != 0) + mir_sntprintf(text, text_size, TEXT("%s"), dbv.pszVal); + CopySkipUnprintableChars(text, text, text_size-1); + db_free(&dbv); + } + } - return TEXT_TEXT; - } - case TEXT_CONTACT_TIME: - { - if (pdnce->hTimeZone) - { - // Get pdnce time - text[0] = 0; - tmi.printDateTime( pdnce->hTimeZone, _T("t"), text, text_size, 0); - } + if (text[0] == '\0') { + if (show_listening_if_no_away) { + Cache_GetLineText(pdnce, TEXT_LISTENING_TO, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different); + if (text[0] != '\0') + return TEXT_LISTENING_TO; + } - return TEXT_CONTACT_TIME; - } - } + if (show_status_if_no_away) { + //re-request status if no away + return Cache_GetLineText(pdnce, TEXT_STATUS, text, text_size, variable_text, xstatus_has_priority, 0, 0, use_name_and_message_for_xstatus, pdnce_time_show_only_if_different); + } + } + return TEXT_STATUS_MESSAGE; + + case TEXT_LISTENING_TO: + GetListeningTo(text, text_size, pdnce); + return TEXT_LISTENING_TO; + + case TEXT_TEXT: + { + TCHAR *tmp = variables_parsedup(variable_text, pdnce->m_cache_tcsName, pdnce->m_cache_hContact); + lstrcpyn(text, tmp, text_size); + if (tmp) + mir_free(tmp); + CopySkipUnprintableChars(text, text, text_size-1); + } + return TEXT_TEXT; + + case TEXT_CONTACT_TIME: + if (pdnce->hTimeZone) { + // Get pdnce time + text[0] = 0; + tmi.printDateTime( pdnce->hTimeZone, _T("t"), text, text_size, 0); + } + + return TEXT_CONTACT_TIME; + } - return TEXT_EMPTY; + return TEXT_EMPTY; } /* diff --git a/plugins/Nudge/main.cpp b/plugins/Nudge/main.cpp index a66a7b0d5c..1bb2e5b876 100644 --- a/plugins/Nudge/main.cpp +++ b/plugins/Nudge/main.cpp @@ -285,33 +285,17 @@ int TriggerActionRecv( DWORD actionID, REPORTINFO *ri) ShakeClist(NULL,NULL); if(bshakeChat && (hContact != NULL)) ShakeChat((WPARAM)hContact,NULL); - - /* // Actually show the message box - DBVARIANT dbv; - TCHAR *tszMsg; - - // Retrieve the correct settings for this action ID - if (!DBGetActionSettingTString(actionID, NULL, MODULENAME, SETTING_TEXT, &dbv)) { - // Parse by Variables, if available (notice extratext and subject are given). - tszMsg = variables_parsedup(dbv.ptszVal, ((ri->td!=NULL)&&(ri->td->dFlags&DF_TEXT))?ri->td->tszText:NULL, ((ri->td!=NULL)&&(ri->td->dFlags&DF_CONTACT))?ri->td->hContact:NULL); - if (tszMsg != NULL) { - // Show the message box - MessageBox(NULL, tszMsg, TranslateT("ExampleAction"), MB_OK); - free(tszMsg); - } - DBFreeVariant(&dbv); - } - */ } - if (ri->flags&ACT_CLEANUP) { // request to delete all associated settings + + if (ri->flags&ACT_CLEANUP) // request to delete all associated settings RemoveAllActionSettings(actionID, "Nudge"); - } + return FALSE; } int TriggerActionSend( DWORD actionID, REPORTINFO *ri) { - if (ri->flags&ACT_PERFORM) { + if (ri->flags & ACT_PERFORM) { HANDLE hContact = ((ri->td!=NULL)&&(ri->td->dFlags&DF_CONTACT))?ri->td->hContact:NULL; if(hContact != NULL) NudgeSend((WPARAM)hContact,NULL); diff --git a/plugins/StatusPlugins/commonstatus.cpp b/plugins/StatusPlugins/commonstatus.cpp index d1e214b307..c2cc820e9b 100644 --- a/plugins/StatusPlugins/commonstatus.cpp +++ b/plugins/StatusPlugins/commonstatus.cpp @@ -335,11 +335,9 @@ static void SetStatusMsg(PROTOCOLSETTINGEX *ps, int newstatus) TCHAR* szFormattedMsg = variables_parsedup(tszMsg, ps->tszAccName, NULL); if (szFormattedMsg != NULL) { - mir_free( tszMsg ); - tszMsg = mir_tstrdup( szFormattedMsg ); - free( szFormattedMsg ); + mir_free(tszMsg); + tszMsg = szFormattedMsg; } - } log_debugA("CommonStatus sets status message for %s directly", ps->szName); if ( CALLSERVICE_NOTFOUND == CallProtoService(ps->szName, PS_SETAWAYMSGT, newstatus, (LPARAM)tszMsg )) { diff --git a/plugins/StatusPlugins/confirmdialog.cpp b/plugins/StatusPlugins/confirmdialog.cpp index f1a2dbf94b..2d93e181fc 100644 --- a/plugins/StatusPlugins/confirmdialog.cpp +++ b/plugins/StatusPlugins/confirmdialog.cpp @@ -146,7 +146,7 @@ static int SetStatusList(HWND hwndDlg) if ( msg != NULL ) { TCHAR* fMsg = variables_parsedup( msg, confirmSettings[i].tszAccName, NULL ); ListView_SetItemText(hList, lvItem.iItem, 2, fMsg); - free(fMsg); + mir_free(fMsg); mir_free(msg); } else ListView_SetItemText(hList, lvItem.iItem, 2, TranslateT("")); diff --git a/plugins/TipperYM/subst.cpp b/plugins/TipperYM/subst.cpp index 531af67200..1d8c8837d9 100644 --- a/plugins/TipperYM/subst.cpp +++ b/plugins/TipperYM/subst.cpp @@ -568,8 +568,7 @@ bool GetRawSubstText(HANDLE hContact, char *szRawSpec, TCHAR *buff, int bufflen) bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFirst, TCHAR *swzDest, int iDestLen) { // hack - allow empty strings before passing to variables (note - zero length strings return false after this) - if (swzDest && swzSource && _tcslen(swzSource) == 0) - { + if (swzDest && swzSource && _tcslen(swzSource) == 0) { swzDest[0] = 0; return true; } @@ -579,7 +578,7 @@ bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFir if (parseTipperVarsFirst == false) swzVarSrc = variables_parsedup((TCHAR *)swzSource, 0, hContact); else - swzVarSrc = _tcsdup(swzSource); + swzVarSrc = mir_tstrdup(swzSource); size_t iSourceLen = _tcslen(swzVarSrc); size_t si = 0, di = 0, v = 0; @@ -779,14 +778,14 @@ bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFir di++; } - free(swzVarSrc); + mir_free(swzVarSrc); swzDest[di] = 0; if (parseTipperVarsFirst) { swzVarSrc = variables_parsedup((TCHAR *)swzDest, 0, hContact); _tcscpy(swzDest, swzVarSrc); - free(swzVarSrc); + mir_free(swzVarSrc); } @@ -800,13 +799,13 @@ bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFir return false; empty: - free(swzVarSrc); + mir_free(swzVarSrc); return false; error: swzDest[0] = _T('*'); swzDest[1] = 0; - free(swzVarSrc); + mir_free(swzVarSrc); return true; } diff --git a/plugins/Variables/trigger_variables.cpp b/plugins/Variables/trigger_variables.cpp index c7d8771fc0..6b90088c4f 100644 --- a/plugins/Variables/trigger_variables.cpp +++ b/plugins/Variables/trigger_variables.cpp @@ -27,37 +27,33 @@ static TRG_VAR_CACHE *tvc = NULL; static int tvcCount = 0; static unsigned int stringChangeTimerID = 0; -static int addToCache(DWORD triggerID) { - +static int addToCache(DWORD triggerID) +{ /* triggerID must be in the DB */ DBVARIANT dbv; - int i; - for (i=0;i