summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/chat
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-08-12 16:21:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-08-12 16:21:37 +0000
commit58ff50e5bf8dbb6b28d54370423232dc0221cd53 (patch)
treeb71113e7574217421cb622e584f643df490e708a /plugins/TabSRMM/src/chat
parentc2cb7db85cbd67c5b95c2735d9b917eb0ac1d234 (diff)
mir_alloc/calloc/free instead of simple malloc/calloc/free
git-svn-id: http://svn.miranda-ng.org/main/trunk@5660 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/chat')
-rw-r--r--plugins/TabSRMM/src/chat/log.cpp15
-rw-r--r--plugins/TabSRMM/src/chat/muchighlight.cpp17
-rw-r--r--plugins/TabSRMM/src/chat/options.cpp24
-rw-r--r--plugins/TabSRMM/src/chat/tools.cpp4
-rw-r--r--plugins/TabSRMM/src/chat/window.cpp16
5 files changed, 33 insertions, 43 deletions
diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp
index ee7830c91d..96c049f032 100644
--- a/plugins/TabSRMM/src/chat/log.cpp
+++ b/plugins/TabSRMM/src/chat/log.cpp
@@ -444,9 +444,9 @@ static TCHAR * _tcsrplc(TCHAR **src, const TCHAR *ptrn, const TCHAR *rplc)
lRplc = lstrlen(rplc);
if (lPtrn && lSrc && lSrc >= lPtrn && (tszFound = _tcsstr(*src, ptrn)) != NULL) {
if (lRplc > lPtrn)
- *src = (TCHAR*) realloc((void*) * src,
+ *src = (TCHAR*) mir_realloc((void*) * src,
sizeof(TCHAR) * (lSrc + lRplc - lPtrn + 1));
- if (tszTail = (TCHAR*) malloc(sizeof(TCHAR) *
+ if (tszTail = (TCHAR*) mir_alloc(sizeof(TCHAR) *
(lSrc - (tszFound - *src) - lPtrn + 1))) {
/* save tail */
_tcscpy(tszTail, tszFound + lPtrn);
@@ -454,7 +454,7 @@ static TCHAR * _tcsrplc(TCHAR **src, const TCHAR *ptrn, const TCHAR *rplc)
_tcscpy(tszFound, rplc);
/* write tail */
_tcscpy(tszFound + lRplc, tszTail);
- free((void*) tszTail);
+ mir_free((void*) tszTail);
}
}
return *src;
@@ -476,7 +476,7 @@ static TCHAR * _tcsnrplc(TCHAR *src, size_t n, const TCHAR *ptrn, const TCHAR *r
if (lPtrn && lSrc && lSrc >= lPtrn && /* lengths are ok */
(tszFound = _tcsstr(src, ptrn)) != NULL && /* pattern was found in string */
(n < 0 || lSrc - lPtrn + lRplc < n) && /* there is enough room in the string */
- (tszTail = (TCHAR*) malloc(sizeof(TCHAR) *
+ (tszTail = (TCHAR*) mir_alloc(sizeof(TCHAR) *
(lSrc - (tszFound - src) - lPtrn + 1))) != NULL) {
/* save tail */
_tcscpy(tszTail, tszFound + lPtrn);
@@ -484,7 +484,7 @@ static TCHAR * _tcsnrplc(TCHAR *src, size_t n, const TCHAR *ptrn, const TCHAR *r
_tcscpy(tszFound, rplc);
/* write tail */
_tcscpy(tszFound + lRplc, tszTail);
- free((void*) tszTail);
+ mir_free(tszTail);
}
return src;
}
@@ -942,7 +942,7 @@ static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
CopyMemory(pbBuff, lstrdat->buffer + lstrdat->bufferOffset, *pcb);
lstrdat->bufferOffset += *pcb;
- // free stuff if the streaming operation is complete
+ // mir_free stuff if the streaming operation is complete
if (lstrdat->bufferOffset == lstrdat->bufferLen) {
mir_free(lstrdat->buffer);
lstrdat->buffer = NULL;
@@ -1323,7 +1323,6 @@ void LoadMsgLogBitmaps(void)
void FreeMsgLogBitmaps(void)
{
- int i;
- for (i=0; i < SIZEOF(pLogIconBmpBits); i++)
+ for (int i=0; i < SIZEOF(pLogIconBmpBits); i++)
mir_free(pLogIconBmpBits[i]);
}
diff --git a/plugins/TabSRMM/src/chat/muchighlight.cpp b/plugins/TabSRMM/src/chat/muchighlight.cpp
index 1777657801..e5d96b3ea4 100644
--- a/plugins/TabSRMM/src/chat/muchighlight.cpp
+++ b/plugins/TabSRMM/src/chat/muchighlight.cpp
@@ -34,18 +34,12 @@
void CMUCHighlight::cleanup()
{
- if (m_NickPatternString)
- mir_free(m_NickPatternString);
- if (m_TextPatternString)
- mir_free(m_TextPatternString);
-
+ mir_free(m_NickPatternString);
+ mir_free(m_TextPatternString);
m_TextPatternString = m_NickPatternString = 0;
- if (m_NickPatterns)
- mir_free(m_NickPatterns);
- if (m_TextPatterns)
- mir_free(m_TextPatterns);
-
+ mir_free(m_NickPatterns);
+ mir_free(m_TextPatterns);
m_iNickPatterns = m_iTextPatterns = 0;
m_NickPatterns = m_TextPatterns = 0;
}
@@ -194,8 +188,7 @@ skip_textpatterns:
::SendMessage(psi->dat->pContainer->hwndStatus, SB_SETTEXT, 0, (LPARAM)psi->dat->szStatusBar);
}
#endif
- if (tszMe)
- mir_free(tszMe);
+ mir_free(tszMe);
}
/*
diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp
index bcbea06b5c..5419240089 100644
--- a/plugins/TabSRMM/src/chat/options.cpp
+++ b/plugins/TabSRMM/src/chat/options.cpp
@@ -580,7 +580,7 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_GROUP));
if (iLen > 0) {
- pszText = (TCHAR*)realloc(pszText, (iLen + 2) * sizeof(TCHAR));
+ pszText = (TCHAR*)mir_realloc(pszText, (iLen + 2) * sizeof(TCHAR));
GetDlgItemText(hwndDlg, IDC_GROUP, pszText, iLen + 1);
db_set_ts(NULL, "Chat", "AddToGroup", pszText);
} else
@@ -588,12 +588,11 @@ INT_PTR CALLBACK DlgProcOptions1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
g_Settings.hGroup = 0;
- if (pszText)
- free(pszText);
+ mir_free(pszText);
b = M.GetByte("Chat", "Tabs", 1);
- SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, sizeof(branch1) / sizeof(branch1[0]));
- SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, sizeof(branch2) / sizeof(branch2[0]));
+ SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch1, SIZEOF(branch1));
+ SaveBranch(GetDlgItem(hwndDlg, IDC_CHECKBOXES), branch2, SIZEOF(branch2));
LoadGlobalSettings();
MM_FontsChanged();
@@ -1029,10 +1028,10 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
if (PluginConfig.m_chat_enabled) {
int iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY));
if (iLen > 0) {
- TCHAR *pszText1 = (TCHAR*)malloc(iLen*sizeof(TCHAR) + 2);
+ TCHAR *pszText1 = (TCHAR*)mir_alloc(iLen*sizeof(TCHAR) + 2);
GetDlgItemText(hwndDlg, IDC_LOGDIRECTORY, pszText1, iLen + 1);
db_set_ts(NULL, "Chat", "LogDirectory", pszText1);
- free(pszText1);
+ mir_free(pszText1);
g_Settings.bLoggingEnabled = IsDlgButtonChecked(hwndDlg, IDC_LOGGING) == BST_CHECKED;
db_set_b(0, "Chat", "LoggingEnabled", g_Settings.bLoggingEnabled);
}
@@ -1053,28 +1052,28 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_LOGTIMESTAMP));
if (iLen > 0) {
- pszText = (char *)realloc(pszText, iLen + 1);
+ pszText = (char *)mir_realloc(pszText, iLen + 1);
GetDlgItemTextA(hwndDlg, IDC_LOGTIMESTAMP, pszText, iLen + 1);
db_set_s(NULL, "Chat", "LogTimestamp", pszText);
} else db_unset(NULL, "Chat", "LogTimestamp");
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_TIMESTAMP));
if (iLen > 0) {
- pszText = (char *)realloc(pszText, iLen + 1);
+ pszText = (char *)mir_realloc(pszText, iLen + 1);
GetDlgItemTextA(hwndDlg, IDC_TIMESTAMP, pszText, iLen + 1);
db_set_s(NULL, "Chat", "HeaderTime", pszText);
} else db_unset(NULL, "Chat", "HeaderTime");
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_INSTAMP));
if (iLen > 0) {
- pszText = (char *)realloc(pszText, iLen + 1);
+ pszText = (char *)mir_realloc(pszText, iLen + 1);
GetDlgItemTextA(hwndDlg, IDC_INSTAMP, pszText, iLen + 1);
db_set_s(NULL, "Chat", "HeaderIncoming", pszText);
} else db_unset(NULL, "Chat", "HeaderIncoming");
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_OUTSTAMP));
if (iLen > 0) {
- pszText = (char *)realloc(pszText, iLen + 1);
+ pszText = (char *)mir_realloc(pszText, iLen + 1);
GetDlgItemTextA(hwndDlg, IDC_OUTSTAMP, pszText, iLen + 1);
db_set_s(NULL, "Chat", "HeaderOutgoing", pszText);
} else db_unset(NULL, "Chat", "HeaderOutgoing");
@@ -1082,9 +1081,8 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
iLen = SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN2, UDM_GETPOS, 0, 0);
db_set_w(NULL, "Chat", "LogLimit", (WORD)iLen);
}
+ mir_free(pszText);
- if (pszText != NULL)
- free(pszText);
if (hListBkgBrush)
DeleteObject(hListBkgBrush);
hListBkgBrush = CreateSolidBrush(M.GetDword("Chat", "ColorNicklistBG", SRMSGDEFSET_BKGCOLOUR));
diff --git a/plugins/TabSRMM/src/chat/tools.cpp b/plugins/TabSRMM/src/chat/tools.cpp
index 835f1acc60..393a92e111 100644
--- a/plugins/TabSRMM/src/chat/tools.cpp
+++ b/plugins/TabSRMM/src/chat/tools.cpp
@@ -504,7 +504,7 @@ void TSAPI DoFlashAndSoundWorker(FLASH_PARAMS* p)
UpdateTrayMenu(dat, si->wStatus, si->pszModule, dat ? dat->szStatus : NULL, si->hContact, p->bHighlight ? 1 : 1);
}
- free(p);
+ mir_free(p);
}
BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix)
@@ -513,7 +513,7 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight
return FALSE;
TWindowData *dat = NULL;
- FLASH_PARAMS *params = (FLASH_PARAMS*)calloc(1, sizeof(FLASH_PARAMS));
+ FLASH_PARAMS *params = (FLASH_PARAMS*)mir_calloc( sizeof(FLASH_PARAMS));
params->hContact = si->hContact;
params->bInactive = TRUE;
if (si->hWnd && si->dat) {
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp
index 20a0eb9d54..6e8359f036 100644
--- a/plugins/TabSRMM/src/chat/window.cpp
+++ b/plugins/TabSRMM/src/chat/window.cpp
@@ -1699,7 +1699,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
if (iCount != LB_ERR) {
int iSelectedItems = SendMessage(hwnd, LB_GETSELCOUNT, 0, 0);
if (iSelectedItems != LB_ERR) {
- int *pItems = (int *)malloc(sizeof(int) * (iSelectedItems + 1));
+ int *pItems = (int *)mir_alloc(sizeof(int) * (iSelectedItems + 1));
if (pItems) {
if (SendMessage(hwnd, LB_GETSELITEMS, (WPARAM)iSelectedItems, (LPARAM)pItems) != LB_ERR) {
for (int i=0; i < iSelectedItems; i++) {
@@ -1708,7 +1708,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
DoEventHookAsync(hwndParent, parentdat->ptszID, parentdat->pszModule, GC_USER_NICKLISTMENU, ui1->pszUID, NULL, (LPARAM)uID);
}
}
- free(pItems);
+ mir_free(pItems);
}
}
}
@@ -1866,7 +1866,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
TNewWindowData *newData = (TNewWindowData*)lParam;
si = (SESSION_INFO*)newData->hdbEvent;
- TWindowData *dat = (TWindowData*)calloc( sizeof(TWindowData), 1);
+ TWindowData *dat = (TWindowData*)mir_calloc( sizeof(TWindowData));
dat->si = si;
dat->hContact = si->hContact;
dat->szProto = GetContactProto(si->hContact);
@@ -2871,8 +2871,8 @@ LABEL_SHOWWINDOW:
USERINFO *ui = si->pUsers;
SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_EXGETSEL, 0, (LPARAM)&chr);
size_t bufSize = lstrlen(tr.lpstrText) + lstrlen(tszAplTmpl) + 3;
- tszTmp = tszAppeal = (TCHAR*)malloc(bufSize * sizeof(TCHAR));
- tr2.lpstrText = (LPTSTR) malloc(sizeof(TCHAR) * 2);
+ tszTmp = tszAppeal = (TCHAR*)mir_alloc(bufSize * sizeof(TCHAR));
+ tr2.lpstrText = (LPTSTR) mir_alloc(sizeof(TCHAR) * 2);
if (chr.cpMin) {
/* prepend nick with space if needed */
tr2.chrg.cpMin = chr.cpMin - 1;
@@ -2901,8 +2901,8 @@ LABEL_SHOWWINDOW:
tszAppeal[st++] = _T('\0');
}
SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)tszAppeal);
- free((void*) tr2.lpstrText);
- free((void*) tszAppeal);
+ mir_free((void*) tr2.lpstrText);
+ mir_free((void*) tszAppeal);
}
}
SetFocus(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE));
@@ -3573,7 +3573,7 @@ LABEL_SHOWWINDOW:
delete dat->Panel;
if (dat->pContainer->dwFlags & CNT_SIDEBAR)
dat->pContainer->SideBar->removeSession(dat);
- free(dat);
+ mir_free(dat);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
}
break;