Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- 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)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/xmllite/tests/reader.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c index 3cdc177e0b..975724ab18 100644 --- a/dlls/xmllite/tests/reader.c +++ b/dlls/xmllite/tests/reader.c @@ -32,6 +32,8 @@ #include "wine/test.h" #include "wine/heap.h"
+#define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0])) + DEFINE_GUID(IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda);
static WCHAR *a2w(const char *str) @@ -1643,7 +1645,7 @@ static void test_readvaluechunk(void)
c = 0xdeadbeef; memset(buf, 0xcc, sizeof(buf)); - hr = IXmlReader_ReadValueChunk(reader, buf, sizeof(buf)/sizeof(WCHAR), &c); + hr = IXmlReader_ReadValueChunk(reader, buf, ARRAY_SIZE(buf), &c); ok(hr == S_OK, "got %08x\n", hr); ok(c == 10, "got %u\n", c); ok(buf[c] == 0xcccc, "buffer overflow\n"); @@ -1652,7 +1654,7 @@ static void test_readvaluechunk(void)
c = 0xdeadbeef; memset(buf, 0xcc, sizeof(buf)); - hr = IXmlReader_ReadValueChunk(reader, buf, sizeof(buf)/sizeof(WCHAR), &c); + hr = IXmlReader_ReadValueChunk(reader, buf, ARRAY_SIZE(buf), &c); ok(hr == S_FALSE, "got %08x\n", hr); ok(!c, "got %u\n", c);
@@ -1985,7 +1987,7 @@ static void test_prefix(void) hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL); ok(hr == S_OK, "S_OK, got %08x\n", hr);
- for (i = 0; i < sizeof(prefix_tests)/sizeof(prefix_tests[0]); i++) { + for (i = 0; i < ARRAY_SIZE(prefix_tests); i++) { XmlNodeType type;
set_input_string(reader, prefix_tests[i].xml); @@ -2060,7 +2062,7 @@ static void test_namespaceuri(void) hr = CreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL); ok(hr == S_OK, "S_OK, got %08x\n", hr);
- for (i = 0; i < sizeof(uri_tests)/sizeof(uri_tests[0]); i++) { + for (i = 0; i < ARRAY_SIZE(uri_tests); i++) { unsigned int j = 0;
set_input_string(reader, uri_tests[i].xml); @@ -2181,7 +2183,7 @@ static void test_encoding_detection(void)
/* there's no way to query detected encoding back, so just verify that document is browsable */
- for (i = 0; i < sizeof(encoding_testsA)/sizeof(encoding_testsA[0]); i++) + for (i = 0; i < ARRAY_SIZE(encoding_testsA); i++) { set_input_string(reader, encoding_testsA[i]);
@@ -2191,7 +2193,7 @@ static void test_encoding_detection(void) ok(type != XmlNodeType_None, "Unexpected node type %d\n", type); }
- for (i = 0; i < sizeof(encoding_testsW)/sizeof(encoding_testsW[0]); i++) + for (i = 0; i < ARRAY_SIZE(encoding_testsW); i++) { stream = create_stream_on_data(encoding_testsW[i].text, lstrlenW(encoding_testsW[i].text) * sizeof(WCHAR));