From: Nikolay Sivov Subject: [PATCH 1/2] xmllite: Use ARRAY_SIZE macro for reader too Message-Id: <20180222060144.29378-1-nsivov@codeweavers.com> Date: Thu, 22 Feb 2018 09:01:43 +0300 Signed-off-by: Nikolay Sivov --- dlls/xmllite/reader.c | 8 ++++---- dlls/xmllite/writer.c | 2 -- dlls/xmllite/xmllite_private.h | 2 ++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c index 495d4e3cb4..9cb7f3bd77 100644 --- a/dlls/xmllite/reader.c +++ b/dlls/xmllite/reader.c @@ -168,7 +168,7 @@ const WCHAR *get_encoding_name(xml_encoding encoding) xml_encoding get_encoding_from_codepage(UINT codepage) { int i; - for (i = 0; i < sizeof(xml_encoding_map)/sizeof(xml_encoding_map[0]); i++) + for (i = 0; i < ARRAY_SIZE(xml_encoding_map); i++) { if (xml_encoding_map[i].cp == codepage) return xml_encoding_map[i].enc; } @@ -749,7 +749,7 @@ xml_encoding parse_encoding_name(const WCHAR *name, int len) if (!name) return XmlEncoding_Unknown; min = 0; - max = sizeof(xml_encoding_map)/sizeof(xml_encoding_map[0]) - 1; + max = ARRAY_SIZE(xml_encoding_map) - 1; while (min <= max) { @@ -3013,12 +3013,12 @@ static void reader_get_attribute_ns_uri(xmlreader *reader, struct attribute *att strval_eq(reader, &attr->prefix, &strval_xmlns)) { *uri = xmlns_uriW; - *len = sizeof(xmlns_uriW)/sizeof(xmlns_uriW[0]) - 1; + *len = ARRAY_SIZE(xmlns_uriW) - 1; } else if (strval_eq(reader, &attr->prefix, &strval_xml)) { *uri = xml_uriW; - *len = sizeof(xml_uriW)/sizeof(xml_uriW[0]) - 1; + *len = ARRAY_SIZE(xml_uriW) - 1; } else { diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index 9bf7e63211..88f75b6e20 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -37,8 +37,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(xmllite); /* not defined in public headers */ DEFINE_GUID(IID_IXmlWriterOutput, 0xc1131708, 0x0f59, 0x477f, 0x93, 0x59, 0x7d, 0x33, 0x24, 0x51, 0xbc, 0x1a); -#define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0])) - static const WCHAR closeelementW[] = {'<','/'}; static const WCHAR closetagW[] = {' ','/','>'}; static const WCHAR closepiW[] = {'?','>'}; diff --git a/dlls/xmllite/xmllite_private.h b/dlls/xmllite/xmllite_private.h index 7884e27453..381dec496c 100644 --- a/dlls/xmllite/xmllite_private.h +++ b/dlls/xmllite/xmllite_private.h @@ -23,6 +23,8 @@ #include "wine/heap.h" +#define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0])) + static inline void *m_alloc(IMalloc *imalloc, size_t len) { if (imalloc) -- 2.16.1