dwrite: Use ARRAY_SIZE() macro.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2018-02-21 08:15:22 +03:00 committed by Alexandre Julliard
parent c3beca6c8f
commit d31651b705
4 changed files with 23 additions and 21 deletions

View File

@ -217,8 +217,8 @@ struct fallback_mapping {
static const struct fallback_mapping fontfallback_neutral_data[] = {
#define MAPPING_RANGE(ranges, families) \
{ (DWRITE_UNICODE_RANGE *)ranges, sizeof(ranges)/sizeof(ranges[0]), \
(WCHAR **)families, sizeof(families)/sizeof(families[0]) }
{ (DWRITE_UNICODE_RANGE *)ranges, ARRAY_SIZE(ranges), \
(WCHAR **)families, ARRAY_SIZE(families) }
MAPPING_RANGE(cjk_ranges, cjk_families),
@ -1056,7 +1056,7 @@ static UINT32 get_opentype_language(const WCHAR *locale)
if (locale) {
WCHAR tag[5];
if (GetLocaleInfoEx(locale, LOCALE_SOPENTYPELANGUAGETAG, tag, sizeof(tag)/sizeof(WCHAR)))
if (GetLocaleInfoEx(locale, LOCALE_SOPENTYPELANGUAGETAG, tag, ARRAY_SIZE(tag)))
language = DWRITE_MAKE_OPENTYPE_TAG(tag[0],tag[1],tag[2],tag[3]);
}
@ -1108,7 +1108,7 @@ static DWRITE_NUMBER_SUBSTITUTION_METHOD get_number_substitutes(IDWriteNumberSub
break;
case DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL:
case DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL:
if (GetLocaleInfoEx(numbersubst->locale, LOCALE_SISO639LANGNAME, isolang, sizeof(isolang)/sizeof(isolang[0]))) {
if (GetLocaleInfoEx(numbersubst->locale, LOCALE_SISO639LANGNAME, isolang, ARRAY_SIZE(isolang))) {
static const WCHAR arW[] = {'a','r',0};
static const WCHAR arabicW[] = {0x640,0x641,0x642,0x643,0x644,0x645,0x646,0x647,0x648,0x649,0};
@ -2199,7 +2199,7 @@ HRESULT create_system_fontfallback(IDWriteFactory5 *factory, IDWriteFontFallback
fallback->IDWriteFontFallback_iface.lpVtbl = &fontfallbackvtbl;
fallback->factory = factory;
fallback->mappings = (struct fallback_mapping *)fontfallback_neutral_data;
fallback->mappings_count = sizeof(fontfallback_neutral_data) / sizeof(*fontfallback_neutral_data);
fallback->mappings_count = ARRAY_SIZE(fontfallback_neutral_data);
IDWriteFactory5_GetSystemFontCollection(fallback->factory, FALSE, &fallback->systemcollection, FALSE);
*ret = &fallback->IDWriteFontFallback_iface;

View File

@ -24,6 +24,8 @@
#include "wine/list.h"
#include "wine/unicode.h"
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
static const DWRITE_MATRIX identity =
{
1.0f, 0.0f,

View File

@ -419,7 +419,7 @@ static void release_font_data(struct dwrite_font_data *data)
if (InterlockedDecrement(&data->ref) > 0)
return;
for (i = DWRITE_INFORMATIONAL_STRING_NONE; i < sizeof(data->info_strings)/sizeof(data->info_strings[0]); i++) {
for (i = DWRITE_INFORMATIONAL_STRING_NONE; i < ARRAY_SIZE(data->info_strings); i++) {
if (data->info_strings[i])
IDWriteLocalizedStrings_Release(data->info_strings[i]);
}
@ -522,7 +522,7 @@ static ULONG WINAPI dwritefontface_Release(IDWriteFontFace4 *iface)
IDWriteFontFileStream_Release(This->stream);
heap_free(This->files);
for (i = 0; i < sizeof(This->glyphs)/sizeof(This->glyphs[0]); i++)
for (i = 0; i < ARRAY_SIZE(This->glyphs); i++)
heap_free(This->glyphs[i]);
freetype_notify_cacheremove(iface);
@ -3060,7 +3060,7 @@ static BOOL is_known_weight_value(DWRITE_FONT_WEIGHT weight, WCHAR *nameW)
{ extrablackW, DWRITE_FONT_WEIGHT_EXTRA_BLACK }
};
ptr = bsearch(&weight, knownweights, sizeof(knownweights)/sizeof(knownweights[0]), sizeof(knownweights[0]),
ptr = bsearch(&weight, knownweights, ARRAY_SIZE(knownweights), sizeof(knownweights[0]),
compare_knownweights);
if (!ptr) {
nameW[0] = 0;
@ -3373,8 +3373,8 @@ static HRESULT init_font_data(const struct fontface_desc *desc, IDWriteLocalized
data->fontsig = props.fontsig;
data->lf = props.lf;
fontstrings_get_en_string(*family_name, familyW, sizeof(familyW)/sizeof(WCHAR));
fontstrings_get_en_string(data->names, faceW, sizeof(faceW)/sizeof(WCHAR));
fontstrings_get_en_string(*family_name, familyW, ARRAY_SIZE(familyW));
fontstrings_get_en_string(data->names, faceW, ARRAY_SIZE(faceW));
if (font_apply_differentiation_rules(data, familyW, faceW)) {
set_en_localizedstring(*family_name, familyW);
set_en_localizedstring(data->names, faceW);
@ -3495,7 +3495,7 @@ static void fontfamily_add_bold_simulated_face(struct dwrite_fontfamily_data *fa
/* Simulated face name should only contain Bold as weight term,
so remove existing regular and weight terms. */
fontstrings_get_en_string(family->fonts[heaviest]->names, initialW, sizeof(initialW)/sizeof(WCHAR));
fontstrings_get_en_string(family->fonts[heaviest]->names, initialW, ARRAY_SIZE(initialW));
facename_remove_regular_term(initialW, -1);
/* remove current weight pattern */
@ -3566,7 +3566,7 @@ static void fontfamily_add_oblique_simulated_face(struct dwrite_fontfamily_data
/* add oblique simulation based on this regular face */
/* remove regular term if any, append 'Oblique' */
fontstrings_get_en_string(family->fonts[regular]->names, facenameW, sizeof(facenameW)/sizeof(WCHAR));
fontstrings_get_en_string(family->fonts[regular]->names, facenameW, ARRAY_SIZE(facenameW));
facename_remove_regular_term(facenameW, -1);
if (*facenameW)
@ -3610,7 +3610,7 @@ static BOOL fontcollection_add_replacement(struct dwrite_fontcollection *collect
}
fontcollection_add_family(collection, target);
fontstrings_get_en_string(replacement->familyname, nameW, sizeof(nameW)/sizeof(WCHAR));
fontstrings_get_en_string(replacement->familyname, nameW, ARRAY_SIZE(nameW));
TRACE("replacement %s -> %s\n", debugstr_w(target_name), debugstr_w(nameW));
}
IDWriteLocalizedStrings_Release(strings);
@ -3767,7 +3767,7 @@ HRESULT create_font_collection(IDWriteFactory5 *factory, IDWriteFontFileEnumerat
continue;
}
fontstrings_get_en_string(family_name, familyW, sizeof(familyW)/sizeof(WCHAR));
fontstrings_get_en_string(family_name, familyW, ARRAY_SIZE(familyW));
/* ignore dot named faces */
if (familyW[0] == '.') {
@ -3886,7 +3886,7 @@ static HRESULT create_local_file_reference(IDWriteFactory5 *factory, const WCHAR
static const WCHAR fontsW[] = {'\\','f','o','n','t','s','\\',0};
WCHAR fullpathW[MAX_PATH];
GetWindowsDirectoryW(fullpathW, sizeof(fullpathW)/sizeof(WCHAR));
GetWindowsDirectoryW(fullpathW, ARRAY_SIZE(fullpathW));
strcatW(fullpathW, fontsW);
strcatW(fullpathW, filename);
@ -3914,7 +3914,7 @@ static HRESULT WINAPI systemfontfileenumerator_MoveNext(IDWriteFontFileEnumerato
{
struct system_fontfile_enumerator *enumerator = impl_from_IDWriteFontFileEnumerator(iface);
WCHAR name_buf[256], *name = name_buf;
DWORD name_count, max_name_count = sizeof(name_buf) / sizeof(*name_buf), type, data_size;
DWORD name_count, max_name_count = ARRAY_SIZE(name_buf), type, data_size;
HRESULT hr = S_OK;
LONG r;
@ -4162,8 +4162,8 @@ HRESULT get_eudc_fontcollection(IDWriteFactory5 *factory, IDWriteFontCollection1
WCHAR keynameW[64], pathW[MAX_PATH];
DWORD type, path_len, name_len;
path_len = sizeof(pathW)/sizeof(*pathW);
name_len = sizeof(keynameW)/sizeof(*keynameW);
path_len = ARRAY_SIZE(pathW);
name_len = ARRAY_SIZE(keynameW);
retval = RegEnumValueW(eudckey, index++, keynameW, &name_len, NULL, &type, (BYTE*)pathW, &path_len);
if (retval || type != REG_SZ)
continue;

View File

@ -1553,7 +1553,7 @@ static BOOL opentype_decode_namerecord(const TT_NAME_V0 *header, BYTE *storage_a
UINT codepage;
codepage = get_name_record_codepage(platform, encoding);
get_name_record_locale(platform, lang_id, locale, sizeof(locale)/sizeof(WCHAR));
get_name_record_locale(platform, lang_id, locale, ARRAY_SIZE(locale));
if (codepage) {
DWORD len = MultiByteToWideChar(codepage, 0, (LPSTR)(storage_area + offset), length, NULL, 0);
@ -1730,7 +1730,7 @@ HRESULT opentype_get_font_facename(struct file_stream_desc *stream_desc, WCHAR *
BOOL exists;
exists = FALSE;
if (GetSystemDefaultLocaleName(localeW, sizeof(localeW)/sizeof(WCHAR)))
if (GetSystemDefaultLocaleName(localeW, ARRAY_SIZE(localeW)))
IDWriteLocalizedStrings_FindLocaleName(lfnames, localeW, &index, &exists);
if (!exists)
@ -1801,7 +1801,7 @@ HRESULT opentype_get_typographic_features(IDWriteFontFace *fontface, UINT32 scri
UINT8 i;
*count = 0;
for (i = 0; i < sizeof(tables)/sizeof(tables[0]); i++) {
for (i = 0; i < ARRAY_SIZE(tables); i++) {
const OT_ScriptList *scriptlist;
const GPOS_GSUB_Header *header;
const OT_Script *script;