Commit 9713e68a authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

shlwapi: Use the ARRAY_SIZE() macro.

parent 923cb0a9
......@@ -276,7 +276,7 @@ HRESULT WINAPI AssocQueryStringA(ASSOCF cfFlags, ASSOCSTR str, LPCSTR pszAssoc,
lpszReturnW = HeapAlloc(GetProcessHeap(), 0,
(dwLenOut + 1) * sizeof(WCHAR));
else
dwLenOut = sizeof(szReturnW) / sizeof(szReturnW[0]);
dwLenOut = ARRAY_SIZE(szReturnW);
if (!lpszReturnW)
hRet = E_OUTOFMEMORY;
......
......@@ -2440,7 +2440,7 @@ HMODULE WINAPI SHPinDllOfCLSID(REFIID refiid)
CHAR value[MAX_PATH], string[MAX_PATH];
strcpy(string, "CLSID\\");
SHStringFromGUIDA(refiid, string + 6, sizeof(string)/sizeof(char) - 6);
SHStringFromGUIDA(refiid, string + 6, ARRAY_SIZE(string) - 6);
strcat(string, "\\InProcServer32");
count = MAX_PATH;
......@@ -2778,7 +2778,7 @@ VOID WINAPI SHWeakReleaseInterface(IUnknown *lpDest, IUnknown **lppUnknown)
BOOL WINAPI GUIDFromStringA(LPCSTR idstr, CLSID *id)
{
WCHAR wClsid[40];
MultiByteToWideChar(CP_ACP, 0, idstr, -1, wClsid, sizeof(wClsid)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, idstr, -1, wClsid, ARRAY_SIZE(wClsid));
return SUCCEEDED(CLSIDFromString(wClsid, id));
}
......@@ -3600,8 +3600,8 @@ HMODULE WINAPI MLLoadLibraryW(LPCWSTR new_mod, HMODULE inst_hwnd, DWORD dwCrossC
DWORD len;
FIXME("(%s,%p,%d) semi-stub!\n", debugstr_w(new_mod), inst_hwnd, dwCrossCodePage);
len = GetModuleFileNameW(inst_hwnd, mod_path, sizeof(mod_path) / sizeof(WCHAR));
if (!len || len >= sizeof(mod_path) / sizeof(WCHAR)) return NULL;
len = GetModuleFileNameW(inst_hwnd, mod_path, ARRAY_SIZE(mod_path));
if (!len || len >= ARRAY_SIZE(mod_path)) return NULL;
ptr = strrchrW(mod_path, '\\');
if (ptr) {
......@@ -4755,7 +4755,7 @@ INT WINAPIV ShellMessageBoxWrapW(HINSTANCE hInstance, HWND hWnd, LPCWSTR lpText,
TRACE("(%p,%p,%p,%p,%08x)\n", hInstance, hWnd, lpText, lpCaption, uType);
if (IS_INTRESOURCE(lpCaption))
LoadStringW(hInstance, LOWORD(lpCaption), szTitle, sizeof(szTitle)/sizeof(szTitle[0]));
LoadStringW(hInstance, LOWORD(lpCaption), szTitle, ARRAY_SIZE(szTitle));
else
pszTitle = lpCaption;
......@@ -5280,8 +5280,8 @@ DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'S','h','e','l','l','C','o','m','p','a','t','i','b','i','l','i','t','y','\\',
'O','b','j','e','c','t','s','\\','%','s',0};
WCHAR strW[sizeof(compatpathW)/sizeof(WCHAR) + 38 /* { CLSID } */];
DWORD ret, length = sizeof(strW)/sizeof(WCHAR);
WCHAR strW[ARRAY_SIZE(compatpathW) + 38 /* { CLSID } */];
DWORD ret, length = ARRAY_SIZE(strW);
OLECHAR *clsid_str;
HKEY key;
INT i;
......@@ -5311,7 +5311,7 @@ DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
/* search in table */
left = 0;
right = sizeof(objcompat_table) / sizeof(struct objcompat_entry) - 1;
right = ARRAY_SIZE(objcompat_table) - 1;
while (right >= left) {
x = (left + right) / 2;
......@@ -5327,7 +5327,7 @@ DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
left = x + 1;
}
length = sizeof(strW)/sizeof(WCHAR);
length = ARRAY_SIZE(strW);
}
return ret;
......
......@@ -3264,7 +3264,7 @@ HRESULT WINAPI PathCreateFromUrlA(LPCSTR pszUrl, LPSTR pszPath,
WCHAR *pathW = bufW;
UNICODE_STRING urlW;
HRESULT ret;
DWORD lenW = sizeof(bufW)/sizeof(WCHAR), lenA;
DWORD lenW = ARRAY_SIZE(bufW), lenA;
if (!pszUrl || !pszPath || !pcchPath || !*pcchPath)
return E_INVALIDARG;
......@@ -3684,7 +3684,7 @@ VOID WINAPI PathSetDlgItemPathW(HWND hDlg, int id, LPCWSTR lpszPath)
return;
if (lpszPath)
lstrcpynW(path, lpszPath, sizeof(path) / sizeof(WCHAR));
lstrcpynW(path, lpszPath, ARRAY_SIZE(path));
else
path[0] = '\0';
......@@ -4122,7 +4122,7 @@ static void init_envvars_map(struct envvars_map *map)
{
while (map->var)
{
map->len = ExpandEnvironmentStringsW(map->var, map->path, sizeof(map->path)/sizeof(WCHAR));
map->len = ExpandEnvironmentStringsW(map->var, map->path, ARRAY_SIZE(map->path));
/* exclude null from length */
if (map->len) map->len--;
map++;
......@@ -4139,12 +4139,12 @@ BOOL WINAPI PathUnExpandEnvStringsW(LPCWSTR path, LPWSTR buffer, UINT buf_len)
static struct envvars_map null_var = {NULL, 0, {0}, 0};
struct envvars_map *match = &null_var, *cur;
struct envvars_map envvars[] = {
{ allusersprofileW, sizeof(allusersprofileW)/sizeof(WCHAR) },
{ appdataW, sizeof(appdataW)/sizeof(WCHAR) },
{ programfilesW, sizeof(programfilesW)/sizeof(WCHAR) },
{ systemrootW, sizeof(systemrootW)/sizeof(WCHAR) },
{ systemdriveW, sizeof(systemdriveW)/sizeof(WCHAR) },
{ userprofileW, sizeof(userprofileW)/sizeof(WCHAR) },
{ allusersprofileW, ARRAY_SIZE(allusersprofileW) },
{ appdataW, ARRAY_SIZE(appdataW) },
{ programfilesW, ARRAY_SIZE(programfilesW) },
{ systemrootW, ARRAY_SIZE(systemrootW) },
{ systemdriveW, ARRAY_SIZE(systemdriveW) },
{ userprofileW, ARRAY_SIZE(userprofileW) },
{ NULL }
};
DWORD pathlen;
......
......@@ -134,7 +134,7 @@ LONG WINAPI SHRegOpenUSKeyW(LPCWSTR Path, REGSAM AccessType, HUSKEY hRelativeUSK
/* Create internal HUSKEY */
hKey = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*hKey));
lstrcpynW(hKey->lpszPath, Path, sizeof(hKey->lpszPath)/sizeof(WCHAR));
lstrcpynW(hKey->lpszPath, Path, ARRAY_SIZE(hKey->lpszPath));
if (hRelativeUSKey)
{
......@@ -275,7 +275,7 @@ LONG WINAPI SHRegCreateUSKeyW(LPCWSTR path, REGSAM samDesired, HUSKEY relative_k
}
ret_key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret_key));
lstrcpynW(ret_key->lpszPath, path, sizeof(ret_key->lpszPath)/sizeof(WCHAR));
lstrcpynW(ret_key->lpszPath, path, ARRAY_SIZE(ret_key->lpszPath));
if (relative_key)
{
......@@ -1534,7 +1534,7 @@ DWORD WINAPI SHDeleteKeyA(HKEY hKey, LPCSTR lpszSubKey)
{
WCHAR subkeyW[MAX_PATH];
MultiByteToWideChar (CP_ACP, 0, lpszSubKey, -1, subkeyW, sizeof(subkeyW)/sizeof(WCHAR));
MultiByteToWideChar (CP_ACP, 0, lpszSubKey, -1, subkeyW, ARRAY_SIZE(subkeyW));
return SHDeleteKeyW(hKey, subkeyW);
}
......@@ -1560,7 +1560,7 @@ DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
if(!dwRet)
{
dwMaxSubkeyLen++;
if (dwMaxSubkeyLen > sizeof(szNameBuf)/sizeof(WCHAR))
if (dwMaxSubkeyLen > ARRAY_SIZE(szNameBuf))
/* Name too big: alloc a buffer for it */
lpszName = HeapAlloc(GetProcessHeap(), 0, dwMaxSubkeyLen*sizeof(WCHAR));
......@@ -2409,7 +2409,7 @@ HRESULT WINAPI SHRegGetCLSIDKeyA(REFGUID guid, LPCSTR lpszValue, BOOL bUseHKCU,
WCHAR szValue[MAX_PATH];
if (lpszValue)
MultiByteToWideChar(CP_ACP, 0, lpszValue, -1, szValue, sizeof(szValue)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpszValue, -1, szValue, ARRAY_SIZE(szValue));
return SHRegGetCLSIDKeyW(guid, lpszValue ? szValue : NULL, bUseHKCU, bCreate, phKey);
}
......
......@@ -71,7 +71,7 @@ static void FillNumberFmt(NUMBERFMTW *fmt, LPWSTR decimal_buffer, int decimal_bu
* http://blogs.msdn.com/oldnewthing/archive/2006/04/18/578251.aspx
*/
fmt->Grouping = 0;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, grouping, sizeof(grouping)/sizeof(WCHAR));
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, grouping, ARRAY_SIZE(grouping));
for (c = grouping; *c; c++)
if (*c >= '0' && *c < '9')
{
......@@ -101,8 +101,7 @@ static int FormatInt(LONGLONG qdwValue, LPWSTR pszBuf, int cchBuf)
WCHAR *c;
BOOL neg = (qdwValue < 0);
FillNumberFmt(&fmt, decimal, sizeof decimal / sizeof (WCHAR),
thousand, sizeof thousand / sizeof (WCHAR));
FillNumberFmt(&fmt, decimal, ARRAY_SIZE(decimal), thousand, ARRAY_SIZE(thousand));
c = &buf[24];
*(--c) = 0;
......@@ -135,8 +134,7 @@ static int FormatDouble(double value, int decimals, LPWSTR pszBuf, int cchBuf)
snprintfW(buf, 64, flfmt, value);
FillNumberFmt(&fmt, decimal, sizeof decimal / sizeof (WCHAR),
thousand, sizeof thousand / sizeof (WCHAR));
FillNumberFmt(&fmt, decimal, ARRAY_SIZE(decimal), thousand, ARRAY_SIZE(thousand));
fmt.NumDigits = decimals;
return GetNumberFormatW(LOCALE_USER_DEFAULT, 0, buf, &fmt, pszBuf, cchBuf);
}
......@@ -2124,7 +2122,7 @@ INT WINAPI StrFromTimeIntervalA(LPSTR lpszStr, UINT cchMax, DWORD dwMS,
if (lpszStr && cchMax)
{
WCHAR szBuff[128];
StrFromTimeIntervalW(szBuff, sizeof(szBuff)/sizeof(WCHAR), dwMS, iDigits);
StrFromTimeIntervalW(szBuff, ARRAY_SIZE(szBuff), dwMS, iDigits);
WideCharToMultiByte(CP_ACP,0,szBuff,-1,lpszStr,cchMax,0,0);
}
return iRet;
......@@ -2420,7 +2418,7 @@ LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
/* Note that if this loop completes without finding a match, i will be
* pointing at the last entry, which is a catch all for > 1000 PB
*/
while (i < sizeof(bfFormats) / sizeof(SHLWAPI_BYTEFORMATS) - 1)
while (i < ARRAY_SIZE(bfFormats) - 1)
{
if (llBytes < bfFormats[i].dLimit)
break;
......@@ -2455,7 +2453,7 @@ LPSTR WINAPI StrFormatByteSize64A(LONGLONG llBytes, LPSTR lpszDest, UINT cchMax)
{
WCHAR wszBuff[32];
StrFormatByteSizeW(llBytes, wszBuff, sizeof(wszBuff)/sizeof(WCHAR));
StrFormatByteSizeW(llBytes, wszBuff, ARRAY_SIZE(wszBuff));
if (lpszDest)
WideCharToMultiByte(CP_ACP, 0, wszBuff, -1, lpszDest, cchMax, 0, 0);
......
......@@ -136,7 +136,7 @@ static DWORD get_scheme_code(LPCWSTR scheme, DWORD scheme_len)
{
unsigned int i;
for(i=0; i < sizeof(shlwapi_schemes)/sizeof(shlwapi_schemes[0]); i++) {
for(i = 0; i < ARRAY_SIZE(shlwapi_schemes); i++) {
if(scheme_len == strlenW(shlwapi_schemes[i].scheme_name)
&& !memicmpW(scheme, shlwapi_schemes[i].scheme_name, scheme_len))
return shlwapi_schemes[i].scheme_number;
......@@ -182,8 +182,7 @@ HRESULT WINAPI ParseURLA(LPCSTR x, PARSEDURLA *y)
y->pszSuffix = ptr+1;
y->cchSuffix = strlen(y->pszSuffix);
len = MultiByteToWideChar(CP_ACP, 0, x, ptr-x,
scheme, sizeof(scheme)/sizeof(WCHAR));
len = MultiByteToWideChar(CP_ACP, 0, x, ptr-x, scheme, ARRAY_SIZE(scheme));
y->nScheme = get_scheme_code(scheme, len);
return S_OK;
......@@ -331,7 +330,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
return E_OUTOFMEMORY;
}
is_file_url = !strncmpW(wszFile, url, sizeof(wszFile)/sizeof(WCHAR));
is_file_url = !strncmpW(wszFile, url, ARRAY_SIZE(wszFile));
if ((nByteLen >= sizeof(wszHttp) &&
!memcmp(wszHttp, url, sizeof(wszHttp))) || is_file_url)
......@@ -362,7 +361,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
if(url[1] == ':') { /* Assume path */
memcpy(wk2, wszFilePrefix, sizeof(wszFilePrefix));
wk2 += sizeof(wszFilePrefix)/sizeof(WCHAR);
wk2 += ARRAY_SIZE(wszFilePrefix);
if (dwFlags & (URL_FILE_USE_PATHURL | URL_WININET_COMPATIBILITY))
{
slash = '\\';
......@@ -397,7 +396,7 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized,
if((dwFlags & URL_FILE_USE_PATHURL) && nByteLen >= sizeof(wszLocalhost)
&& is_file_url
&& !memcmp(wszLocalhost, wk1, sizeof(wszLocalhost))){
wk1 += sizeof(wszLocalhost)/sizeof(WCHAR);
wk1 += ARRAY_SIZE(wszLocalhost);
while(*wk1 == '\\' && (dwFlags & URL_FILE_USE_PATHURL))
wk1++;
}
......@@ -954,7 +953,7 @@ HRESULT WINAPI UrlEscapeA(
WCHAR *escapedW = bufW;
UNICODE_STRING urlW;
HRESULT ret;
DWORD lenW = sizeof(bufW)/sizeof(WCHAR), lenA;
DWORD lenW = ARRAY_SIZE(bufW), lenA;
if (!pszEscaped || !pcchEscaped || !*pcchEscaped)
return E_INVALIDARG;
......@@ -1162,7 +1161,7 @@ HRESULT WINAPI UrlEscapeW(
len = 0;
if((int_flags & WINE_URL_COLLAPSE_SLASHES) && src == pszUrl + parsed_url.cchProtocol + 1) {
int localhost_len = sizeof(localhost)/sizeof(WCHAR) - 1;
int localhost_len = ARRAY_SIZE(localhost) - 1;
while(cur == '/' || cur == '\\') {
slashes++;
cur = *++src;
......@@ -2442,7 +2441,7 @@ HRESULT WINAPI UrlCreateFromPathA(LPCSTR pszPath, LPSTR pszUrl, LPDWORD pcchUrl,
WCHAR *urlW = bufW;
UNICODE_STRING pathW;
HRESULT ret;
DWORD lenW = sizeof(bufW)/sizeof(WCHAR), lenA;
DWORD lenW = ARRAY_SIZE(bufW), lenA;
if(!RtlCreateUnicodeStringFromAsciiz(&pathW, pszPath))
return E_INVALIDARG;
......@@ -2545,13 +2544,13 @@ HRESULT WINAPI MLBuildResURLA(LPCSTR lpszLibName, HMODULE hMod, DWORD dwFlags,
HRESULT hRet;
if (lpszLibName)
MultiByteToWideChar(CP_ACP, 0, lpszLibName, -1, szLibName, sizeof(szLibName)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpszLibName, -1, szLibName, ARRAY_SIZE(szLibName));
if (lpszRes)
MultiByteToWideChar(CP_ACP, 0, lpszRes, -1, szRes, sizeof(szRes)/sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpszRes, -1, szRes, ARRAY_SIZE(szRes));
if (dwDestLen > sizeof(szLibName)/sizeof(WCHAR))
dwDestLen = sizeof(szLibName)/sizeof(WCHAR);
if (dwDestLen > ARRAY_SIZE(szLibName))
dwDestLen = ARRAY_SIZE(szLibName);
hRet = MLBuildResURLW(lpszLibName ? szLibName : NULL, hMod, dwFlags,
lpszRes ? szRes : NULL, lpszDest ? szDest : NULL, dwDestLen);
......@@ -2592,8 +2591,8 @@ HRESULT WINAPI MLBuildResURLW(LPCWSTR lpszLibName, HMODULE hMod, DWORD dwFlags,
WCHAR szBuff[MAX_PATH];
DWORD len;
len = GetModuleFileNameW(hMod, szBuff, sizeof(szBuff)/sizeof(WCHAR));
if (len && len < sizeof(szBuff)/sizeof(WCHAR))
len = GetModuleFileNameW(hMod, szBuff, ARRAY_SIZE(szBuff));
if (len && len < ARRAY_SIZE(szBuff))
{
DWORD dwPathLen = strlenW(szBuff) + 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment