gdi32: Use the ARRAY_SIZE() macro.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2018-10-05 21:35:35 +02:00 committed by Alexandre Julliard
parent 02b7f00a11
commit fb7a8d92fd
11 changed files with 46 additions and 47 deletions

View file

@ -1627,7 +1627,7 @@ NTSTATUS WINAPI D3DKMTCreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc )
if (!desc->pMemory) return STATUS_INVALID_PARAMETER;
for (i = 0; i < sizeof(format_info) / sizeof(*format_info); ++i)
for (i = 0; i < ARRAY_SIZE( format_info ); ++i)
{
if (format_info[i].format == desc->Format)
{

View file

@ -281,7 +281,7 @@ int get_clipped_rects( const dib_info *dib, const RECT *rc, HRGN clip, struct cl
if (region->rects[i].top >= rect.bottom) break;
if (!intersect_rect( out, &rect, &region->rects[i] )) continue;
out++;
if (out == &clip_rects->buffer[sizeof(clip_rects->buffer) / sizeof(RECT)])
if (out == &clip_rects->buffer[ARRAY_SIZE( clip_rects->buffer )])
{
clip_rects->rects = HeapAlloc( GetProcessHeap(), 0, region->numRects * sizeof(RECT) );
if (!clip_rects->rects) return 0;

View file

@ -759,7 +759,7 @@ static struct cached_glyph *cache_glyph_bitmap( DC *dc, struct cached_font *font
if (flags & ETO_GLYPH_INDEX) ggo_flags |= GGO_GLYPH_INDEX;
indices[0] = index;
for (i = 0; i < sizeof(indices) / sizeof(indices[0]); i++)
for (i = 0; i < ARRAY_SIZE( indices ); i++)
{
index = indices[i];
ret = GetGlyphOutlineW( dc->hSelf, index, ggo_flags, &metrics, 0, NULL, &identity );
@ -1260,7 +1260,7 @@ BOOL dibdrv_PolyPolygon( PHYSDEV dev, const POINT *pt, const INT *counts, DWORD
total += counts[i];
}
if (total > sizeof(pt_buf) / sizeof(pt_buf[0]))
if (total > ARRAY_SIZE( pt_buf ))
{
points = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*pt) );
if (!points) return FALSE;
@ -1330,7 +1330,7 @@ BOOL dibdrv_PolyPolyline( PHYSDEV dev, const POINT* pt, const DWORD* counts, DWO
total += counts[i];
}
if (total > sizeof(pt_buf) / sizeof(pt_buf[0]))
if (total > ARRAY_SIZE( pt_buf ))
{
points = HeapAlloc( GetProcessHeap(), 0, total * sizeof(*pt) );
if (!points) return FALSE;

View file

@ -125,7 +125,7 @@ static BOOL init_opengl(void)
LOAD_FUNCPTR(OSMesaPixelStore);
#undef LOAD_FUNCPTR
for (i = 0; i < sizeof(opengl_func_names)/sizeof(opengl_func_names[0]); i++)
for (i = 0; i < ARRAY_SIZE( opengl_func_names ); i++)
{
if (!(((void **)&opengl_funcs.gl)[i] = pOSMesaGetProcAddress( opengl_func_names[i] )))
{

View file

@ -2393,7 +2393,7 @@ static void convert_to_8888(dib_info *dst, const dib_info *src, const RECT *src_
BYTE *src_start = get_pixel_ptr_8(src, src_rect->left, src_rect->top), *src_pixel;
DWORD dst_colors[256], i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = color_table[i].rgbRed << 16 | color_table[i].rgbGreen << 8 |
color_table[i].rgbBlue;
@ -2417,7 +2417,7 @@ static void convert_to_8888(dib_info *dst, const dib_info *src, const RECT *src_
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
DWORD dst_colors[16], i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = color_table[i].rgbRed << 16 | color_table[i].rgbGreen << 8 |
color_table[i].rgbBlue;
@ -2445,7 +2445,7 @@ static void convert_to_8888(dib_info *dst, const dib_info *src, const RECT *src_
BYTE *src_start = get_pixel_ptr_1(src, src_rect->left, src_rect->top);
DWORD dst_colors[2], i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = color_table[i].rgbRed << 16 | color_table[i].rgbGreen << 8 |
color_table[i].rgbBlue;
@ -2660,7 +2660,7 @@ static void convert_to_32(dib_info *dst, const dib_info *src, const RECT *src_re
BYTE *src_start = get_pixel_ptr_8(src, src_rect->left, src_rect->top), *src_pixel;
DWORD dst_colors[256], i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -2683,7 +2683,7 @@ static void convert_to_32(dib_info *dst, const dib_info *src, const RECT *src_re
BYTE *src_start = get_pixel_ptr_4(src, src_rect->left, src_rect->top), *src_pixel;
DWORD dst_colors[16], i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -2710,7 +2710,7 @@ static void convert_to_32(dib_info *dst, const dib_info *src, const RECT *src_re
BYTE *src_start = get_pixel_ptr_1(src, src_rect->left, src_rect->top);
DWORD dst_colors[2], i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -3151,7 +3151,7 @@ static void convert_to_555(dib_info *dst, const dib_info *src, const RECT *src_r
WORD dst_colors[256];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = ((color_table[i].rgbRed << 7) & 0x7c00) |
((color_table[i].rgbGreen << 2) & 0x03e0) |
((color_table[i].rgbBlue >> 3) & 0x001f);
@ -3177,7 +3177,7 @@ static void convert_to_555(dib_info *dst, const dib_info *src, const RECT *src_r
WORD dst_colors[16];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = ((color_table[i].rgbRed << 7) & 0x7c00) |
((color_table[i].rgbGreen << 2) & 0x03e0) |
((color_table[i].rgbBlue >> 3) & 0x001f);
@ -3207,7 +3207,7 @@ static void convert_to_555(dib_info *dst, const dib_info *src, const RECT *src_r
WORD dst_colors[2];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = ((color_table[i].rgbRed << 7) & 0x7c00) |
((color_table[i].rgbGreen << 2) & 0x03e0) |
((color_table[i].rgbBlue >> 3) & 0x001f);
@ -3425,7 +3425,7 @@ static void convert_to_16(dib_info *dst, const dib_info *src, const RECT *src_re
WORD dst_colors[256];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -3449,7 +3449,7 @@ static void convert_to_16(dib_info *dst, const dib_info *src, const RECT *src_re
WORD dst_colors[16];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -3477,7 +3477,7 @@ static void convert_to_16(dib_info *dst, const dib_info *src, const RECT *src_re
WORD dst_colors[2];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -3710,7 +3710,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
BYTE dst_colors[256];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_colortable(dst, color_table[i]);
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -3735,7 +3735,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
BYTE dst_colors[16];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_colortable(dst, color_table[i]);
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -3763,7 +3763,7 @@ static void convert_to_8(dib_info *dst, const dib_info *src, const RECT *src_rec
BYTE dst_colors[2];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = FILTER_DIBINDEX(color_table[i], rgbquad_to_pixel_colortable(dst, color_table[i]));
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -4055,7 +4055,7 @@ static void convert_to_4(dib_info *dst, const dib_info *src, const RECT *src_rec
BYTE dst_colors[256];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_colortable(dst, color_table[i]);
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -4109,7 +4109,7 @@ static void convert_to_4(dib_info *dst, const dib_info *src, const RECT *src_rec
BYTE dst_colors[16];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_colortable(dst, color_table[i]);
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -4150,7 +4150,7 @@ static void convert_to_4(dib_info *dst, const dib_info *src, const RECT *src_rec
BYTE dst_colors[2];
int i;
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = FILTER_DIBINDEX(color_table[i], rgbquad_to_pixel_colortable(dst, color_table[i]));
for(y = src_rect->top; y < src_rect->bottom; y++)
@ -5394,7 +5394,7 @@ static void mask_rect_32( const dib_info *dst, const RECT *rc,
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
/* Creating a BYTE-sized table so we don't need to mask the lsb of bit_val */
for (i = 2; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 2; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = dst_colors[i & 1];
/* Special case starting and finishing in same byte, neither on byte boundary */
@ -5731,12 +5731,12 @@ static void mask_rect_16( const dib_info *dst, const RECT *rc,
get_rop_codes( rop2, &codes );
if (dst->funcs == &funcs_555)
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = ((color_table[i].rgbRed << 7) & 0x7c00) |
((color_table[i].rgbGreen << 2) & 0x03e0) |
((color_table[i].rgbBlue >> 3) & 0x001f);
else
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = rgbquad_to_pixel_masks(dst, color_table[i]);
/* Special case starting and finishing in same byte, neither on byte boundary */
@ -5872,7 +5872,7 @@ static void mask_rect_8( const dib_info *dst, const RECT *rc,
get_rop_codes( rop2, &codes );
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
dst_colors[i] = FILTER_DIBINDEX(color_table[i], rgbquad_to_pixel_colortable(dst, color_table[i]));
/* Special case starting and finishing in same byte, neither on byte boundary */
@ -6010,7 +6010,7 @@ static void mask_rect_4( const dib_info *dst, const RECT *rc,
get_rop_codes( rop2, &codes );
for (i = 0; i < sizeof(dst_colors) / sizeof(dst_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE(dst_colors); i++)
{
dst_colors[i] = FILTER_DIBINDEX(color_table[i],rgbquad_to_pixel_colortable(dst, color_table[i]));
/* Set high nibble to match so we don't need to shift it later. */

View file

@ -189,7 +189,7 @@ X(EMR_CREATECOLORSPACEW)
static const char *get_emr_name(DWORD type)
{
unsigned int i;
for(i = 0; i < sizeof(emr_names) / sizeof(emr_names[0]); i++)
for(i = 0; i < ARRAY_SIZE(emr_names); i++)
if(type == emr_names[i].type) return emr_names[i].name;
TRACE("Unknown record type %d\n", type);
return NULL;

View file

@ -510,7 +510,7 @@ INT EMFDRV_GetDeviceCaps(PHYSDEV dev, INT cap)
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
if (cap >= 0 && cap < sizeof(physDev->dev_caps) / sizeof(physDev->dev_caps[0]))
if (cap >= 0 && cap < ARRAY_SIZE( physDev->dev_caps ))
return physDev->dev_caps[cap];
return 0;
}

View file

@ -378,7 +378,7 @@ HDC WINAPI CreateEnhMetaFileW(
ref_dc = CreateDCW( displayW, NULL, NULL, NULL );
memset( physDev->dev_caps, 0, sizeof(physDev->dev_caps) );
for (cap = 0; cap < sizeof(physDev->dev_caps) / sizeof(physDev->dev_caps[0]); cap++)
for (cap = 0; cap < ARRAY_SIZE( physDev->dev_caps ); cap++)
if (devcap_is_valid( cap ))
physDev->dev_caps[cap] = GetDeviceCaps( ref_dc, cap );

View file

@ -618,8 +618,7 @@ HFONT WINAPI CreateFontW( INT height, INT width, INT esc,
logfont.lfPitchAndFamily = pitch;
if (name)
lstrcpynW(logfont.lfFaceName, name,
sizeof(logfont.lfFaceName) / sizeof(WCHAR));
lstrcpynW(logfont.lfFaceName, name, ARRAY_SIZE(logfont.lfFaceName));
else
logfont.lfFaceName[0] = '\0';
@ -1829,7 +1828,7 @@ static DWORD get_glyph_bitmap( HDC hdc, UINT index, UINT flags, UINT aa_flags,
indices[0] = index;
if (flags & ETO_GLYPH_INDEX) aa_flags |= GGO_GLYPH_INDEX;
for (i = 0; i < sizeof(indices) / sizeof(indices[0]); i++)
for (i = 0; i < ARRAY_SIZE( indices ); i++)
{
index = indices[i];
ret = GetGlyphOutlineW( hdc, index, aa_flags, metrics, 0, NULL, &identity );

View file

@ -1385,7 +1385,7 @@ static int match_name_table_language( const FT_SfntName *name, LANGID lang )
break;
case TT_PLATFORM_MACINTOSH:
if (!IsValidCodePage( get_mac_code_page( name ))) return 0;
if (name->language_id >= sizeof(mac_langid_table)/sizeof(mac_langid_table[0])) return 0;
if (name->language_id >= ARRAY_SIZE( mac_langid_table )) return 0;
name_lang = mac_langid_table[name->language_id];
break;
case TT_PLATFORM_APPLE_UNICODE:
@ -1395,7 +1395,7 @@ static int match_name_table_language( const FT_SfntName *name, LANGID lang )
case TT_APPLE_ID_DEFAULT:
case TT_APPLE_ID_ISO_10646:
case TT_APPLE_ID_UNICODE_2_0:
if (name->language_id >= sizeof(mac_langid_table)/sizeof(mac_langid_table[0])) return 0;
if (name->language_id >= ARRAY_SIZE( mac_langid_table )) return 0;
name_lang = mac_langid_table[name->language_id];
break;
default:
@ -2648,14 +2648,14 @@ static BOOL init_system_links(void)
goto skip_internal;
}
for (i = 0; i < sizeof(font_links_defaults_list)/sizeof(font_links_defaults_list[0]); i++)
for (i = 0; i < ARRAY_SIZE(font_links_defaults_list); i++)
{
const FontSubst *psub2;
psub2 = get_font_subst(&font_subst_list, font_links_defaults_list[i].shelldlg, -1);
if ((!strcmpiW(font_links_defaults_list[i].shelldlg, psub->to.name) || (psub2 && !strcmpiW(psub2->to.name,psub->to.name))))
{
for (j = 0; j < sizeof(font_links_list)/sizeof(font_links_list[0]); j++)
for (j = 0; j < ARRAY_SIZE(font_links_list); j++)
populate_system_links(font_links_list[j], font_links_defaults_list[i].substitutes);
if (!strcmpiW(psub->to.name, font_links_defaults_list[i].substitutes[0]))
@ -3052,7 +3052,7 @@ static char *get_winfonts_dir_path(LPCWSTR file)
static const WCHAR slashW[] = {'\\','\0'};
WCHAR windowsdir[MAX_PATH];
GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
GetWindowsDirectoryW(windowsdir, ARRAY_SIZE(windowsdir));
strcatW(windowsdir, fontsW);
strcatW(windowsdir, slashW);
strcatW(windowsdir, file);
@ -3069,7 +3069,7 @@ static void load_system_fonts(void)
char *unixname;
if(RegOpenKeyW(HKEY_CURRENT_CONFIG, system_fonts_reg_key, &hkey) == ERROR_SUCCESS) {
GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
GetWindowsDirectoryW(windowsdir, ARRAY_SIZE(windowsdir));
strcatW(windowsdir, fontsW);
for(value = SystemFontValues; *value; value++) {
dlen = sizeof(data);
@ -3138,7 +3138,7 @@ static void update_reg_entries(void)
len = strlenW(name) + 1;
if (face->scalable)
len += sizeof(TrueType) / sizeof(WCHAR);
len += ARRAY_SIZE(TrueType);
valueW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
strcpyW(valueW, name);
@ -4025,7 +4025,7 @@ static void update_font_info(void)
RegSetValueExW(hkey, logpixels, 0, REG_DWORD, (const BYTE *)&screen_dpi, sizeof(screen_dpi));
RegCloseKey(hkey);
for (i = 0; i < sizeof(nls_update_font_list)/sizeof(nls_update_font_list[0]); i++)
for (i = 0; i < ARRAY_SIZE(nls_update_font_list); i++)
{
HKEY hkey;
@ -4186,7 +4186,7 @@ static void init_font_list(void)
load_system_fonts();
/* load in the fonts from %WINDOWSDIR%\\Fonts first of all */
GetWindowsDirectoryW(windowsdir, sizeof(windowsdir) / sizeof(WCHAR));
GetWindowsDirectoryW(windowsdir, ARRAY_SIZE(windowsdir));
strcatW(windowsdir, fontsW);
if((unixname = wine_get_unix_file_name(windowsdir)))
{

View file

@ -503,7 +503,7 @@ static const struct DefaultFontInfo* get_default_fonts(UINT charset)
{
unsigned int n;
for(n=0;n<(sizeof(default_fonts)/sizeof(default_fonts[0]));n++)
for(n = 0; n < ARRAY_SIZE( default_fonts ); n++)
{
if ( default_fonts[n].charset == charset )
return &default_fonts[n];
@ -1285,7 +1285,7 @@ INT WINAPI EnumObjects( HDC hdc, INT nObjType,
{
case OBJ_PEN:
/* Enumerate solid pens */
for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE( solid_colors ); i++)
{
pen.lopnStyle = PS_SOLID;
pen.lopnWidth.x = 1;
@ -1300,7 +1300,7 @@ INT WINAPI EnumObjects( HDC hdc, INT nObjType,
case OBJ_BRUSH:
/* Enumerate solid brushes */
for (i = 0; i < sizeof(solid_colors)/sizeof(solid_colors[0]); i++)
for (i = 0; i < ARRAY_SIZE( solid_colors ); i++)
{
brush.lbStyle = BS_SOLID;
brush.lbColor = solid_colors[i];