[PATCH] mshtml: Use the ARRAY_SIZE() macro

Michael Stefaniuc mstefani at winehq.org
Thu Aug 23 16:31:15 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/mshtml/dispex.c       |  6 +++---
 dlls/mshtml/htmlbody.c     |  2 +-
 dlls/mshtml/htmldoc.c      |  2 +-
 dlls/mshtml/htmlelem.c     |  2 +-
 dlls/mshtml/htmlevent.c    |  8 ++++----
 dlls/mshtml/htmlimg.c      |  2 +-
 dlls/mshtml/htmllocation.c |  2 +-
 dlls/mshtml/htmlstyle.c    | 18 +++++++++---------
 dlls/mshtml/htmlwindow.c   |  9 +++------
 dlls/mshtml/main.c         |  8 ++++----
 dlls/mshtml/mutation.c     |  6 +++---
 dlls/mshtml/navigate.c     |  4 ++--
 dlls/mshtml/nsembed.c      |  8 ++++----
 dlls/mshtml/nsio.c         | 21 ++++++++++-----------
 dlls/mshtml/olecmd.c       | 11 ++++-------
 dlls/mshtml/pluginhost.c   |  4 ++--
 dlls/mshtml/protocol.c     | 26 +++++++++++++-------------
 dlls/mshtml/script.c       |  4 ++--
 dlls/mshtml/view.c         |  6 ++----
 19 files changed, 70 insertions(+), 79 deletions(-)

diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c
index 360d915523..02ba5d41d5 100644
--- a/dlls/mshtml/dispex.c
+++ b/dlls/mshtml/dispex.c
@@ -182,7 +182,7 @@ void release_typelib(void)
     if(!typelib)
         return;
 
-    for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
+    for(i=0; i < ARRAY_SIZE(typeinfos); i++)
         if(typeinfos[i])
             ITypeInfo_Release(typeinfos[i]);
 
@@ -774,12 +774,12 @@ static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
             return E_ACCESSDENIED;
 
         name_len = SysStringLen(This->info->name);
-        ptr = str = SysAllocStringLen(NULL, name_len + (sizeof(func_prefixW)+sizeof(func_suffixW))/sizeof(WCHAR));
+        ptr = str = SysAllocStringLen(NULL, name_len + ARRAY_SIZE(func_prefixW) + ARRAY_SIZE(func_suffixW));
         if(!str)
             return E_OUTOFMEMORY;
 
         memcpy(ptr, func_prefixW, sizeof(func_prefixW));
-        ptr += sizeof(func_prefixW)/sizeof(WCHAR);
+        ptr += ARRAY_SIZE(func_prefixW);
 
         memcpy(ptr, This->info->name, name_len*sizeof(WCHAR));
         ptr += name_len;
diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c
index 4913c45995..2cfd46dc50 100644
--- a/dlls/mshtml/htmlbody.c
+++ b/dlls/mshtml/htmlbody.c
@@ -140,7 +140,7 @@ HRESULT nscolor_to_str(LPCWSTR color, BSTR *ret)
     }
 
     if(*color != '#') {
-        for(i=0; i < sizeof(keyword_table)/sizeof(keyword_table[0]); i++) {
+        for(i=0; i < ARRAY_SIZE(keyword_table); i++) {
             if(!strcmpiW(color, keyword_table[i].keyword))
                 rgb = keyword_table[i].rgb;
         }
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index eab7b1feb0..17c9e6307f 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1191,7 +1191,7 @@ static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
 {
     int i;
 
-    for(i = 0; i < sizeof(command_names)/sizeof(*command_names); i++) {
+    for(i = 0; i < ARRAY_SIZE(command_names); i++) {
         if(!strcmpiW(command_names[i].name, str)) {
             *cmdid = command_names[i].id;
             return TRUE;
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 40e558c62a..4da01560e2 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -103,7 +103,7 @@ static const tag_desc_t tag_descs[] = {
 
 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
 {
-    DWORD min=0, max=sizeof(tag_descs)/sizeof(*tag_descs)-1, i;
+    DWORD min=0, max=ARRAY_SIZE(tag_descs)-1, i;
     int r;
 
     while(min <= max) {
diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c
index d5d59905cd..1a93ae2fe8 100644
--- a/dlls/mshtml/htmlevent.c
+++ b/dlls/mshtml/htmlevent.c
@@ -230,7 +230,7 @@ static eventid_t str_to_eid(const WCHAR *str)
 {
     int i;
 
-    for(i=0; i < sizeof(event_info)/sizeof(event_info[0]); i++) {
+    for(i=0; i < ARRAY_SIZE(event_info); i++) {
         if(!strcmpW(event_info[i].name, str))
             return i;
     }
@@ -245,7 +245,7 @@ static eventid_t attr_to_eid(const WCHAR *str)
     if((str[0] != 'o' && str[0] != 'O') || (str[1] != 'n' && str[1] != 'N'))
         return EVENTID_LAST;
 
-    for(i=0; i < sizeof(event_info)/sizeof(event_info[0]); i++) {
+    for(i=0; i < ARRAY_SIZE(event_info); i++) {
         if(!strcmpW(event_info[i].name, str+2) && event_info[i].dispid)
             return i;
     }
@@ -2345,7 +2345,7 @@ static void call_event_handlers(EventTarget *event_target, DOMEvent *event, disp
     }
 
     listeners_cnt = 0;
-    listeners_size = sizeof(listeners_buf)/sizeof(*listeners_buf);
+    listeners_size = ARRAY_SIZE(listeners_buf);
 
     if(container) {
         LIST_FOR_EACH_ENTRY(listener, &container->listeners, event_listener_t, entry) {
@@ -2529,7 +2529,7 @@ static HRESULT dispatch_event_object(EventTarget *event_target, DOMEvent *event,
     IEventTarget_AddRef(&event_target->IEventTarget_iface);
 
     chain_cnt = 0;
-    chain_buf_size = sizeof(target_chain_buf)/sizeof(*target_chain_buf);
+    chain_buf_size = ARRAY_SIZE(target_chain_buf);
 
     do {
         if(chain_cnt == chain_buf_size) {
diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c
index 90681e4783..13dd3edbb5 100644
--- a/dlls/mshtml/htmlimg.c
+++ b/dlls/mshtml/htmlimg.c
@@ -312,7 +312,7 @@ static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
     if(NS_SUCCEEDED(nsres)) {
         nsAString_GetData(&src_str, &src);
 
-        if(!strncmpiW(src, blockedW, sizeof(blockedW)/sizeof(WCHAR)-1)) {
+        if(!strncmpiW(src, blockedW, ARRAY_SIZE(blockedW)-1)) {
             TRACE("returning BLOCKED::\n");
             *p = SysAllocString(blockedW);
             if(!*p)
diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c
index 59b20f614d..769951643c 100644
--- a/dlls/mshtml/htmllocation.c
+++ b/dlls/mshtml/htmllocation.c
@@ -355,7 +355,7 @@ static HRESULT WINAPI HTMLLocation_get_host(IHTMLLocation *iface, BSTR *p)
         WCHAR portW[6];
         WCHAR *buf;
 
-        port_len = snprintfW(portW, sizeof(portW)/sizeof(portW[0]), format, url.nPort);
+        port_len = snprintfW(portW, ARRAY_SIZE(portW), format, url.nPort);
         len = url.dwHostNameLength + 1 /* ':' */ + port_len;
         buf = *p = SysAllocStringLen(NULL, len);
         memcpy(buf, url.lpszHostName, url.dwHostNameLength * sizeof(WCHAR));
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index b99ea08318..bab8923c90 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -303,7 +303,7 @@ static const style_tbl_entry_t style_tbl[] = {
     {attrZIndex,               DISPID_IHTMLSTYLE_ZINDEX}
 };
 
-C_ASSERT(sizeof(style_tbl)/sizeof(*style_tbl) == STYLEID_MAX_VALUE);
+C_ASSERT(ARRAY_SIZE(style_tbl) == STYLEID_MAX_VALUE);
 
 static const WCHAR valLineThrough[] =
     {'l','i','n','e','-','t','h','r','o','u','g','h',0};
@@ -323,7 +323,7 @@ static const WCHAR emptyW[] = {0};
 
 static const style_tbl_entry_t *lookup_style_tbl(const WCHAR *name)
 {
-    int c, i, min = 0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1;
+    int c, i, min = 0, max = ARRAY_SIZE(style_tbl)-1;
 
     while(min <= max) {
         i = (min+max)/2;
@@ -388,7 +388,7 @@ static LPWSTR fix_url_value(LPCWSTR val)
 
     static const WCHAR urlW[] = {'u','r','l','('};
 
-    if(strncmpW(val, urlW, sizeof(urlW)/sizeof(WCHAR)) || !strchrW(val, '\\'))
+    if(strncmpW(val, urlW, ARRAY_SIZE(urlW)) || !strchrW(val, '\\'))
         return NULL;
 
     ret = heap_strdupW(val);
@@ -1250,7 +1250,7 @@ static HRESULT WINAPI HTMLStyle_put_backgroundPositionY(IHTMLStyle *iface, VARIA
 
             TRACE("no space in %s\n", debugstr_w(pos));
             pos = zero_pxW;
-            space = pos + sizeof(zero_pxW)/sizeof(WCHAR)-1;
+            space = pos + ARRAY_SIZE(zero_pxW)-1;
         }
 
         posx_len = space-pos;
@@ -2718,7 +2718,7 @@ static void update_filter(HTMLStyle *This)
             continue;
         }
 
-        if(ptr2 + sizeof(alphaW)/sizeof(WCHAR) == ptr && !memcmp(ptr2, alphaW, sizeof(alphaW))) {
+        if(ptr2 + ARRAY_SIZE(alphaW) == ptr && !memcmp(ptr2, alphaW, sizeof(alphaW))) {
             static const WCHAR formatW[] = {'%','f',0};
             static const WCHAR opacityW[] = {'o','p','a','c','i','t','y','='};
 
@@ -2735,11 +2735,11 @@ static void update_filter(HTMLStyle *This)
                     break;
                 }
 
-                if(ptr-ptr2 > sizeof(opacityW)/sizeof(WCHAR) && !memcmp(ptr2, opacityW, sizeof(opacityW))) {
+                if(ptr-ptr2 > ARRAY_SIZE(opacityW) && !memcmp(ptr2, opacityW, sizeof(opacityW))) {
                     float fval = 0.0f, e = 0.1f;
                     WCHAR buf[32];
 
-                    ptr2 += sizeof(opacityW)/sizeof(WCHAR);
+                    ptr2 += ARRAY_SIZE(opacityW);
 
                     while(isdigitW(*ptr2))
                         fval = fval*10.0f + (float)(*ptr2++ - '0');
@@ -2915,12 +2915,12 @@ static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttri
             return S_OK;
         }
 
-        for(i=0; i < sizeof(style_tbl)/sizeof(*style_tbl); i++) {
+        for(i=0; i < ARRAY_SIZE(style_tbl); i++) {
             if(dispid == style_tbl[i].dispid)
                 break;
         }
 
-        if(i == sizeof(style_tbl)/sizeof(*style_tbl))
+        if(i == ARRAY_SIZE(style_tbl))
             return remove_attribute(&This->dispex, dispid, pfSuccess);
         style_entry = style_tbl+i;
     }
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index 581de990ee..44f633798a 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -626,8 +626,7 @@ static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
 
     TRACE("(%p)->(%s)\n", This, debugstr_w(message));
 
-    if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, title,
-                    sizeof(title)/sizeof(WCHAR))) {
+    if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, title, ARRAY_SIZE(title))) {
         WARN("Could not load message box title: %d\n", GetLastError());
         return S_OK;
     }
@@ -657,8 +656,7 @@ static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
 
     if(!confirmed) return E_INVALIDARG;
 
-    if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
-                sizeof(wszTitle)/sizeof(WCHAR))) {
+    if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle, ARRAY_SIZE(wszTitle))) {
         WARN("Could not load message box title: %d\n", GetLastError());
         *confirmed = VARIANT_TRUE;
         return S_OK;
@@ -689,8 +687,7 @@ static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
             prompt_arg *arg = (prompt_arg*)lparam;
             WCHAR wszTitle[100];
 
-            if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
-                        sizeof(wszTitle)/sizeof(WCHAR))) {
+            if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle, ARRAY_SIZE(wszTitle))) {
                 WARN("Could not load message box title: %d\n", GetLastError());
                 EndDialog(hwnd, wparam);
                 return FALSE;
diff --git a/dlls/mshtml/main.c b/dlls/mshtml/main.c
index 9b2f1993ae..6ce8198aee 100644
--- a/dlls/mshtml/main.c
+++ b/dlls/mshtml/main.c
@@ -126,7 +126,7 @@ static void thread_detach(void)
 static void free_strings(void)
 {
     unsigned int i;
-    for(i = 0; i < sizeof(status_strings)/sizeof(*status_strings); i++)
+    for(i = 0; i < ARRAY_SIZE(status_strings); i++)
         heap_free(status_strings[i]);
 }
 
@@ -490,7 +490,7 @@ static HRESULT register_server(BOOL do_register)
     INF_SET_CLSID(TridentAPI);
     INF_SET_ID(LIBID_MSHTML);
 
-    for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++) {
+    for(i=0; i < ARRAY_SIZE(pse); i++) {
         pse[i].pszValue = heap_alloc(39);
         sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
                 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
@@ -498,7 +498,7 @@ static HRESULT register_server(BOOL do_register)
                 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
     }
 
-    strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
+    strtable.cEntries = ARRAY_SIZE(pse);
     strtable.pse = pse;
 
     hAdvpack = LoadLibraryW(wszAdvpack);
@@ -508,7 +508,7 @@ static HRESULT register_server(BOOL do_register)
 
     FreeLibrary(hAdvpack);
 
-    for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
+    for(i=0; i < ARRAY_SIZE(pse); i++)
         heap_free(pse[i].pszValue);
 
     if(FAILED(hres))
diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c
index 39a0e58308..6508270d35 100644
--- a/dlls/mshtml/mutation.c
+++ b/dlls/mshtml/mutation.c
@@ -131,10 +131,10 @@ static PRUnichar *handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *
     ptr += 2;
 
     len = strlenW(ptr);
-    if(len < sizeof(endifW)/sizeof(WCHAR))
+    if(len < ARRAY_SIZE(endifW))
         return NULL;
 
-    end = ptr + len-sizeof(endifW)/sizeof(WCHAR);
+    end = ptr + len - ARRAY_SIZE(endifW);
     if(memcmp(end, endifW, sizeof(endifW)))
         return NULL;
 
@@ -398,7 +398,7 @@ static BOOL parse_ua_compatible(const WCHAR *p, compat_mode_t *r)
 
     TRACE("%s\n", debugstr_w(p));
 
-    if(strncmpiW(ie_eqW, p, sizeof(ie_eqW)/sizeof(WCHAR)))
+    if(strncmpiW(ie_eqW, p, ARRAY_SIZE(ie_eqW)))
         return FALSE;
     p += 3;
 
diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c
index cd18287178..f331cfdef5 100644
--- a/dlls/mshtml/navigate.c
+++ b/dlls/mshtml/navigate.c
@@ -728,13 +728,13 @@ static void parse_content_type(nsChannelBSC *This, const WCHAR *value)
         ptr++;
 
     len = strlenW(value);
-    if(ptr + sizeof(charsetW)/sizeof(WCHAR) < value+len && !memicmpW(ptr, charsetW, sizeof(charsetW)/sizeof(WCHAR))) {
+    if(ptr + ARRAY_SIZE(charsetW) < value+len && !memicmpW(ptr, charsetW, ARRAY_SIZE(charsetW))) {
         size_t charset_len, lena;
         nsACString charset_str;
         const WCHAR *charset;
         char *charseta;
 
-        ptr += sizeof(charsetW)/sizeof(WCHAR);
+        ptr += ARRAY_SIZE(charsetW);
 
         if(*ptr == '\'') {
             FIXME("Quoted value\n");
diff --git a/dlls/mshtml/nsembed.c b/dlls/mshtml/nsembed.c
index 9c2d5e51f9..6aae9c2948 100644
--- a/dlls/mshtml/nsembed.c
+++ b/dlls/mshtml/nsembed.c
@@ -242,7 +242,7 @@ static nsresult create_profile_directory(void)
 {
     static const WCHAR wine_geckoW[] = {'\\','w','i','n','e','_','g','e','c','k','o',0};
 
-    WCHAR path[MAX_PATH + sizeof(wine_geckoW)/sizeof(WCHAR)];
+    WCHAR path[MAX_PATH + ARRAY_SIZE(wine_geckoW)];
     cpp_bool exists;
     nsresult nsres;
     HRESULT hres;
@@ -309,7 +309,7 @@ static nsresult NSAPI nsDirectoryServiceProvider2_GetFiles(nsIDirectoryServicePr
         if(!plugin_directory) {
             static const WCHAR gecko_pluginW[] = {'\\','g','e','c','k','o','\\','p','l','u','g','i','n',0};
 
-            len = GetSystemDirectoryW(plugin_path, (sizeof(plugin_path)-sizeof(gecko_pluginW))/sizeof(WCHAR)+1);
+            len = GetSystemDirectoryW(plugin_path, ARRAY_SIZE(plugin_path)-ARRAY_SIZE(gecko_pluginW)+1);
             if(!len)
                 return NS_ERROR_UNEXPECTED;
 
@@ -413,7 +413,7 @@ static BOOL install_wine_gecko(void)
     static const WCHAR argsW[] =
         {' ','a','p','p','w','i','z','.','c','p','l',' ','i','n','s','t','a','l','l','_','g','e','c','k','o',0};
 
-    len = GetSystemDirectoryW(app, MAX_PATH-sizeof(controlW)/sizeof(WCHAR));
+    len = GetSystemDirectoryW(app, MAX_PATH-ARRAY_SIZE(controlW));
     memcpy(app+len, controlW, sizeof(controlW));
 
     args = heap_alloc(len*sizeof(WCHAR) + sizeof(controlW) + sizeof(argsW));
@@ -421,7 +421,7 @@ static BOOL install_wine_gecko(void)
         return FALSE;
 
     memcpy(args, app, len*sizeof(WCHAR) + sizeof(controlW));
-    memcpy(args + len + sizeof(controlW)/sizeof(WCHAR)-1, argsW, sizeof(argsW));
+    memcpy(args + len + ARRAY_SIZE(controlW)-1, argsW, sizeof(argsW));
 
     TRACE("starting %s\n", debugstr_w(args));
 
diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c
index 7333334f6e..d5e4983616 100644
--- a/dlls/mshtml/nsio.c
+++ b/dlls/mshtml/nsio.c
@@ -198,8 +198,8 @@ HRESULT nsuri_to_url(LPCWSTR nsuri, BOOL ret_empty, BSTR *ret)
 
     static const WCHAR wine_prefixW[] = {'w','i','n','e',':'};
 
-    if(!strncmpW(nsuri, wine_prefixW, sizeof(wine_prefixW)/sizeof(WCHAR)))
-        ptr += sizeof(wine_prefixW)/sizeof(WCHAR);
+    if(!strncmpW(nsuri, wine_prefixW, ARRAY_SIZE(wine_prefixW)))
+        ptr += ARRAY_SIZE(wine_prefixW);
 
     if(*ptr || ret_empty) {
         *ret = SysAllocString(ptr);
@@ -1271,7 +1271,7 @@ static nsresult NSAPI nsChannel_SetRequestMethod(nsIHttpChannel *iface,
     TRACE("(%p)->(%s)\n", This, debugstr_nsacstr(aRequestMethod));
 
     nsACString_GetData(aRequestMethod, &method);
-    for(i=0; i < sizeof(request_method_strings)/sizeof(*request_method_strings); i++) {
+    for(i=0; i < ARRAY_SIZE(request_method_strings); i++) {
         if(!strcasecmp(method, request_method_strings[i])) {
             This->request_method = i;
             return NS_OK;
@@ -1356,7 +1356,7 @@ static nsresult NSAPI nsChannel_SetReferrerWithPolicy(nsIHttpChannel *iface, nsI
 
     hres = IUri_GetDisplayUri(referrer->uri, &referrer_uri);
     if(SUCCEEDED(hres)) {
-        set_http_header(&This->request_headers, refererW, sizeof(refererW)/sizeof(WCHAR), referrer_uri, SysStringLen(referrer_uri));
+        set_http_header(&This->request_headers, refererW, ARRAY_SIZE(refererW), referrer_uri, SysStringLen(referrer_uri));
         SysFreeString(referrer_uri);
     }
 
@@ -1584,7 +1584,7 @@ static nsresult NSAPI nsChannel_IsNoStoreResponse(nsIHttpChannel *iface, cpp_boo
 
     TRACE("(%p)->(%p)\n", This, _retval);
 
-    header = find_http_header(&This->response_headers, cache_controlW, sizeof(cache_controlW)/sizeof(WCHAR));
+    header = find_http_header(&This->response_headers, cache_controlW, ARRAY_SIZE(cache_controlW));
     *_retval = header && !strcmpiW(header->data, no_storeW);
     return NS_OK;
 }
@@ -1756,8 +1756,7 @@ static nsresult NSAPI nsUploadChannel_SetUploadStream(nsIUploadChannel *iface,
             if(!ct)
                 return NS_ERROR_UNEXPECTED;
 
-            set_http_header(&This->request_headers, content_typeW,
-                    sizeof(content_typeW)/sizeof(WCHAR), ct, strlenW(ct));
+            set_http_header(&This->request_headers, content_typeW, ARRAY_SIZE(content_typeW), ct, strlenW(ct));
             heap_free(ct);
             This->post_data_contains_headers = FALSE;
         }
@@ -2840,7 +2839,7 @@ static nsresult NSAPI nsURI_SchemeIs(nsIFileURL *iface, const char *scheme, cpp_
     if(FAILED(hres))
         return NS_ERROR_UNEXPECTED;
 
-    MultiByteToWideChar(CP_UTF8, 0, scheme, -1, buf, sizeof(buf)/sizeof(WCHAR));
+    MultiByteToWideChar(CP_UTF8, 0, scheme, -1, buf, ARRAY_SIZE(buf));
     *_retval = !strcmpW(scheme_name, buf);
     SysFreeString(scheme_name);
     return NS_OK;
@@ -3296,7 +3295,7 @@ static nsresult NSAPI nsFileURL_GetFile(nsIFileURL *iface, nsIFile **aFile)
 
     TRACE("(%p)->(%p)\n", This, aFile);
 
-    hres = CoInternetParseIUri(This->uri, PARSE_PATH_FROM_URL, 0, path, sizeof(path)/sizeof(WCHAR), &size, 0);
+    hres = CoInternetParseIUri(This->uri, PARSE_PATH_FROM_URL, 0, path, ARRAY_SIZE(path), &size, 0);
     if(FAILED(hres)) {
         WARN("CoInternetParseIUri failed: %08x\n", hres);
         return NS_ERROR_FAILURE;
@@ -3830,7 +3829,7 @@ static BOOL is_gecko_special_uri(const char *spec)
     static const char *special_schemes[] = {"chrome:", "data:", "jar:", "moz-safe-about", "resource:", "javascript:", "wyciwyg:"};
     unsigned int i;
 
-    for(i=0; i < sizeof(special_schemes)/sizeof(*special_schemes); i++) {
+    for(i=0; i < ARRAY_SIZE(special_schemes); i++) {
         if(!strncasecmp(spec, special_schemes[i], strlen(special_schemes[i])))
             return TRUE;
     }
@@ -3894,7 +3893,7 @@ static nsresult NSAPI nsIOServiceHook_NewURI(nsIIOServiceHook *iface, const nsAC
         SysFreeString(charset);
     }
 
-    MultiByteToWideChar(cp, 0, spec, -1, new_spec, sizeof(new_spec)/sizeof(WCHAR));
+    MultiByteToWideChar(cp, 0, spec, -1, new_spec, ARRAY_SIZE(new_spec));
 
     if(base_wine_uri) {
         hres = combine_url(base_wine_uri->uri, new_spec, &urlmon_uri);
diff --git a/dlls/mshtml/olecmd.c b/dlls/mshtml/olecmd.c
index ece5874f07..e5fc474bbe 100644
--- a/dlls/mshtml/olecmd.c
+++ b/dlls/mshtml/olecmd.c
@@ -228,13 +228,10 @@ static void set_default_templates(nsIPrintSettings *settings)
     nsIPrintSettings_SetFooterStrRight(settings, empty);
     nsIPrintSettings_SetFooterStrCenter(settings, empty);
 
-    if(LoadStringW(get_shdoclc(), IDS_PRINT_HEADER_TEMPLATE, buf,
-                   sizeof(buf)/sizeof(WCHAR)))
+    if(LoadStringW(get_shdoclc(), IDS_PRINT_HEADER_TEMPLATE, buf, ARRAY_SIZE(buf)))
         set_print_template(settings, buf, TRUE);
 
-
-    if(LoadStringW(get_shdoclc(), IDS_PRINT_FOOTER_TEMPLATE, buf,
-                   sizeof(buf)/sizeof(WCHAR)))
+    if(LoadStringW(get_shdoclc(), IDS_PRINT_FOOTER_TEMPLATE, buf, ARRAY_SIZE(buf)))
         set_print_template(settings, buf, FALSE);
 
 }
@@ -838,7 +835,7 @@ static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, con
         ULONG i;
 
         for(i=0; i<cCmds; i++) {
-            if(prgCmds[i].cmdID < OLECMDID_OPEN || prgCmds[i].cmdID >= sizeof(exec_table)/sizeof(*exec_table)) {
+            if(prgCmds[i].cmdID < OLECMDID_OPEN || prgCmds[i].cmdID >= ARRAY_SIZE(exec_table)) {
                 WARN("Unsupported cmdID = %d\n", prgCmds[i].cmdID);
                 prgCmds[i].cmdf = 0;
             }else {
@@ -909,7 +906,7 @@ static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID
     HTMLDocument *This = impl_from_IOleCommandTarget(iface);
 
     if(!pguidCmdGroup) {
-        if(nCmdID < OLECMDID_OPEN || nCmdID >= sizeof(exec_table)/sizeof(*exec_table) || !exec_table[nCmdID].func) {
+        if(nCmdID < OLECMDID_OPEN || nCmdID >= ARRAY_SIZE(exec_table) || !exec_table[nCmdID].func) {
             WARN("Unsupported cmdID = %d\n", nCmdID);
             return OLECMDERR_E_NOTSUPPORTED;
         }
diff --git a/dlls/mshtml/pluginhost.c b/dlls/mshtml/pluginhost.c
index 256850be06..933e35cdcd 100644
--- a/dlls/mshtml/pluginhost.c
+++ b/dlls/mshtml/pluginhost.c
@@ -2269,10 +2269,10 @@ static BOOL parse_classid(const PRUnichar *classid, CLSID *clsid)
 
     static const PRUnichar clsidW[] = {'c','l','s','i','d',':'};
 
-    if(strncmpiW(classid, clsidW, sizeof(clsidW)/sizeof(WCHAR)))
+    if(strncmpiW(classid, clsidW, ARRAY_SIZE(clsidW)))
         return FALSE;
 
-    ptr = classid + sizeof(clsidW)/sizeof(WCHAR);
+    ptr = classid + ARRAY_SIZE(clsidW);
     len = strlenW(ptr);
 
     if(len == 38) {
diff --git a/dlls/mshtml/protocol.c b/dlls/mshtml/protocol.c
index d385f16185..f7b02c9aa0 100644
--- a/dlls/mshtml/protocol.c
+++ b/dlls/mshtml/protocol.c
@@ -370,8 +370,8 @@ static HRESULT WINAPI AboutProtocol_Start(IInternetProtocol *iface, LPCWSTR szUr
 
     TRACE("bindf %x\n", grfBINDF);
 
-    if(strlenW(szUrl)>=sizeof(wszAbout)/sizeof(WCHAR) && !memcmp(wszAbout, szUrl, sizeof(wszAbout))) {
-        text = szUrl + sizeof(wszAbout)/sizeof(WCHAR);
+    if(strlenW(szUrl) >= ARRAY_SIZE(wszAbout) && !memcmp(wszAbout, szUrl, sizeof(wszAbout))) {
+        text = szUrl + ARRAY_SIZE(wszAbout);
         if(!strcmpW(wszBlank, text))
             text = NULL;
     }
@@ -570,14 +570,14 @@ static HRESULT WINAPI ResProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
         return hres;
     }
 
-    if(len < sizeof(wszRes)/sizeof(wszRes[0]) || memcmp(url, wszRes, sizeof(wszRes))) {
+    if(len < ARRAY_SIZE(wszRes) || memcmp(url, wszRes, sizeof(wszRes))) {
         WARN("Wrong protocol of url: %s\n", debugstr_w(url));
         IInternetProtocolSink_ReportResult(pOIProtSink, E_INVALIDARG, 0, NULL);
         heap_free(url);
         return E_INVALIDARG;
     }
 
-    url_dll = url + sizeof(wszRes)/sizeof(wszRes[0]);
+    url_dll = url + ARRAY_SIZE(wszRes);
     if(!(res_type = strchrW(url_dll, '/'))) {
         WARN("wrong url: %s\n", debugstr_w(url));
         IInternetProtocolSink_ReportResult(pOIProtSink, MK_E_SYNTAX, 0, NULL);
@@ -692,23 +692,23 @@ static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPC
         static const WCHAR wszFile[] = {'f','i','l','e',':','/','/'};
         static const WCHAR wszRes[] = {'r','e','s',':','/','/'};
 
-        if(strlenW(pwzUrl) <= sizeof(wszRes)/sizeof(WCHAR) || memcmp(pwzUrl, wszRes, sizeof(wszRes)))
+        if(strlenW(pwzUrl) <= ARRAY_SIZE(wszRes) || memcmp(pwzUrl, wszRes, sizeof(wszRes)))
             return E_INVALIDARG;
 
-        ptr = strchrW(pwzUrl + sizeof(wszRes)/sizeof(WCHAR), '/');
+        ptr = strchrW(pwzUrl + ARRAY_SIZE(wszRes), '/');
         if(!ptr)
             return E_INVALIDARG;
 
-        len = ptr - (pwzUrl + sizeof(wszRes)/sizeof(WCHAR));
-        if(len >= sizeof(file_part)/sizeof(WCHAR)) {
+        len = ptr - (pwzUrl + ARRAY_SIZE(wszRes));
+        if(len >= ARRAY_SIZE(file_part)) {
             FIXME("Too long URL\n");
             return MK_E_SYNTAX;
         }
 
-        memcpy(file_part, pwzUrl + sizeof(wszRes)/sizeof(WCHAR), len*sizeof(WCHAR));
+        memcpy(file_part, pwzUrl + ARRAY_SIZE(wszRes), len*sizeof(WCHAR));
         file_part[len] = 0;
 
-        len = SearchPathW(NULL, file_part, NULL, sizeof(full_path)/sizeof(WCHAR), full_path, NULL);
+        len = SearchPathW(NULL, file_part, NULL, ARRAY_SIZE(full_path), full_path, NULL);
         if(!len) {
             HMODULE module;
 
@@ -720,20 +720,20 @@ static HRESULT WINAPI ResProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPC
                 return MK_E_SYNTAX;
             }
 
-            len = GetModuleFileNameW(module, full_path, sizeof(full_path)/sizeof(WCHAR));
+            len = GetModuleFileNameW(module, full_path, ARRAY_SIZE(full_path));
             FreeLibrary(module);
             if(!len)
                 return E_FAIL;
         }
 
-        size = sizeof(wszFile)/sizeof(WCHAR) + len + 1;
+        size = ARRAY_SIZE(wszFile) + len + 1;
         if(pcchResult)
             *pcchResult = size;
         if(size > cchResult)
             return S_FALSE;
 
         memcpy(pwzResult, wszFile, sizeof(wszFile));
-        memcpy(pwzResult + sizeof(wszFile)/sizeof(WCHAR), full_path, (len+1)*sizeof(WCHAR));
+        memcpy(pwzResult + ARRAY_SIZE(wszFile), full_path, (len+1)*sizeof(WCHAR));
         return S_OK;
     }
 
diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c
index 7acbd5bd0a..d7b4e92310 100644
--- a/dlls/mshtml/script.c
+++ b/dlls/mshtml/script.c
@@ -1054,8 +1054,8 @@ HRESULT load_script(HTMLScriptElement *script_elem, const WCHAR *src, BOOL async
 
     static const WCHAR wine_schemaW[] = {'w','i','n','e',':'};
 
-    if(strlenW(src) > sizeof(wine_schemaW)/sizeof(WCHAR) && !memcmp(src, wine_schemaW, sizeof(wine_schemaW)))
-        src += sizeof(wine_schemaW)/sizeof(WCHAR);
+    if(strlenW(src) > ARRAY_SIZE(wine_schemaW) && !memcmp(src, wine_schemaW, sizeof(wine_schemaW)))
+        src += ARRAY_SIZE(wine_schemaW);
 
     TRACE("(%p %s %x)\n", script_elem, debugstr_w(src), async);
 
diff --git a/dlls/mshtml/view.c b/dlls/mshtml/view.c
index 531c680523..442b07d89a 100644
--- a/dlls/mshtml/view.c
+++ b/dlls/mshtml/view.c
@@ -411,10 +411,8 @@ HRESULT call_set_active_object(IOleInPlaceUIWindow *window, IOleInPlaceActiveObj
 {
     static WCHAR html_documentW[30];
 
-    if(act_obj && !html_documentW[0]) {
-        LoadStringW(hInst, IDS_HTMLDOCUMENT, html_documentW,
-                    sizeof(html_documentW)/sizeof(WCHAR));
-    }
+    if(act_obj && !html_documentW[0])
+        LoadStringW(hInst, IDS_HTMLDOCUMENT, html_documentW, ARRAY_SIZE(html_documentW));
 
     return IOleInPlaceUIWindow_SetActiveObject(window, act_obj, act_obj ? html_documentW : NULL);
 }
-- 
2.14.4




More information about the wine-devel mailing list