Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/gdiplus/brush.c | 2 +- dlls/gdiplus/font.c | 4 ++-- dlls/gdiplus/gdiplus_private.h | 2 ++ dlls/gdiplus/image.c | 6 +++--- dlls/gdiplus/metafile.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c index 0114a510ca..3aeb654086 100644 --- a/dlls/gdiplus/brush.c +++ b/dlls/gdiplus/brush.c @@ -232,7 +232,7 @@ static const char HatchBrushes[][8] = {
GpStatus get_hatch_data(GpHatchStyle hatchstyle, const char **result) { - if (hatchstyle < sizeof(HatchBrushes) / sizeof(HatchBrushes[0])) + if (hatchstyle < ARRAY_SIZE(HatchBrushes)) { *result = HatchBrushes[hatchstyle]; return Ok; diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index f99b026b25..64778bb226 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -1367,7 +1367,7 @@ static int match_name_table_language( const tt_name_record *name, LANGID lang ) case TT_PLATFORM_MACINTOSH: if (!IsValidCodePage( get_mac_code_page( name ))) return 0; name_lang = GET_BE_WORD(name->language_id); - if (name_lang >= sizeof(mac_langid_table)/sizeof(mac_langid_table[0])) return 0; + if (name_lang >= ARRAY_SIZE(mac_langid_table)) return 0; name_lang = mac_langid_table[name_lang]; break; case TT_PLATFORM_APPLE_UNICODE: @@ -1377,7 +1377,7 @@ static int match_name_table_language( const tt_name_record *name, LANGID lang ) case TT_APPLE_ID_ISO_10646: case TT_APPLE_ID_UNICODE_2_0: name_lang = GET_BE_WORD(name->language_id); - if (name_lang >= sizeof(mac_langid_table)/sizeof(mac_langid_table[0])) return 0; + if (name_lang >= ARRAY_SIZE(mac_langid_table)) return 0; name_lang = mac_langid_table[name_lang]; break; default: diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index ea79f1183c..9fff578a28 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -35,6 +35,8 @@
#include "gdiplus.h"
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) + #define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER) #define MAX_ARC_PTS (13) #define MAX_DASHLEN (16) /* this is a limitation of gdi */ diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index b03630c55c..9841857e63 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -2554,7 +2554,7 @@ static UINT vt_to_itemtype(UINT vt) { VT_BLOB, PropertyTagTypeUndefined } }; UINT i; - for (i = 0; i < sizeof(vt2type)/sizeof(vt2type[0]); i++) + for (i = 0; i < ARRAY_SIZE(vt2type); i++) { if (vt2type[i].vt == vt) return vt2type[i].type; } @@ -3454,10 +3454,10 @@ static void png_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI { if (name.vt == VT_LPSTR) { - for (j=0; j<sizeof(keywords)/sizeof(keywords[0]); j++) + for (j = 0; j < ARRAY_SIZE(keywords); j++) if (!strcmp(keywords[j].name, name.u.pszVal)) break; - if (j < sizeof(keywords)/sizeof(keywords[0]) && !keywords[j].seen) + if (j < ARRAY_SIZE(keywords) && !keywords[j].seen) { keywords[j].seen = TRUE; item = create_prop(keywords[j].propid, &value); diff --git a/dlls/gdiplus/metafile.c b/dlls/gdiplus/metafile.c index 77673a7ea3..08dde2fec6 100644 --- a/dlls/gdiplus/metafile.c +++ b/dlls/gdiplus/metafile.c @@ -606,7 +606,7 @@ void METAFILE_Free(GpMetafile *metafile) if (metafile->record_stream) IStream_Release(metafile->record_stream);
- for (i = 0; i < sizeof(metafile->objtable)/sizeof(metafile->objtable[0]); i++) + for (i = 0; i < ARRAY_SIZE(metafile->objtable); i++) metafile_free_object_table_entry(metafile, i); }