diff options
Diffstat (limited to 'plugins/NewAwaySysMod')
-rw-r--r-- | plugins/NewAwaySysMod/src/Common.h | 1 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/GroupCheckbox.cpp | 13 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/MsgEventAdded.cpp | 3 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/ReadAwayMsg.cpp | 4 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/SetAwayMsg.cpp | 4 |
5 files changed, 11 insertions, 14 deletions
diff --git a/plugins/NewAwaySysMod/src/Common.h b/plugins/NewAwaySysMod/src/Common.h index f9ca1ef548..178eb52bfb 100644 --- a/plugins/NewAwaySysMod/src/Common.h +++ b/plugins/NewAwaySysMod/src/Common.h @@ -29,6 +29,7 @@ #include <windows.h>
#include <stdio.h>
#include <stdlib.h>
+#include <malloc.h>
#include <CommCtrl.h>
#include <commdlg.h>
#include <Uxtheme.h>
diff --git a/plugins/NewAwaySysMod/src/GroupCheckbox.cpp b/plugins/NewAwaySysMod/src/GroupCheckbox.cpp index fed51eb888..1cc6c21e01 100644 --- a/plugins/NewAwaySysMod/src/GroupCheckbox.cpp +++ b/plugins/NewAwaySysMod/src/GroupCheckbox.cpp @@ -88,17 +88,15 @@ static int CALLBACK CheckboxWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM l HFONT hOldFont = (HFONT)SelectObject(hdc, dat->hFont);
RECT rcText = { 0 };
if (hTheme) {
- WCHAR *szText = (WCHAR*)malloc(Len * sizeof(WCHAR));
+ WCHAR *szText = (WCHAR*)_alloca(Len * sizeof(WCHAR));
GetWindowTextW(hWnd, szText, Len);
GetThemeTextExtent(hTheme, hdc, BP_GROUPBOX, IsWindowEnabled(hWnd) ? GBS_NORMAL : GBS_DISABLED, szText, -1, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE, 0, &rcText);
- free(szText);
}
else {
SIZE size;
- TCHAR *szText = (TCHAR*)malloc(Len * sizeof(TCHAR));
+ TCHAR *szText = (TCHAR*)_alloca(Len * sizeof(TCHAR));
GetWindowText(hWnd, szText, Len);
GetTextExtentPoint32(hdc, szText, (int)mir_tstrlen(szText), &size);
- free(szText);
rcText.right = size.cx;
rcText.bottom = size.cy;
}
@@ -276,7 +274,7 @@ static int CALLBACK CheckboxWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM l rc.left += CG_CHECKBOX_INDENT + CG_CHECKBOX_WIDTH + CG_TEXT_INDENT;
int Len = GetWindowTextLength(hWnd) + 1;
- TCHAR *szTextT = (TCHAR*)malloc(Len * sizeof(TCHAR));
+ TCHAR *szTextT = (TCHAR*)_alloca(Len * sizeof(TCHAR));
GetWindowText(hWnd, szTextT, Len);
HFONT hOldFont = (HFONT)SelectObject(hdcMem, dat->hFont);
@@ -301,11 +299,10 @@ static int CALLBACK CheckboxWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM l InflateRect(&rcText, 1, -1);
DrawFocusRect(hdcMem, &rcText);
}
- free(szTextT);
SelectObject(hdcMem, hOldFont);
- if (hTheme) {
+ if (hTheme)
CloseThemeData(hTheme);
- }
+
BitBlt(hdc, 0, 0, rc.right, rc.bottom, hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, hbmOld);
DeleteObject(hbmMem);
diff --git a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp index c62d050c75..61a45f0af6 100644 --- a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp +++ b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp @@ -59,7 +59,7 @@ void __cdecl AutoreplyDelayThread(void *_ad) }
int ReplyLen = (ad->Reply.GetLen() + 1) * (sizeof(char)+sizeof(WCHAR));
- PBYTE pBuf = (PBYTE)malloc(ReplyLen);
+ PBYTE pBuf = (PBYTE)_alloca(ReplyLen);
memcpy(pBuf, _T2A(ad->Reply), ad->Reply.GetLen() + 1);
memcpy(pBuf + ad->Reply.GetLen() + 1, ad->Reply, (ad->Reply.GetLen() + 1) * sizeof(WCHAR));
CallContactService(ad->hContact, ServiceExists(CString(szProto) + PSS_MESSAGE "W") ? (PSS_MESSAGE "W") : PSS_MESSAGE, PREF_UNICODE, (LPARAM)pBuf);
@@ -79,7 +79,6 @@ void __cdecl AutoreplyDelayThread(void *_ad) db_event_add(ad->hContact, &dbeo);
}
- free(pBuf);
delete ad;
}
diff --git a/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp b/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp index 62a621fae1..8a49dcf6ef 100644 --- a/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp @@ -70,10 +70,10 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam char *szProto = GetContactProto(awayData->hContact);
TCHAR *status = pcli->pfnGetStatusModeDescription(db_get_w(awayData->hContact, szProto, "Status", ID_STATUS_OFFLINE), 0);
GetWindowText(hwndDlg, format, SIZEOF(format));
- _sntprintf(str, SIZEOF(str), format, status, contactName);
+ mir_sntprintf(str, SIZEOF(str), format, status, contactName);
SetWindowText(hwndDlg, str);
GetDlgItemText(hwndDlg, IDC_READAWAYMSG_RETRIEVE, format, SIZEOF(format));
- _sntprintf(str, SIZEOF(str), format, status);
+ mir_sntprintf(str, SIZEOF(str), format, status);
SetDlgItemText(hwndDlg, IDC_READAWAYMSG_RETRIEVE, str);
}
return true;
diff --git a/plugins/NewAwaySysMod/src/SetAwayMsg.cpp b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp index c944d2fc2c..a30283fb4f 100644 --- a/plugins/NewAwaySysMod/src/SetAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp @@ -78,11 +78,11 @@ static LRESULT CALLBACK MsgEditSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, SendMessage(hWnd, WM_KEYDOWN, VK_LEFT, 0);
SendMessage(hWnd, EM_GETSEL, (WPARAM)&start, NULL);
int nLen = GetWindowTextLength(hWnd);
- TCHAR *text = (TCHAR*)malloc((nLen + 1) * sizeof(TCHAR));
+ TCHAR *text = (TCHAR*)_alloca((nLen + 1) * sizeof(TCHAR));
GetWindowText(hWnd, text, nLen + 1);
memmove(text + start, text + end, sizeof(TCHAR)* (_tcslen(text) + 1 - end));
SetWindowText(hWnd, text);
- free(text);
+
SendMessage(hWnd, EM_SETSEL, start, start);
SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), EN_CHANGE), (LPARAM)hWnd);
return 0;
|