summaryrefslogtreecommitdiff
path: root/src/core/stdclist
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-19 19:35:42 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-19 19:35:42 +0000
commit4c814798c7bc7f6a0f92c21b027b26290622aa2f (patch)
tree9bbfb38bd639f352300aa16ff7c45f5a9b2dba6d /src/core/stdclist
parentf0f0cd088f1ec3a85abee825ddbc214f3f6b92c3 (diff)
SIZEOF replaced with more secure analog - _countof
git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core/stdclist')
-rw-r--r--src/core/stdclist/src/clcfonts.cpp18
-rw-r--r--src/core/stdclist/src/clcopts.cpp18
-rw-r--r--src/core/stdclist/src/clcpaint.cpp4
-rw-r--r--src/core/stdclist/src/cluiopts.cpp2
4 files changed, 21 insertions, 21 deletions
diff --git a/src/core/stdclist/src/clcfonts.cpp b/src/core/stdclist/src/clcfonts.cpp
index 873fb00d56..560a3a6363 100644
--- a/src/core/stdclist/src/clcfonts.cpp
+++ b/src/core/stdclist/src/clcfonts.cpp
@@ -54,10 +54,10 @@ void RegisterCListFonts()
FontIDT fontid = { sizeof(fontid) };
fontid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWREREGISTER | FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS;
strncpy(fontid.dbSettingsGroup, "CLC", sizeof(fontid.dbSettingsGroup));
- _tcsncpy(fontid.group, LPGENT("Contact list"), SIZEOF(fontid.group));
+ _tcsncpy(fontid.group, LPGENT("Contact list"), _countof(fontid.group));
HDC hdc = GetDC(NULL);
- for (int i = 0; i < SIZEOF(clistFontDescr); i++) {
+ for (int i = 0; i < _countof(clistFontDescr); i++) {
LOGFONT lf;
pcli->pfnGetFontSetting(i, &lf, &fontid.deffontsettings.colour);
lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hdc, LOGPIXELSY), 72);
@@ -70,11 +70,11 @@ void RegisterCListFonts()
fontid.flags &= ~FIDF_CLASSMASK;
fontid.flags |= clistFontDescr[i].iMask;
- _tcsncpy(fontid.name, clistFontDescr[i].tszName, SIZEOF(fontid.name));
+ _tcsncpy(fontid.name, clistFontDescr[i].tszName, _countof(fontid.name));
char idstr[10];
mir_snprintf(idstr, "Font%d", i);
- strncpy(fontid.prefix, idstr, SIZEOF(fontid.prefix));
+ strncpy(fontid.prefix, idstr, _countof(fontid.prefix));
fontid.order = i;
FontRegisterT(&fontid);
}
@@ -87,25 +87,25 @@ void RegisterCListFonts()
strncpy(colourid.dbSettingsGroup, "CLC", sizeof(colourid.dbSettingsGroup));
strncpy(colourid.setting, "BkColour", sizeof(colourid.setting));
- _tcsncpy(colourid.name, LPGENT("Background"), SIZEOF(colourid.name));
- _tcsncpy(colourid.group, LPGENT("Contact list"), SIZEOF(colourid.group));
+ _tcsncpy(colourid.name, LPGENT("Background"), _countof(colourid.name));
+ _tcsncpy(colourid.group, LPGENT("Contact list"), _countof(colourid.group));
colourid.defcolour = CLCDEFAULT_BKCOLOUR;
ColourRegisterT(&colourid);
strncpy(colourid.setting, "SelTextColour", sizeof(colourid.setting));
- _tcsncpy(colourid.name, LPGENT("Selected text"), SIZEOF(colourid.name));
+ _tcsncpy(colourid.name, LPGENT("Selected text"), _countof(colourid.name));
colourid.order = 1;
colourid.defcolour = CLCDEFAULT_SELTEXTCOLOUR;
ColourRegisterT(&colourid);
strncpy(colourid.setting, "HotTextColour", sizeof(colourid.setting));
- _tcsncpy(colourid.name, LPGENT("Hottrack text"), SIZEOF(colourid.name));
+ _tcsncpy(colourid.name, LPGENT("Hottrack text"), _countof(colourid.name));
colourid.order = 1;
colourid.defcolour = CLCDEFAULT_HOTTEXTCOLOUR;
ColourRegisterT(&colourid);
strncpy(colourid.setting, "QuickSearchColour", sizeof(colourid.setting));
- _tcsncpy(colourid.name, LPGENT("Quicksearch text"), SIZEOF(colourid.name));
+ _tcsncpy(colourid.name, LPGENT("Quicksearch text"), _countof(colourid.name));
colourid.order = 1;
colourid.defcolour = CLCDEFAULT_QUICKSEARCHCOLOUR;
ColourRegisterT(&colourid);
diff --git a/src/core/stdclist/src/clcopts.cpp b/src/core/stdclist/src/clcopts.cpp
index 3312357c5b..f54350b67c 100644
--- a/src/core/stdclist/src/clcopts.cpp
+++ b/src/core/stdclist/src/clcopts.cpp
@@ -150,7 +150,7 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam
{
int i;
DWORD exStyle = db_get_dw(NULL, "CLC", "ExStyle", pcli->pfnGetDefaultExStyle());
- for (i = 0; i < SIZEOF(checkBoxToStyleEx); i++)
+ for (i = 0; i < _countof(checkBoxToStyleEx); i++)
CheckDlgButton(hwndDlg, checkBoxToStyleEx[i].id,
(exStyle & checkBoxToStyleEx[i].flag) ^ (checkBoxToStyleEx[i].flag *
checkBoxToStyleEx[i].not) ? BST_CHECKED : BST_UNCHECKED);
@@ -158,7 +158,7 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam
{
UDACCEL accel[2] = { {0, 10} , {2, 50} };
SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETRANGE, 0, MAKELONG(999, 0));
- SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETACCEL, SIZEOF(accel), (LPARAM) & accel);
+ SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETACCEL, _countof(accel), (LPARAM) & accel);
SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETPOS, 0,
MAKELONG(db_get_w(NULL, "CLC", "ScrollTime", CLCDEFAULT_SCROLLTIME), 0));
}
@@ -173,9 +173,9 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam
db_get_dw(NULL, "CLC", "GreyoutFlags", CLCDEFAULT_GREYOUTFLAGS) ? BST_CHECKED : BST_UNCHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_SMOOTHTIME), IsDlgButtonChecked(hwndDlg, IDC_NOTNOSMOOTHSCROLLING));
EnableWindow(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS), IsDlgButtonChecked(hwndDlg, IDC_GREYOUT));
- FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS), greyoutValues, SIZEOF(greyoutValues),
+ FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS), greyoutValues, _countof(greyoutValues),
db_get_dw(NULL, "CLC", "FullGreyoutFlags", CLCDEFAULT_FULLGREYOUTFLAGS));
- FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), offlineValues, SIZEOF(offlineValues),
+ FillCheckBoxTree(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), offlineValues, _countof(offlineValues),
db_get_dw(NULL, "CLC", "OfflineModes", CLCDEFAULT_OFFLINEMODES));
CheckDlgButton(hwndDlg, IDC_NOSCROLLBAR, db_get_b(NULL, "CLC", "NoVScrollBar", 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_GAMMACORRECT, db_get_b(NULL, "CLC", "GammaCorrect", CLCDEFAULT_GAMMACORRECT) ? BST_CHECKED : BST_UNCHECKED);
@@ -239,7 +239,7 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam
if (((LPNMHDR) lParam)->code == PSN_APPLY ) {
int i;
DWORD exStyle = 0;
- for (i = 0; i < SIZEOF(checkBoxToStyleEx); i++)
+ for (i = 0; i < _countof(checkBoxToStyleEx); i++)
if ((IsDlgButtonChecked(hwndDlg, checkBoxToStyleEx[i].id) == 0) == checkBoxToStyleEx[i].not)
exStyle |= checkBoxToStyleEx[i].flag;
@@ -335,17 +335,17 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
case WM_COMMAND:
if (LOWORD(wParam) == IDC_BROWSE) {
TCHAR str[MAX_PATH], filter[512];
- GetDlgItemText(hwndDlg, IDC_FILENAME, str, SIZEOF(str));
+ GetDlgItemText(hwndDlg, IDC_FILENAME, str, _countof(str));
OPENFILENAME ofn = { 0 };
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwndDlg;
ofn.hInstance = NULL;
- Bitmap_GetFilter(filter, SIZEOF(filter));
+ Bitmap_GetFilter(filter, _countof(filter));
ofn.lpstrFilter = filter;
ofn.lpstrFile = str;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
- ofn.nMaxFile = SIZEOF(str);
+ ofn.nMaxFile = _countof(str);
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = _T("bmp");
if (!GetOpenFileName(&ofn))
@@ -384,7 +384,7 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
}
{
char str[MAX_PATH], strrel[MAX_PATH];
- GetDlgItemTextA(hwndDlg, IDC_FILENAME, str, SIZEOF(str));
+ GetDlgItemTextA(hwndDlg, IDC_FILENAME, str, _countof(str));
if ( PathToRelative(str, strrel))
db_set_s(NULL, "CLC", "BkBitmap", strrel);
else
diff --git a/src/core/stdclist/src/clcpaint.cpp b/src/core/stdclist/src/clcpaint.cpp
index 36e5918a35..c81daf2932 100644
--- a/src/core/stdclist/src/clcpaint.cpp
+++ b/src/core/stdclist/src/clcpaint.cpp
@@ -513,7 +513,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint)
pts[6].y = pts[5].y;
pts[7].x = pts[0].x;
pts[7].y = pts[4].y;
- HRGN hRgn = CreatePolygonRgn(pts, SIZEOF(pts), ALTERNATE);
+ HRGN hRgn = CreatePolygonRgn(pts, _countof(pts), ALTERNATE);
HBRUSH hBrush = CreateSolidBrush(dat->fontInfo[FONTID_CONTACTS].colour);
FillRgn(hdcMem, hRgn, hBrush);
DeleteObject(hBrush);
@@ -543,7 +543,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint)
int greyGreen = GetGValue(greyColour) * 2;
int greyBlue = GetBValue(greyColour) * 2;
if (divide3[0] == 255) {
- for (i = 0; i < SIZEOF(divide3); i++)
+ for (i = 0; i < _countof(divide3); i++)
divide3[i] = (i + 1) / 3;
}
for (int i = 4 * clRect.right * clRect.bottom - 4; i >= 0; i -= 4) {
diff --git a/src/core/stdclist/src/cluiopts.cpp b/src/core/stdclist/src/cluiopts.cpp
index af5fe02bee..76dacac9c2 100644
--- a/src/core/stdclist/src/cluiopts.cpp
+++ b/src/core/stdclist/src/cluiopts.cpp
@@ -172,7 +172,7 @@ static INT_PTR CALLBACK DlgProcCluiOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
db_set_b(NULL, "CList", "Min2Tray", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_MIN2TRAY));
{
TCHAR title[256];
- GetDlgItemText(hwndDlg, IDC_TITLETEXT, title, SIZEOF(title));
+ GetDlgItemText(hwndDlg, IDC_TITLETEXT, title, _countof(title));
db_set_ts(NULL, "CList", "TitleText", title);
SetWindowText(pcli->hwndContactList, title);
}