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

ole32: Use the ARRAY_SIZE() macro.

parent 489c01ee
......@@ -536,14 +536,14 @@ static HRESULT WINAPI ClassMoniker_GetDisplayName(IMoniker* iface,
*ppszDisplayName = CoTaskMemAlloc(sizeof(wszClsidPrefix) + (CHARS_IN_GUID-2) * sizeof(WCHAR));
StringFromGUID2(&This->clsid, *ppszDisplayName+sizeof(wszClsidPrefix)/sizeof(WCHAR)-2, CHARS_IN_GUID);
StringFromGUID2(&This->clsid, *ppszDisplayName+ARRAY_SIZE(wszClsidPrefix)-2, CHARS_IN_GUID);
/* note: this overwrites the opening curly bracket of the CLSID string generated above */
memcpy(*ppszDisplayName, wszClsidPrefix, sizeof(wszClsidPrefix)-sizeof(WCHAR));
/* note: this overwrites the closing curly bracket of the CLSID string generated above */
(*ppszDisplayName)[sizeof(wszClsidPrefix)/sizeof(WCHAR)-2+CHARS_IN_GUID-2] = ':';
(*ppszDisplayName)[sizeof(wszClsidPrefix)/sizeof(WCHAR)-2+CHARS_IN_GUID-1] = '\0';
(*ppszDisplayName)[ARRAY_SIZE(wszClsidPrefix)-2+CHARS_IN_GUID-2] = ':';
(*ppszDisplayName)[ARRAY_SIZE(wszClsidPrefix)-2+CHARS_IN_GUID-1] = '\0';
TRACE("string is %s\n", debugstr_w(*ppszDisplayName));
return S_OK;
......
......@@ -1197,7 +1197,7 @@ static HRESULT get_priv_data(ole_priv_data **data)
for(cf = 0; (cf = EnumClipboardFormats(cf)) != 0; count++)
{
WCHAR buf[256];
if (GetClipboardFormatNameW(cf, buf, sizeof(buf) / sizeof(WCHAR)))
if (GetClipboardFormatNameW(cf, buf, ARRAY_SIZE(buf)))
TRACE("cf %04x %s\n", cf, debugstr_w(buf));
else
TRACE("cf %04x\n", cf);
......
......@@ -2667,7 +2667,7 @@ static HRESULT WINAPI DataCache_UpdateCache( IOleCache2 *iface, IDataObject *dat
}
else
{
for (i = 0; i < sizeof(view_list) / sizeof(view_list[0]); i++)
for (i = 0; i < ARRAY_SIZE(view_list); i++)
{
fmt.cfFormat = view_list[i];
fmt.tymed = tymed_from_cf( fmt.cfFormat );
......
......@@ -1152,7 +1152,7 @@ HRESULT WINAPI MkParseDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
*pchEaten = 0;
*ppmk = NULL;
if (!strncmpiW(szDisplayName, wszClsidColon, sizeof(wszClsidColon)/sizeof(wszClsidColon[0])))
if (!strncmpiW(szDisplayName, wszClsidColon, ARRAY_SIZE(wszClsidColon)))
{
hr = ClassMoniker_CreateFromDisplayName(pbc, szDisplayName, &chEaten, &moniker);
if (FAILED(hr) && (hr != MK_E_SYNTAX))
......
......@@ -967,7 +967,7 @@ static HRESULT WINAPI EnumOLEVERB_Next(
LPWSTR pwszOLEVERB;
LPWSTR pwszMenuFlags;
LPWSTR pwszAttribs;
LONG res = RegEnumKeyW(This->hkeyVerb, This->index, wszSubKey, sizeof(wszSubKey)/sizeof(wszSubKey[0]));
LONG res = RegEnumKeyW(This->hkeyVerb, This->index, wszSubKey, ARRAY_SIZE(wszSubKey));
if (res == ERROR_NO_MORE_ITEMS)
{
hr = S_FALSE;
......
......@@ -135,7 +135,7 @@ static HRESULT get_storage(IDataObject *data, IStorage *stg, UINT *src_cf, BOOL
if (other_fmts)
{
for (i = 0; i < sizeof(fmt_id)/sizeof(fmt_id[0]); i++)
for (i = 0; i < ARRAY_SIZE(fmt_id); i++)
{
init_fmtetc(&fmt, fmt_id[i], TYMED_ISTORAGE);
hr = IDataObject_QueryGetData(data, &fmt);
......
......@@ -1658,7 +1658,7 @@ static HRESULT create_server(REFCLSID rclsid, HANDLE *process)
static const WCHAR embedding[] = { ' ', '-','E','m','b','e','d','d','i','n','g',0 };
HKEY key;
HRESULT hres;
WCHAR command[MAX_PATH+sizeof(embedding)/sizeof(WCHAR)];
WCHAR command[MAX_PATH+ARRAY_SIZE(embedding)];
DWORD size = (MAX_PATH+1) * sizeof(WCHAR);
STARTUPINFOW sinfo;
PROCESS_INFORMATION pinfo;
......@@ -1799,7 +1799,7 @@ static void get_localserver_pipe_name(WCHAR *pipefn, REFCLSID rclsid)
{
static const WCHAR wszPipeRef[] = {'\\','\\','.','\\','p','i','p','e','\\',0};
strcpyW(pipefn, wszPipeRef);
StringFromGUID2(rclsid, pipefn + sizeof(wszPipeRef)/sizeof(wszPipeRef[0]) - 1, CHARS_IN_GUID);
StringFromGUID2(rclsid, pipefn + ARRAY_SIZE(wszPipeRef) - 1, CHARS_IN_GUID);
}
/* FIXME: should call to rpcss instead */
......
......@@ -5057,7 +5057,7 @@ static HRESULT StorageImpl_LockOne(StorageImpl *This, ULONG start, ULONG end)
if (SUCCEEDED(hr))
{
for (j=0; j<sizeof(This->locked_bytes)/sizeof(This->locked_bytes[0]); j++)
for (j = 0; j < ARRAY_SIZE(This->locked_bytes); j++)
{
if (This->locked_bytes[j] == 0)
{
......@@ -5200,10 +5200,10 @@ static void StorageImpl_Destroy(StorageBaseImpl* iface)
BlockChainStream_Destroy(This->rootBlockChain);
BlockChainStream_Destroy(This->smallBlockDepotChain);
for (i=0; i<BLOCKCHAIN_CACHE_SIZE; i++)
for (i = 0; i < BLOCKCHAIN_CACHE_SIZE; i++)
BlockChainStream_Destroy(This->blockChainCache[i]);
for (i=0; i<sizeof(This->locked_bytes)/sizeof(This->locked_bytes[0]); i++)
for (i = 0; i < ARRAY_SIZE(This->locked_bytes); i++)
{
ULARGE_INTEGER offset, cb;
cb.QuadPart = 1;
......@@ -9369,8 +9369,7 @@ HRESULT WINAPI WriteFmtUserTypeStg(
/* get the clipboard format name */
if( cf )
{
n = GetClipboardFormatNameW( cf, szwClipName,
sizeof(szwClipName)/sizeof(szwClipName[0]) );
n = GetClipboardFormatNameW(cf, szwClipName, ARRAY_SIZE(szwClipName));
szwClipName[n]=0;
}
......
......@@ -116,7 +116,7 @@ ULONG __RPC_USER CLIPFORMAT_UserSize(ULONG *pFlags, ULONG size, CLIPFORMAT *pCF)
/* urg! this function is badly designed because it won't tell us how
* much space is needed without doing a dummy run of storing the
* name into a buffer */
ret = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
ret = GetClipboardFormatNameW(*pCF, format, ARRAY_SIZE(format)-1);
if (!ret)
RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
size += (ret + 1) * sizeof(WCHAR);
......@@ -161,7 +161,7 @@ unsigned char * __RPC_USER CLIPFORMAT_UserMarshal(ULONG *pFlags, unsigned char *
*(DWORD *)pBuffer = *pCF;
pBuffer += 4;
len = GetClipboardFormatNameW(*pCF, format, sizeof(format)/sizeof(format[0])-1);
len = GetClipboardFormatNameW(*pCF, format, ARRAY_SIZE(format)-1);
if (!len)
RaiseException(DV_E_CLIPFORMAT, 0, 0, NULL);
len += 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