Commit a1e0a029 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

oleaut32: Use the ARRAY_SIZE() macro.

parent 56b3304a
......@@ -122,9 +122,7 @@ static inline bstr_t *bstr_from_str(BSTR str)
static inline bstr_cache_entry_t *get_cache_entry_from_idx(unsigned cache_idx)
{
return bstr_cache_enabled && cache_idx < sizeof(bstr_cache)/sizeof(*bstr_cache)
? bstr_cache + cache_idx
: NULL;
return bstr_cache_enabled && cache_idx < ARRAY_SIZE(bstr_cache) ? bstr_cache + cache_idx : NULL;
}
static inline bstr_cache_entry_t *get_cache_entry(size_t size)
......@@ -304,7 +302,7 @@ void WINAPI SysFreeString(BSTR str)
}
}
if(cache_entry->cnt < sizeof(cache_entry->buf)/sizeof(*cache_entry->buf)) {
if(cache_entry->cnt < ARRAY_SIZE(cache_entry->buf)) {
cache_entry->buf[(cache_entry->head+cache_entry->cnt) % BUCKET_BUFFER_SIZE] = bstr;
cache_entry->cnt++;
......
......@@ -591,7 +591,7 @@ static void realize_font(OLEFontImpl *This)
if(This->gdiFont)
{
old_font = SelectObject(hdc, This->gdiFont);
GetTextFaceW(hdc, sizeof(text_face) / sizeof(text_face[0]), text_face);
GetTextFaceW(hdc, ARRAY_SIZE(text_face), text_face);
SelectObject(hdc, old_font);
dec_int_ref(This->gdiFont);
This->gdiFont = 0;
......@@ -645,7 +645,7 @@ static void realize_font(OLEFontImpl *This)
/* Fixup the name and charset properties so that they match the
selected font */
old_font = SelectObject(get_dc(), This->gdiFont);
GetTextFaceW(hdc, sizeof(text_face) / sizeof(text_face[0]), text_face);
GetTextFaceW(hdc, ARRAY_SIZE(text_face), text_face);
if(lstrcmpiW(text_face, This->description.lpstrName))
{
HeapFree(GetProcessHeap(), 0, This->description.lpstrName);
......
......@@ -2395,7 +2395,7 @@ HRESULT WINAPI OleLoadPicturePath( LPOLESTR szURLorPath, LPUNKNOWN punkCaller,
if (strncmpW(szURLorPath, file, 5) == 0) {
DWORD size;
hRes = CoInternetParseUrl(szURLorPath, PARSE_PATH_FROM_URL, 0, path_buf,
sizeof(path_buf)/sizeof(WCHAR), &size, 0);
ARRAY_SIZE(path_buf), &size, 0);
if (FAILED(hRes))
return hRes;
......
......@@ -387,8 +387,8 @@ _get_typeinfo_for_iid(REFIID riid, ITypeInfo **typeinfo)
*typeinfo = NULL;
moduleW[0] = 0;
if (!actctx_get_typelib_module(riid, moduleW, sizeof(moduleW)/sizeof(moduleW[0]))) {
hres = reg_get_typelib_module(riid, moduleW, sizeof(moduleW)/sizeof(moduleW[0]));
if (!actctx_get_typelib_module(riid, moduleW, ARRAY_SIZE(moduleW))) {
hres = reg_get_typelib_module(riid, moduleW, ARRAY_SIZE(moduleW));
if (FAILED(hres))
return hres;
}
......@@ -1470,9 +1470,9 @@ static DWORD WINAPI xCall(int method, void **args)
/* Need them for hack below */
memset(names,0,sizeof(names));
if (ITypeInfo_GetNames(tinfo,fdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames))
if (ITypeInfo_GetNames(tinfo,fdesc->memid,names,ARRAY_SIZE(names),&nrofnames))
nrofnames = 0;
if (nrofnames > sizeof(names)/sizeof(names[0]))
if (nrofnames > ARRAY_SIZE(names))
ERR("Need more names!\n");
xargs = (DWORD *)(args + 1);
......@@ -2125,8 +2125,8 @@ TMStubImpl_Invoke(
/* Need them for hack below */
memset(names,0,sizeof(names));
ITypeInfo_GetNames(tinfo,fdesc->memid,names,sizeof(names)/sizeof(names[0]),&nrofnames);
if (nrofnames > sizeof(names)/sizeof(names[0])) {
ITypeInfo_GetNames(tinfo,fdesc->memid,names,ARRAY_SIZE(names),&nrofnames);
if (nrofnames > ARRAY_SIZE(names)) {
ERR("Need more names!\n");
}
......
......@@ -328,7 +328,7 @@ static HRESULT query_typelib_path( REFGUID guid, WORD wMaj, WORD wMin,
return TYPE_E_LIBNOTREGISTERED;
nameW = (WCHAR*)((BYTE*)data.lpSectionBase + tlib->name_offset);
len = SearchPathW( NULL, nameW, NULL, sizeof(Path)/sizeof(WCHAR), Path, NULL );
len = SearchPathW( NULL, nameW, NULL, ARRAY_SIZE( Path ), Path, NULL );
if (!len) return TYPE_E_LIBNOTREGISTERED;
TRACE_(typelib)("got path from context %s\n", debugstr_w(Path));
......@@ -969,11 +969,11 @@ enddeleteloop:
/* check if there is anything besides the FLAGS/HELPDIR keys.
If there is, we don't delete them */
tmpLength = sizeof(subKeyName)/sizeof(WCHAR);
tmpLength = ARRAY_SIZE(subKeyName);
deleteOtherStuff = TRUE;
i = 0;
while(RegEnumKeyExW(key, i++, subKeyName, &tmpLength, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
tmpLength = sizeof(subKeyName)/sizeof(WCHAR);
tmpLength = ARRAY_SIZE(subKeyName);
/* if its not FLAGS or HELPDIR, then we must keep the rest of the key */
if (!strcmpW(subKeyName, FLAGSW)) continue;
......@@ -7751,7 +7751,7 @@ static BOOL CALLBACK search_res_tlb(HMODULE hModule, LPCWSTR lpszType, LPWSTR lp
if (!(len = GetModuleFileNameW(hModule, szPath, MAX_PATH)))
return TRUE;
if (snprintfW(szPath + len, sizeof(szPath)/sizeof(WCHAR) - len, formatW, LOWORD(lpszName)) < 0)
if (snprintfW(szPath + len, ARRAY_SIZE(szPath) - len, formatW, LOWORD(lpszName)) < 0)
return TRUE;
ret = LoadTypeLibEx(szPath, REGKIND_NONE, &pTLib);
......
......@@ -449,8 +449,7 @@ static inline const BYTE *VARIANT_GetNamedFormat(LPCWSTR lpszFormat)
LPCNAMED_FORMAT fmt;
key.name = lpszFormat;
fmt = bsearch(&key, VARIANT_NamedFormats,
sizeof(VARIANT_NamedFormats)/sizeof(NAMED_FORMAT),
fmt = bsearch(&key, VARIANT_NamedFormats, ARRAY_SIZE(VARIANT_NamedFormats),
sizeof(NAMED_FORMAT), FormatCompareFn);
return fmt ? fmt->format : NULL;
}
......@@ -764,7 +763,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
TRACE("time sep\n");
}
else if ((*pFormat == 'a' || *pFormat == 'A') &&
!strncmpiW(pFormat, szAMPM, sizeof(szAMPM)/sizeof(WCHAR)))
!strncmpiW(pFormat, szAMPM, ARRAY_SIZE(szAMPM)))
{
/* Date formats: System AM/PM designation
* Other formats: Literal
......@@ -772,8 +771,8 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
*/
header->type = FMT_TYPE_DATE;
NEED_SPACE(sizeof(BYTE));
pFormat += sizeof(szAMPM)/sizeof(WCHAR);
if (!strncmpW(pFormat, szampm, sizeof(szampm)/sizeof(WCHAR)))
pFormat += ARRAY_SIZE(szAMPM);
if (!strncmpW(pFormat, szampm, ARRAY_SIZE(szampm)))
*pOut++ = FMT_DATE_AMPM_SYS2;
else
*pOut++ = FMT_DATE_AMPM_SYS1;
......@@ -811,8 +810,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
*pLastHours = *pLastHours + 2;
TRACE("A/P\n");
}
else if (*pFormat == 'a' &&
!strncmpW(pFormat, szamSlashpm, sizeof(szamSlashpm)/sizeof(WCHAR)))
else if (*pFormat == 'a' && !strncmpW(pFormat, szamSlashpm, ARRAY_SIZE(szamSlashpm)))
{
/* Date formats: lowercase AM or PM designation
* Other formats: Literal
......@@ -820,14 +818,13 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
*/
header->type = FMT_TYPE_DATE;
NEED_SPACE(sizeof(BYTE));
pFormat += sizeof(szamSlashpm)/sizeof(WCHAR);
pFormat += ARRAY_SIZE(szamSlashpm);
*pOut++ = FMT_DATE_AMPM_LOWER;
if (pLastHours)
*pLastHours = *pLastHours + 2;
TRACE("AM/PM\n");
}
else if (*pFormat == 'A' &&
!strncmpW(pFormat, szAMSlashPM, sizeof(szAMSlashPM)/sizeof(WCHAR)))
else if (*pFormat == 'A' && !strncmpW(pFormat, szAMSlashPM, ARRAY_SIZE(szAMSlashPM)))
{
/* Date formats: Uppercase AM or PM designation
* Other formats: Literal
......@@ -835,7 +832,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
*/
header->type = FMT_TYPE_DATE;
NEED_SPACE(sizeof(BYTE));
pFormat += sizeof(szAMSlashPM)/sizeof(WCHAR);
pFormat += ARRAY_SIZE(szAMSlashPM);
*pOut++ = FMT_DATE_AMPM_UPPER;
TRACE("AM/PM\n");
}
......@@ -847,7 +844,7 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
*/
header->type = FMT_TYPE_DATE;
NEED_SPACE(sizeof(BYTE));
pFormat += sizeof(szAMSlashPM)/sizeof(WCHAR);
pFormat += ARRAY_SIZE(szAMSlashPM);
*pOut++ = FMT_DATE_GENERAL;
TRACE("gen date\n");
}
......@@ -989,14 +986,14 @@ HRESULT WINAPI VarTokenizeFormatString(LPOLESTR lpszFormat, LPBYTE rgbTok,
fmt_state &= ~FMT_STATE_OPEN_COPY;
}
else if ((*pFormat == 't' || *pFormat == 'T') &&
!strncmpiW(pFormat, szTTTTT, sizeof(szTTTTT)/sizeof(WCHAR)))
!strncmpiW(pFormat, szTTTTT, ARRAY_SIZE(szTTTTT)))
{
/* Date formats: System time specifier
* Other formats: Literal
* Types the format if found
*/
header->type = FMT_TYPE_DATE;
pFormat += sizeof(szTTTTT)/sizeof(WCHAR);
pFormat += ARRAY_SIZE(szTTTTT);
NEED_SPACE(sizeof(BYTE));
*pOut++ = FMT_DATE_TIME_SYS;
fmt_state &= ~FMT_STATE_OPEN_COPY;
......@@ -1316,8 +1313,7 @@ static HRESULT VARIANT_FormatNumber(LPVARIANT pVarIn, LPOLESTR lpszFormat,
if (numHeader->flags & FMT_FLAG_THOUSANDS)
{
if (!GetLocaleInfoW(lcid, LOCALE_STHOUSAND, thousandSeparator,
sizeof(thousandSeparator)/sizeof(WCHAR)))
if (!GetLocaleInfoW(lcid, LOCALE_STHOUSAND, thousandSeparator, ARRAY_SIZE(thousandSeparator)))
{
thousandSeparator[0] = ',';
thousandSeparator[1] = 0;
......@@ -1555,8 +1551,7 @@ VARIANT_FormatNumber_Bool:
}
if (localeValue)
{
if (GetLocaleInfoW(lcid, localeValue, pBuff,
sizeof(buff)/sizeof(WCHAR)-(pBuff-buff)))
if (GetLocaleInfoW(lcid, localeValue, pBuff, ARRAY_SIZE(buff)-(pBuff-buff)))
{
TRACE("added %s\n", debugstr_w(pBuff));
while (*pBuff)
......@@ -1875,8 +1870,7 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
if (localeValue)
{
*pBuff = '\0';
if (GetLocaleInfoW(lcid, localeValue, pBuff,
sizeof(buff)/sizeof(WCHAR)-(pBuff-buff)))
if (GetLocaleInfoW(lcid, localeValue, pBuff, ARRAY_SIZE(buff)-(pBuff-buff)))
{
TRACE("added %s\n", debugstr_w(pBuff));
while (*pBuff)
......@@ -1892,9 +1886,8 @@ static HRESULT VARIANT_FormatDate(LPVARIANT pVarIn, LPOLESTR lpszFormat,
{
WCHAR fmt_buff[80];
if (!GetLocaleInfoW(lcid, dwFmt, fmt_buff, sizeof(fmt_buff)/sizeof(WCHAR)) ||
!get_date_format(lcid, 0, &udate.st, fmt_buff, pBuff,
sizeof(buff)/sizeof(WCHAR)-(pBuff-buff)))
if (!GetLocaleInfoW(lcid, dwFmt, fmt_buff, ARRAY_SIZE(fmt_buff)) ||
!get_date_format(lcid, 0, &udate.st, fmt_buff, pBuff, ARRAY_SIZE(buff)-(pBuff-buff)))
{
hRes = E_INVALIDARG;
goto VARIANT_FormatDate_Exit;
......@@ -2293,8 +2286,7 @@ HRESULT WINAPI VarFormatNumber(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT
{
WCHAR grouping[16];
grouping[2] = '\0';
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, grouping,
sizeof(grouping)/sizeof(WCHAR));
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, grouping, ARRAY_SIZE(grouping));
numfmt.Grouping = grouping[2] == '2' ? 32 : grouping[0] - '0';
}
else if (nGrouping == -1)
......@@ -2310,14 +2302,11 @@ HRESULT WINAPI VarFormatNumber(LPVARIANT pVarIn, INT nDigits, INT nLeading, INT
numfmt.NegativeOrder = 1; /* 1 = "-xxx" */
numfmt.lpDecimalSep = decimal;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal,
sizeof(decimal)/sizeof(WCHAR));
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal, ARRAY_SIZE(decimal));
numfmt.lpThousandSep = thousands;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thousands,
sizeof(thousands)/sizeof(WCHAR));
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thousands, ARRAY_SIZE(thousands));
if (GetNumberFormatW(LOCALE_USER_DEFAULT, 0, V_BSTR(&vStr), &numfmt,
buff, sizeof(buff)/sizeof(WCHAR)))
if (GetNumberFormatW(LOCALE_USER_DEFAULT, 0, V_BSTR(&vStr), &numfmt, buff, ARRAY_SIZE(buff)))
{
*pbstrOut = SysAllocString(buff);
if (!*pbstrOut)
......@@ -2473,8 +2462,7 @@ HRESULT WINAPI VarFormatCurrency(LPVARIANT pVarIn, INT nDigits, INT nLeading,
{
WCHAR grouping[16];
grouping[2] = '\0';
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, grouping,
sizeof(grouping)/sizeof(WCHAR));
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, grouping, ARRAY_SIZE(grouping));
numfmt.Grouping = grouping[2] == '2' ? 32 : grouping[0] - '0';
}
else if (nGrouping == -1)
......@@ -2492,18 +2480,14 @@ HRESULT WINAPI VarFormatCurrency(LPVARIANT pVarIn, INT nDigits, INT nLeading,
GETLOCALENUMBER(LOCALE_ICURRENCY, PositiveOrder);
numfmt.lpDecimalSep = decimal;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal,
sizeof(decimal)/sizeof(WCHAR));
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal, ARRAY_SIZE(decimal));
numfmt.lpThousandSep = thousands;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, thousands,
sizeof(thousands)/sizeof(WCHAR));
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, thousands, ARRAY_SIZE(thousands));
numfmt.lpCurrencySymbol = currency;
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, currency,
sizeof(currency)/sizeof(WCHAR));
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, currency, ARRAY_SIZE(currency));
/* use NLS as per VarFormatNumber() */
if (GetCurrencyFormatW(LOCALE_USER_DEFAULT, 0, V_BSTR(&vStr), &numfmt,
buff, sizeof(buff)/sizeof(WCHAR)))
if (GetCurrencyFormatW(LOCALE_USER_DEFAULT, 0, V_BSTR(&vStr), &numfmt, buff, ARRAY_SIZE(buff)))
{
*pbstrOut = SysAllocString(buff);
if (!*pbstrOut)
......
......@@ -1549,7 +1549,7 @@ static void VARIANT_GetLocalisedNumberChars(VARIANT_NUMBER_CHARS *lpChars, LCID
/* Local currency symbols are often 2 characters */
lpChars->cCurrencyLocal2 = '\0';
switch(GetLocaleInfoW(lcid, lctype|LOCALE_SCURRENCY, buff, sizeof(buff)/sizeof(WCHAR)))
switch(GetLocaleInfoW(lcid, lctype|LOCALE_SCURRENCY, buff, ARRAY_SIZE(buff)))
{
case 3: lpChars->cCurrencyLocal2 = buff[1]; /* Fall through */
case 2: lpChars->cCurrencyLocal = buff[0];
......@@ -1610,7 +1610,7 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
VARIANT_NUMBER_CHARS chars;
BYTE rgbTmp[1024];
DWORD dwState = B_EXPONENT_START|B_INEXACT_ZEROS;
int iMaxDigits = sizeof(rgbTmp) / sizeof(BYTE);
int iMaxDigits = ARRAY_SIZE(rgbTmp);
int cchUsed = 0;
TRACE("(%s,%d,0x%08x,%p,%p)\n", debugstr_w(lpszStr), lcid, dwFlags, pNumprs, rgbDig);
......
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