[IMAGESOFT] Use ARRAYSIZE / un-hardcode some sizeof(TYPE) where applicable.

This commit is contained in:
Hermès Bélusca-Maïto 2021-09-26 02:38:37 +02:00
parent 67fd29cae0
commit 516c8829ea
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
11 changed files with 27 additions and 28 deletions

View file

@ -32,7 +32,7 @@ AboutDialogProc(HWND hDlg,
LoadString(hInstance, LoadString(hInstance,
IDS_LICENSE, IDS_LICENSE,
strLicense, strLicense,
sizeof(strLicense) / sizeof(TCHAR)); ARRAYSIZE(strLicense));
SetWindowText(hLicenseEditWnd, SetWindowText(hLicenseEditWnd,
strLicense); strLicense);

View file

@ -15,7 +15,7 @@ DisplayBlackAndWhite(HWND hwnd,
RECT rc; RECT rc;
GetObject(hBitmap, GetObject(hBitmap,
sizeof(BITMAP), sizeof(bitmap),
&bitmap); &bitmap);
/* Bitmap header */ /* Bitmap header */
@ -112,7 +112,7 @@ DisplayInvertedColors(HWND hwnd,
RECT rc; RECT rc;
GetObject(hBitmap, GetObject(hBitmap,
sizeof(BITMAP), sizeof(bitmap),
&bitmap); &bitmap);
/* Bitmap header */ /* Bitmap header */
@ -206,7 +206,7 @@ DisplayBlur(HWND hwnd,
RECT rc; RECT rc;
GetObject(hBitmap, GetObject(hBitmap,
sizeof(BITMAP), sizeof(bitmap),
&bitmap); &bitmap);
/* Bitmap header */ /* Bitmap header */
@ -367,7 +367,7 @@ DisplaySharpness(HWND hwnd,
RECT rc; RECT rc;
GetObject(hBitmap, GetObject(hBitmap,
sizeof(BITMAP), sizeof(bitmap),
&bitmap); &bitmap);
/* Bitmap header */ /* Bitmap header */

View file

@ -21,7 +21,7 @@ AdjustBrightness(HBITMAP hOrigBitmap,
RECT rc; RECT rc;
GetObject(hNewBitmap, GetObject(hNewBitmap,
sizeof(BITMAP), sizeof(bitmap),
&bitmap); &bitmap);
/* Bitmap header */ /* Bitmap header */

View file

@ -21,7 +21,7 @@ AdjustContrast(HBITMAP hOrigBitmap,
RECT rc; RECT rc;
GetObject(hNewBitmap, GetObject(hNewBitmap,
sizeof(BITMAP), sizeof(bitmap),
&bitmap); &bitmap);
/* Bitmap header */ /* Bitmap header */

View file

@ -58,8 +58,7 @@ FloatToolbarCreateToolsGui(PMAIN_WND_INFO Info)
HIMAGELIST hImageList; HIMAGELIST hImageList;
UINT NumButtons; UINT NumButtons;
NumButtons = sizeof(ToolsButtons) / sizeof(ToolsButtons[0]); NumButtons = ARRAYSIZE(ToolsButtons);
hTb = CreateWindowEx(0, hTb = CreateWindowEx(0,
TOOLBARCLASSNAME, TOOLBARCLASSNAME,
NULL, NULL,
@ -293,7 +292,7 @@ FloatToolbarCreateHistoryGui(PMAIN_WND_INFO Info)
if (hList == NULL) if (hList == NULL)
return FALSE; return FALSE;
NumButtons = sizeof(HistoryButtons) / sizeof(HistoryButtons[0]); NumButtons = ARRAYSIZE(HistoryButtons);
hButtons = CreateWindowEx(0, hButtons = CreateWindowEx(0,
TOOLBARCLASSNAME, TOOLBARCLASSNAME,
NULL, NULL,
@ -603,7 +602,7 @@ InitFloatWndClass(VOID)
{ {
WNDCLASSEX wc = {0}; WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX); wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = FloatToolbarWndProc; wc.lpfnWndProc = FloatToolbarWndProc;
wc.hInstance = hInstance; wc.hInstance = hInstance;

View file

@ -16,7 +16,7 @@ EnumFontSizes(ENUMLOGFONTEX *lpelfe,
if (fTrueType) if (fTrueType)
{ {
for (i = 0; i < (sizeof(ttsizes) / sizeof(ttsizes[0])); i++) for (i = 0; i < ARRAYSIZE(ttsizes); i++)
{ {
wsprintf(ach, _T("%d"), ttsizes[i]); wsprintf(ach, _T("%d"), ttsizes[i]);

View file

@ -20,7 +20,7 @@ _tWinMain(HINSTANCE hThisInstance,
hInstance = hThisInstance; hInstance = hThisInstance;
ProcessHeap = GetProcessHeap(); ProcessHeap = GetProcessHeap();
icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwSize = sizeof(icex);
icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES; icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
InitCommonControlsEx(&icex); InitCommonControlsEx(&icex);

View file

@ -65,14 +65,14 @@ LoadDIBImage(PEDIT_WND_INFO Info)
bSuccess = ReadFile(hFile, bSuccess = ReadFile(hFile,
&bmfh, &bmfh,
sizeof(BITMAPFILEHEADER), sizeof(bmfh),
&BytesRead, &BytesRead,
NULL); NULL);
if (bSuccess && (BytesRead == sizeof(BITMAPFILEHEADER)) if (bSuccess && (BytesRead == sizeof(bmfh))
&& (bmfh.bfType == *(WORD *)"BM")) && (bmfh.bfType == *(WORD *)"BM"))
{ {
DWORD InfoSize = bmfh.bfOffBits - sizeof(BITMAPFILEHEADER); DWORD InfoSize = bmfh.bfOffBits - sizeof(bmfh);
Info->pbmi = HeapAlloc(ProcessHeap, Info->pbmi = HeapAlloc(ProcessHeap,
0, 0,
@ -102,7 +102,7 @@ LoadDIBImage(PEDIT_WND_INFO Info)
NULL); NULL);
GetObject(Info->hBitmap, GetObject(Info->hBitmap,
sizeof(BITMAP), sizeof(bitmap),
&bitmap); &bitmap);
Info->Width = bitmap.bmWidth; Info->Width = bitmap.bmWidth;
@ -514,7 +514,7 @@ InitImageEditWindowImpl(VOID)
{ {
WNDCLASSEX wc = {0}; WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX); wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = ImageEditWndProc; wc.lpfnWndProc = ImageEditWndProc;
wc.hInstance = hInstance; wc.hInstance = hInstance;

View file

@ -129,7 +129,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
case ID_TOOLBAR_STANDARD: case ID_TOOLBAR_STANDARD:
{ {
Buttons = StdButtons; Buttons = StdButtons;
NumButtons = sizeof(StdButtons) / sizeof(StdButtons[0]); NumButtons = ARRAYSIZE(StdButtons);
StartImageRes = IDB_MAINNEWICON; StartImageRes = IDB_MAINNEWICON;
NumImages = 10; NumImages = 10;
break; break;
@ -138,7 +138,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
case ID_TOOLBAR_TEXT: case ID_TOOLBAR_TEXT:
{ {
Buttons = TextButtons; Buttons = TextButtons;
NumButtons = sizeof(TextButtons) / sizeof(TextButtons[0]); NumButtons = ARRAYSIZE(TextButtons);
StartImageRes = IDB_TEXTBOLD; StartImageRes = IDB_TEXTBOLD;
NumImages = 6; NumImages = 6;
break; break;
@ -493,7 +493,7 @@ MainWndMoveFloatingWindows(PMAIN_WND_INFO Info,
CopyMemory(wndOldPos, CopyMemory(wndOldPos,
&wndNewPos, &wndNewPos,
sizeof(RECT)); sizeof(wndOldPos));
} }
} }
@ -665,7 +665,7 @@ CreateToolbars(PMAIN_WND_INFO Info)
{ {
UINT i; UINT i;
for (i = 0; i < sizeof(MainDockBars) / sizeof(MainDockBars[0]); i++) for (i = 0; i < ARRAYSIZE(MainDockBars); i++)
{ {
/* FIXME - lookup whether to display the toolbar */ /* FIXME - lookup whether to display the toolbar */
TbdAddToolbar(&Info->ToolDocks, TbdAddToolbar(&Info->ToolDocks,
@ -774,7 +774,7 @@ InitMainWnd(PMAIN_WND_INFO Info)
if (Info->hStatus != NULL) if (Info->hStatus != NULL)
SendMessage(Info->hStatus, SendMessage(Info->hStatus,
SB_SETPARTS, SB_SETPARTS,
sizeof(statwidths)/sizeof(int), ARRAYSIZE(statwidths),
(LPARAM)statwidths); (LPARAM)statwidths);
/* create the MDI client window */ /* create the MDI client window */
@ -1170,13 +1170,13 @@ MainWndProc(HWND hwnd,
if (!MainWndMenuHint(Info, if (!MainWndMenuHint(Info,
LOWORD(wParam), LOWORD(wParam),
MainMenuHintTable, MainMenuHintTable,
sizeof(MainMenuHintTable) / sizeof(MainMenuHintTable[0]), ARRAYSIZE(MainMenuHintTable),
IDS_HINT_BLANK)) IDS_HINT_BLANK))
{ {
MainWndMenuHint(Info, MainWndMenuHint(Info,
LOWORD(wParam), LOWORD(wParam),
SystemMenuHintTable, SystemMenuHintTable,
sizeof(SystemMenuHintTable) / sizeof(SystemMenuHintTable[0]), ARRAYSIZE(SystemMenuHintTable),
IDS_HINT_BLANK); IDS_HINT_BLANK);
} }
} }
@ -1428,7 +1428,7 @@ InitMainWindowImpl(VOID)
{ {
WNDCLASSEX wc = {0}; WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX); wc.cbSize = sizeof(wc);
wc.lpfnWndProc = MainWndProc; wc.lpfnWndProc = MainWndProc;
wc.hInstance = hInstance; wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, wc.hIcon = LoadIcon(hInstance,

View file

@ -8,7 +8,7 @@ static OPENFILENAME ofn;
VOID FileInitialize(HWND hwnd) VOID FileInitialize(HWND hwnd)
{ {
ZeroMemory(&ofn, sizeof(ofn)); ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAME); ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd; ofn.hwndOwner = hwnd;
ofn.nMaxFile = MAX_PATH; ofn.nMaxFile = MAX_PATH;
ofn.nMaxFileTitle = MAX_PATH; ofn.nMaxFileTitle = MAX_PATH;

View file

@ -1117,7 +1117,7 @@ TbdInitImpl(VOID)
{ {
WNDCLASSEX wc = {0}; WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX); wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = ToolDockWndProc; wc.lpfnWndProc = ToolDockWndProc;
wc.cbWndExtra = TD_EXTRA_BYTES; wc.cbWndExtra = TD_EXTRA_BYTES;