msxml3: Use ARRAY_SIZE() macro.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Nikolay Sivov 2018-02-27 01:16:41 +03:00 committed by Alexandre Julliard
parent a62bed3bb8
commit 6b7e1131e5
10 changed files with 67 additions and 65 deletions

View File

@ -251,9 +251,9 @@ HRESULT create_uri(const WCHAR *url, IUri **uri)
if (!PathIsURLW(url))
{
WCHAR fullpath[MAX_PATH];
DWORD needed = sizeof(fileUrl)/sizeof(WCHAR);
DWORD needed = ARRAY_SIZE(fileUrl);
if (!PathSearchAndQualifyW(url, fullpath, sizeof(fullpath)/sizeof(WCHAR)))
if (!PathSearchAndQualifyW(url, fullpath, ARRAY_SIZE(fullpath)))
{
WARN("can't find path\n");
return E_FAIL;

View File

@ -208,11 +208,11 @@ void release_typelib(void)
heap_free(iter);
}
for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
for(i=0; i < ARRAY_SIZE(typeinfos); i++)
if(typeinfos[i])
ITypeInfo_Release(typeinfos[i]);
for(i=0; i < sizeof(typelib)/sizeof(*typelib); i++)
for(i=0; i < ARRAY_SIZE(typelib); i++)
if(typelib[i])
ITypeLib_Release(typelib[i]);

View File

@ -100,7 +100,7 @@ static MSXML_VERSION get_msxml_version(const GUID *clsid)
{
unsigned int i;
for (i = 0; i < sizeof(clsid_versions_table)/sizeof(struct clsid_version_t); i++)
for (i = 0; i < ARRAY_SIZE(clsid_versions_table); i++)
if (IsEqualGUID(clsid, clsid_versions_table[i].clsid))
return clsid_versions_table[i].version;

View File

@ -516,7 +516,7 @@ static HRESULT WINAPI BSCHttpNegotiate_BeginningTransaction(IHttpNegotiate *ifac
if (This->request->use_utf8_content)
{
lstrcpyW(ptr, content_type_utf8W);
ptr += sizeof(content_type_utf8W)/sizeof(WCHAR)-1;
ptr += ARRAY_SIZE(content_type_utf8W) - 1;
}
if (base_uri)
@ -535,13 +535,13 @@ static HRESULT WINAPI BSCHttpNegotiate_BeginningTransaction(IHttpNegotiate *ifac
ptr += SysStringLen(entry->header);
lstrcpyW(ptr, colspaceW);
ptr += sizeof(colspaceW)/sizeof(WCHAR)-1;
ptr += ARRAY_SIZE(colspaceW) - 1;
lstrcpyW(ptr, entry->value);
ptr += SysStringLen(entry->value);
lstrcpyW(ptr, crlfW);
ptr += sizeof(crlfW)/sizeof(WCHAR)-1;
ptr += ARRAY_SIZE(crlfW) - 1;
}
*add_headers = buff;
@ -1030,8 +1030,8 @@ static HRESULT httprequest_setRequestHeader(httprequest *This, BSTR header, BSTR
entry->value = SysAllocString(value);
/* header length including null terminator */
This->reqheader_size += SysStringLen(entry->header) + sizeof(colspaceW)/sizeof(WCHAR) +
SysStringLen(entry->value) + sizeof(crlfW)/sizeof(WCHAR) - 1;
This->reqheader_size += SysStringLen(entry->header) + ARRAY_SIZE(colspaceW) +
SysStringLen(entry->value) + ARRAY_SIZE(crlfW) - 1;
list_add_head(&This->reqheaders, &entry->entry);

View File

@ -69,7 +69,7 @@ void wineXmlCallbackLog(char const* caller, xmlErrorLevel lvl, char const* msg,
{
enum __wine_debug_class dbcl;
char buff[200];
const int max_size = sizeof(buff) / sizeof(buff[0]);
const int max_size = ARRAY_SIZE(buff);
int len;
switch (lvl)

View File

@ -31,6 +31,8 @@
# error You must include config.h to use this header
#endif
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
typedef enum {
MSXML_DEFAULT = 0,
MSXML2 = 20,

View File

@ -225,7 +225,7 @@ static xml_encoding parse_encoding_name(const WCHAR *encoding)
int min, max, n, c;
min = 0;
max = sizeof(xml_encoding_map)/sizeof(struct xml_encoding_data) - 1;
max = ARRAY_SIZE(xml_encoding_map) - 1;
while (min <= max)
{
@ -515,21 +515,21 @@ static WCHAR *get_escaped_string(const WCHAR *str, escape_mode mode, int *len)
{
case '<':
memcpy(ptr, ltW, sizeof(ltW));
ptr += sizeof(ltW)/sizeof(WCHAR);
ptr += ARRAY_SIZE(ltW);
break;
case '&':
memcpy(ptr, ampW, sizeof(ampW));
ptr += sizeof(ampW)/sizeof(WCHAR);
ptr += ARRAY_SIZE(ampW);
break;
case '>':
memcpy(ptr, gtW, sizeof(gtW));
ptr += sizeof(gtW)/sizeof(WCHAR);
ptr += ARRAY_SIZE(gtW);
break;
case '"':
if (mode == EscapeValue)
{
memcpy(ptr, equotW, sizeof(equotW));
ptr += sizeof(equotW)/sizeof(WCHAR);
ptr += ARRAY_SIZE(equotW);
break;
}
/* fallthrough for text mode */
@ -557,26 +557,26 @@ static void write_prolog_buffer(mxwriter *writer)
static const WCHAR noW[] = {'n','o','\"','?','>'};
/* version */
write_output_buffer(writer, versionW, sizeof(versionW)/sizeof(WCHAR));
write_output_buffer(writer, versionW, ARRAY_SIZE(versionW));
write_output_buffer_quoted(writer, writer->version, -1);
/* encoding */
write_output_buffer(writer, encodingW, sizeof(encodingW)/sizeof(WCHAR));
write_output_buffer(writer, encodingW, ARRAY_SIZE(encodingW));
if (writer->dest)
write_output_buffer(writer, writer->encoding, -1);
else
write_output_buffer(writer, utf16W, sizeof(utf16W)/sizeof(WCHAR) - 1);
write_output_buffer(writer, utf16W, ARRAY_SIZE(utf16W) - 1);
write_output_buffer(writer, quotW, 1);
/* standalone */
write_output_buffer(writer, standaloneW, sizeof(standaloneW)/sizeof(WCHAR));
write_output_buffer(writer, standaloneW, ARRAY_SIZE(standaloneW));
if (writer->props[MXWriter_Standalone] == VARIANT_TRUE)
write_output_buffer(writer, yesW, sizeof(yesW)/sizeof(WCHAR));
write_output_buffer(writer, yesW, ARRAY_SIZE(yesW));
else
write_output_buffer(writer, noW, sizeof(noW)/sizeof(WCHAR));
write_output_buffer(writer, noW, ARRAY_SIZE(noW));
write_output_buffer(writer, crlfW, sizeof(crlfW)/sizeof(WCHAR));
write_output_buffer(writer, crlfW, ARRAY_SIZE(crlfW));
writer->newline = TRUE;
}
@ -628,7 +628,7 @@ static void write_node_indent(mxwriter *writer)
/* This is to workaround PI output logic that always puts newline chars,
document prolog PI does that too. */
if (!writer->newline)
write_output_buffer(writer, crlfW, sizeof(crlfW)/sizeof(WCHAR));
write_output_buffer(writer, crlfW, ARRAY_SIZE(crlfW));
while (indent--)
write_output_buffer(writer, tabW, 1);
@ -1445,7 +1445,7 @@ static HRESULT WINAPI SAXContentHandler_processingInstruction(
if (!target) return E_INVALIDARG;
write_node_indent(This);
write_output_buffer(This, openpiW, sizeof(openpiW)/sizeof(WCHAR));
write_output_buffer(This, openpiW, ARRAY_SIZE(openpiW));
if (*target)
write_output_buffer(This, target, ntarget);
@ -1456,7 +1456,7 @@ static HRESULT WINAPI SAXContentHandler_processingInstruction(
write_output_buffer(This, data, ndata);
}
write_output_buffer(This, closepiW, sizeof(closepiW)/sizeof(WCHAR));
write_output_buffer(This, closepiW, ARRAY_SIZE(closepiW));
This->newline = TRUE;
return S_OK;
@ -1524,7 +1524,7 @@ static HRESULT WINAPI SAXLexicalHandler_startDTD(ISAXLexicalHandler *iface,
if (!name) return E_INVALIDARG;
write_output_buffer(This, doctypeW, sizeof(doctypeW)/sizeof(WCHAR));
write_output_buffer(This, doctypeW, ARRAY_SIZE(doctypeW));
if (*name)
{
@ -1534,7 +1534,7 @@ static HRESULT WINAPI SAXLexicalHandler_startDTD(ISAXLexicalHandler *iface,
if (publicId)
{
write_output_buffer(This, publicW, sizeof(publicW)/sizeof(WCHAR));
write_output_buffer(This, publicW, ARRAY_SIZE(publicW));
write_output_buffer_quoted(This, publicId, publicId_len);
if (!systemId) return E_INVALIDARG;
@ -1549,13 +1549,13 @@ static HRESULT WINAPI SAXLexicalHandler_startDTD(ISAXLexicalHandler *iface,
}
else if (systemId)
{
write_output_buffer(This, systemW, sizeof(systemW)/sizeof(WCHAR));
write_output_buffer(This, systemW, ARRAY_SIZE(systemW));
write_output_buffer_quoted(This, systemId, systemId_len);
if (*systemId)
write_output_buffer(This, spaceW, 1);
}
write_output_buffer(This, openintW, sizeof(openintW)/sizeof(WCHAR));
write_output_buffer(This, openintW, ARRAY_SIZE(openintW));
return S_OK;
}
@ -1567,7 +1567,7 @@ static HRESULT WINAPI SAXLexicalHandler_endDTD(ISAXLexicalHandler *iface)
TRACE("(%p)\n", This);
write_output_buffer(This, closedtdW, sizeof(closedtdW)/sizeof(WCHAR));
write_output_buffer(This, closedtdW, ARRAY_SIZE(closedtdW));
return S_OK;
}
@ -1594,7 +1594,7 @@ static HRESULT WINAPI SAXLexicalHandler_startCDATA(ISAXLexicalHandler *iface)
TRACE("(%p)\n", This);
write_node_indent(This);
write_output_buffer(This, scdataW, sizeof(scdataW)/sizeof(WCHAR));
write_output_buffer(This, scdataW, ARRAY_SIZE(scdataW));
This->cdata = TRUE;
return S_OK;
@ -1607,7 +1607,7 @@ static HRESULT WINAPI SAXLexicalHandler_endCDATA(ISAXLexicalHandler *iface)
TRACE("(%p)\n", This);
write_output_buffer(This, ecdataW, sizeof(ecdataW)/sizeof(WCHAR));
write_output_buffer(This, ecdataW, ARRAY_SIZE(ecdataW));
This->cdata = FALSE;
return S_OK;
@ -1626,10 +1626,10 @@ static HRESULT WINAPI SAXLexicalHandler_comment(ISAXLexicalHandler *iface, const
close_element_starttag(This);
write_node_indent(This);
write_output_buffer(This, copenW, sizeof(copenW)/sizeof(WCHAR));
write_output_buffer(This, copenW, ARRAY_SIZE(copenW));
if (nchars)
write_output_buffer(This, chars, nchars);
write_output_buffer(This, ccloseW, sizeof(ccloseW)/sizeof(WCHAR));
write_output_buffer(This, ccloseW, ARRAY_SIZE(ccloseW));
return S_OK;
}
@ -1679,14 +1679,14 @@ static HRESULT WINAPI SAXDeclHandler_elementDecl(ISAXDeclHandler *iface,
if (!name || !model) return E_INVALIDARG;
write_output_buffer(This, elementW, sizeof(elementW)/sizeof(WCHAR));
write_output_buffer(This, elementW, ARRAY_SIZE(elementW));
if (n_name) {
write_output_buffer(This, name, n_name);
write_output_buffer(This, spaceW, sizeof(spaceW)/sizeof(WCHAR));
write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW));
}
if (n_model)
write_output_buffer(This, model, n_model);
write_output_buffer(This, closetagW, sizeof(closetagW)/sizeof(WCHAR));
write_output_buffer(This, closetagW, ARRAY_SIZE(closetagW));
return S_OK;
}
@ -1704,31 +1704,31 @@ static HRESULT WINAPI SAXDeclHandler_attributeDecl(ISAXDeclHandler *iface,
debugstr_wn(attr, n_attr), n_attr, debugstr_wn(type, n_type), n_type, debugstr_wn(Default, n_default), n_default,
debugstr_wn(value, n_value), n_value);
write_output_buffer(This, attlistW, sizeof(attlistW)/sizeof(WCHAR));
write_output_buffer(This, attlistW, ARRAY_SIZE(attlistW));
if (n_element) {
write_output_buffer(This, element, n_element);
write_output_buffer(This, spaceW, sizeof(spaceW)/sizeof(WCHAR));
write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW));
}
if (n_attr) {
write_output_buffer(This, attr, n_attr);
write_output_buffer(This, spaceW, sizeof(spaceW)/sizeof(WCHAR));
write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW));
}
if (n_type) {
write_output_buffer(This, type, n_type);
write_output_buffer(This, spaceW, sizeof(spaceW)/sizeof(WCHAR));
write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW));
}
if (n_default) {
write_output_buffer(This, Default, n_default);
write_output_buffer(This, spaceW, sizeof(spaceW)/sizeof(WCHAR));
write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW));
}
if (n_value)
write_output_buffer_quoted(This, value, n_value);
write_output_buffer(This, closetagW, sizeof(closetagW)/sizeof(WCHAR));
write_output_buffer(This, closetagW, ARRAY_SIZE(closetagW));
return S_OK;
}
@ -1743,16 +1743,16 @@ static HRESULT WINAPI SAXDeclHandler_internalEntityDecl(ISAXDeclHandler *iface,
if (!name || !value) return E_INVALIDARG;
write_output_buffer(This, entityW, sizeof(entityW)/sizeof(WCHAR));
write_output_buffer(This, entityW, ARRAY_SIZE(entityW));
if (n_name) {
write_output_buffer(This, name, n_name);
write_output_buffer(This, spaceW, sizeof(spaceW)/sizeof(WCHAR));
write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW));
}
if (n_value)
write_output_buffer_quoted(This, value, n_value);
write_output_buffer(This, closetagW, sizeof(closetagW)/sizeof(WCHAR));
write_output_buffer(This, closetagW, ARRAY_SIZE(closetagW));
return S_OK;
}
@ -1768,26 +1768,26 @@ static HRESULT WINAPI SAXDeclHandler_externalEntityDecl(ISAXDeclHandler *iface,
if (!name || !systemId) return E_INVALIDARG;
write_output_buffer(This, entityW, sizeof(entityW)/sizeof(WCHAR));
write_output_buffer(This, entityW, ARRAY_SIZE(entityW));
if (n_name) {
write_output_buffer(This, name, n_name);
write_output_buffer(This, spaceW, sizeof(spaceW)/sizeof(WCHAR));
write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW));
}
if (publicId)
{
write_output_buffer(This, publicW, sizeof(publicW)/sizeof(WCHAR));
write_output_buffer(This, publicW, ARRAY_SIZE(publicW));
write_output_buffer_quoted(This, publicId, n_publicId);
write_output_buffer(This, spaceW, sizeof(spaceW)/sizeof(WCHAR));
write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW));
write_output_buffer_quoted(This, systemId, n_systemId);
}
else
{
write_output_buffer(This, systemW, sizeof(systemW)/sizeof(WCHAR));
write_output_buffer(This, systemW, ARRAY_SIZE(systemW));
write_output_buffer_quoted(This, systemId, n_systemId);
}
write_output_buffer(This, closetagW, sizeof(closetagW)/sizeof(WCHAR));
write_output_buffer(This, closetagW, ARRAY_SIZE(closetagW));
return S_OK;
}
@ -2299,30 +2299,30 @@ static HRESULT WINAPI SAXDTDHandler_notationDecl(ISAXDTDHandler *iface,
if (!name || !n_name)
return E_INVALIDARG;
write_output_buffer(This, notationW, sizeof(notationW)/sizeof(WCHAR));
write_output_buffer(This, notationW, ARRAY_SIZE(notationW));
write_output_buffer(This, name, n_name);
if (!publicid && !systemid)
return E_INVALIDARG;
write_output_buffer(This, spaceW, sizeof(spaceW)/sizeof(WCHAR));
write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW));
if (publicid)
{
write_output_buffer(This, publicW, sizeof(publicW)/sizeof(WCHAR));
write_output_buffer(This, publicW, ARRAY_SIZE(publicW));
write_output_buffer_quoted(This, publicid, n_publicid);
if (systemid)
{
write_output_buffer(This, spaceW, sizeof(spaceW)/sizeof(WCHAR));
write_output_buffer(This, spaceW, ARRAY_SIZE(spaceW));
write_output_buffer_quoted(This, systemid, n_systemid);
}
}
else
{
write_output_buffer(This, systemW, sizeof(systemW)/sizeof(WCHAR));
write_output_buffer(This, systemW, ARRAY_SIZE(systemW));
write_output_buffer_quoted(This, systemid, n_systemid);
}
write_output_buffer(This, closetagW, sizeof(closetagW)/sizeof(WCHAR));
write_output_buffer(This, closetagW, ARRAY_SIZE(closetagW));
return S_OK;
}

View File

@ -130,7 +130,7 @@ static saxreader_feature get_saxreader_feature(const WCHAR *name)
int min, max, n, c;
min = 0;
max = sizeof(saxreader_feature_map)/sizeof(struct saxreader_feature_pair) - 1;
max = ARRAY_SIZE(saxreader_feature_map) - 1;
while (min <= max)
{
@ -678,7 +678,7 @@ static void format_error_message_from_id(saxlocator *This, HRESULT hr)
{
WCHAR msg[1024];
if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
NULL, hr, 0, msg, sizeof(msg)/sizeof(msg[0]), NULL))
NULL, hr, 0, msg, ARRAY_SIZE(msg), NULL))
{
FIXME("MSXML errors not yet supported.\n");
msg[0] = '\0';
@ -1420,7 +1420,7 @@ static BSTR saxreader_get_unescaped_value(const xmlChar *buf, int len)
WCHAR *src;
/* leave first '&' from a reference as a value */
src = dest + (sizeof(ampescW)/sizeof(WCHAR) - 1);
src = dest + ARRAY_SIZE(ampescW) - 1;
dest++;
/* move together with null terminator */

View File

@ -374,9 +374,9 @@ static HRESULT WINAPI xmldoc_put_URL(IXMLDocument *iface, BSTR p)
if (!PathIsURLW(p))
{
WCHAR fullpath[MAX_PATH];
DWORD needed = sizeof(url) / sizeof(WCHAR);
DWORD needed = ARRAY_SIZE(url);
if (!PathSearchAndQualifyW(p, fullpath, sizeof(fullpath) / sizeof(WCHAR)))
if (!PathSearchAndQualifyW(p, fullpath, ARRAY_SIZE(fullpath)))
{
ERR("can't find path\n");
return E_FAIL;

View File

@ -434,7 +434,7 @@ static inline HRESULT handle_xml_load(BindStatusCallback *This)
/* TODO: fix parsing processing instruction value */
if((p = strstrW(V_BSTR(&var), hrefW))) {
p += sizeof(hrefW)/sizeof(WCHAR)-1;
p += ARRAY_SIZE(hrefW) - 1;
if(*p!='\'' && *p!='\"') p = NULL;
else {
href = p+1;