Commit d94de38f authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

winemac.drv: Use the ARRAY_SIZE() macro.

parent d744f367
......@@ -280,7 +280,7 @@ static WINE_CLIPFORMAT *insert_clipboard_format(UINT id, CFStringRef type)
{
WCHAR buffer[256];
if (!GetClipboardFormatNameW(format->format_id, buffer, sizeof(buffer) / sizeof(buffer[0])))
if (!GetClipboardFormatNameW(format->format_id, buffer, ARRAY_SIZE(buffer)))
{
WARN("failed to get name for format %s; error 0x%08x\n", debugstr_format(format->format_id), GetLastError());
HeapFree(GetProcessHeap(), 0, format);
......@@ -347,7 +347,7 @@ static void register_builtin_formats(void)
WINE_CLIPFORMAT *format;
/* Register built-in formats */
for (i = 0; i < sizeof(builtin_format_ids)/sizeof(builtin_format_ids[0]); i++)
for (i = 0; i < ARRAY_SIZE(builtin_format_ids); i++)
{
if (!(format = HeapAlloc(GetProcessHeap(), 0, sizeof(*format)))) break;
format->format_id = builtin_format_ids[i].id;
......@@ -360,7 +360,7 @@ static void register_builtin_formats(void)
}
/* Register known mappings between Windows formats and Mac types */
for (i = 0; i < sizeof(builtin_format_names)/sizeof(builtin_format_names[0]); i++)
for (i = 0; i < ARRAY_SIZE(builtin_format_names); i++)
{
if (!(format = HeapAlloc(GetProcessHeap(), 0, sizeof(*format)))) break;
format->format_id = RegisterClipboardFormatW(builtin_format_names[i].name);
......@@ -1841,12 +1841,12 @@ static LRESULT CALLBACK clipboard_wndproc(HWND hwnd, UINT msg, WPARAM wp, LPARAM
static BOOL wait_clipboard_mutex(void)
{
static const WCHAR prefix[] = {'_','_','w','i','n','e','_','c','l','i','p','b','o','a','r','d','_'};
WCHAR buffer[MAX_PATH + sizeof(prefix) / sizeof(WCHAR)];
WCHAR buffer[MAX_PATH + ARRAY_SIZE(prefix)];
HANDLE mutex;
memcpy(buffer, prefix, sizeof(prefix));
if (!GetUserObjectInformationW(GetProcessWindowStation(), UOI_NAME,
buffer + sizeof(prefix) / sizeof(WCHAR),
buffer + ARRAY_SIZE(prefix),
sizeof(buffer) - sizeof(prefix), NULL))
{
ERR("failed to get winstation name\n");
......@@ -1873,7 +1873,7 @@ static BOOL CALLBACK init_pipe_name(INIT_ONCE* once, void* param, void** context
memcpy(clipboard_pipe_name, prefix, sizeof(prefix));
if (!GetUserObjectInformationW(GetProcessWindowStation(), UOI_NAME,
clipboard_pipe_name + sizeof(prefix) / sizeof(WCHAR),
clipboard_pipe_name + ARRAY_SIZE(prefix),
sizeof(clipboard_pipe_name) - sizeof(prefix), NULL))
{
ERR("failed to get winstation name\n");
......
......@@ -519,7 +519,7 @@ static CFDictionaryRef create_mode_dict(CGDisplayModeRef display_mode, BOOL is_o
CFSTR("pixel_encoding"),
CFSTR("refresh_rate"),
};
const void* values[sizeof(keys) / sizeof(keys[0])] = {
const void* values[ARRAY_SIZE(keys)] = {
cf_io_flags,
cf_width,
cf_height,
......@@ -527,7 +527,7 @@ static CFDictionaryRef create_mode_dict(CGDisplayModeRef display_mode, BOOL is_o
cf_refresh,
};
ret = CFDictionaryCreate(NULL, (const void**)keys, (const void**)values, sizeof(keys) / sizeof(keys[0]),
ret = CFDictionaryCreate(NULL, (const void**)keys, (const void**)values, ARRAY_SIZE(keys),
&kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
}
......@@ -1182,7 +1182,7 @@ BOOL macdrv_GetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp)
struct macdrv_display *displays;
int num_displays;
uint32_t mac_entries;
int win_entries = sizeof(r->red) / sizeof(r->red[0]);
int win_entries = ARRAY_SIZE(r->red);
CGGammaValue *red, *green, *blue;
CGError err;
int win_entry;
......@@ -1316,7 +1316,7 @@ BOOL macdrv_SetDeviceGammaRamp(PHYSDEV dev, LPVOID ramp)
DDGAMMARAMP *r = ramp;
struct macdrv_display *displays;
int num_displays;
int win_entries = sizeof(r->red) / sizeof(r->red[0]);
int win_entries = ARRAY_SIZE(r->red);
CGGammaValue *red, *green, *blue;
int i;
CGError err = kCGErrorFailure;
......
......@@ -72,8 +72,7 @@ static void compute_desktop_rect(void)
uint32_t count, i;
desktop_rect = CGRectNull;
if (CGGetActiveDisplayList(sizeof(displayIDs)/sizeof(displayIDs[0]),
displayIDs, &count) != kCGErrorSuccess ||
if (CGGetActiveDisplayList(ARRAY_SIZE(displayIDs), displayIDs, &count) != kCGErrorSuccess ||
!count)
{
displayIDs[0] = CGMainDisplayID();
......
......@@ -90,7 +90,7 @@ const char* debugstr_cf(CFTypeRef t)
if (!ret)
{
UniChar buf[200];
int len = min(CFStringGetLength(s), sizeof(buf)/sizeof(buf[0]));
int len = min(CFStringGetLength(s), ARRAY_SIZE(buf));
CFStringGetCharacters(s, CFRangeMake(0, len), buf);
ret = debugstr_wn(buf, len);
}
......@@ -242,7 +242,7 @@ static void load_strings(HINSTANCE instance)
return;
}
for (i = 0; i < sizeof(ids) / sizeof(ids[0]); i++)
for (i = 0; i < ARRAY_SIZE(ids); i++)
{
LPCWSTR str;
int len = LoadStringW(instance, ids[i], (LPWSTR)&str, 0);
......
......@@ -225,7 +225,7 @@ CFStringRef copy_system_cursor_name(ICONINFOEXW *info)
}
/* Make sure it's one of the appropriate NSCursor class methods. */
for (i = 0; i < sizeof(cocoa_cursor_names) / sizeof(cocoa_cursor_names[0]); i++)
for (i = 0; i < ARRAY_SIZE(cocoa_cursor_names); i++)
if (CFEqual(cursor_name, cocoa_cursor_names[i]))
goto done;
......@@ -238,9 +238,9 @@ CFStringRef copy_system_cursor_name(ICONINFOEXW *info)
if (info->szResName[0]) goto done; /* only integer resources are supported here */
if (!(module = GetModuleHandleW(info->szModName))) goto done;
for (i = 0; i < sizeof(module_cursors)/sizeof(module_cursors[0]); i++)
for (i = 0; i < ARRAY_SIZE(module_cursors); i++)
if (GetModuleHandleW(module_cursors[i].name) == module) break;
if (i == sizeof(module_cursors)/sizeof(module_cursors[0])) goto done;
if (i == ARRAY_SIZE(module_cursors)) goto done;
cursors = module_cursors[i].cursors;
for (i = 0; cursors[i].id; i++)
......@@ -276,7 +276,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
CGPoint hot_spot;
CFDictionaryRef hot_spot_dict;
const CFStringRef keys[] = { CFSTR("image"), CFSTR("hotSpot") };
CFTypeRef values[sizeof(keys) / sizeof(keys[0])];
CFTypeRef values[ARRAY_SIZE(keys)];
CFDictionaryRef frame;
CFArrayRef frames;
......@@ -444,7 +444,7 @@ CFArrayRef create_monochrome_cursor(HDC hdc, const ICONINFOEXW *icon, int width,
values[0] = cgmasked;
values[1] = hot_spot_dict;
frame = CFDictionaryCreate(NULL, (const void**)keys, values, sizeof(keys) / sizeof(keys[0]),
frame = CFDictionaryCreate(NULL, (const void**)keys, values, ARRAY_SIZE(keys),
&kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFRelease(hot_spot_dict);
......
......@@ -328,7 +328,7 @@ static const char* debugstr_attrib(int attrib, int value)
const char *attrib_name = NULL;
const char *value_name = NULL;
for (i = 0; i < sizeof(attrib_names) / sizeof(attrib_names[0]); i++)
for (i = 0; i < ARRAY_SIZE(attrib_names); i++)
{
if (attrib_names[i].attrib == attrib)
{
......@@ -386,7 +386,7 @@ static CGOpenGLDisplayMask active_displays_mask(void)
uint32_t count, i;
CGOpenGLDisplayMask mask;
err = CGGetActiveDisplayList(sizeof(displays) / sizeof(displays[0]), displays, &count);
err = CGGetActiveDisplayList(ARRAY_SIZE(displays), displays, &count);
if (err != kCGErrorSuccess)
{
displays[0] = CGMainDisplayID();
......@@ -473,7 +473,7 @@ static void dump_renderer(const renderer_properties* renderer)
TRACE(" Double buffer: %s\n", (renderer->buffer_modes & kCGLDoubleBufferBit) ? "YES" : "NO");
TRACE("Color buffer modes:\n");
for (i = 0; i < sizeof(color_modes)/sizeof(color_modes[0]); i++)
for (i = 0; i < ARRAY_SIZE(color_modes); i++)
{
if (renderer->color_modes & color_modes[i].mode)
{
......@@ -485,7 +485,7 @@ static void dump_renderer(const renderer_properties* renderer)
}
TRACE("Accumulation buffer sizes: { ");
for (i = 0; i < sizeof(color_modes)/sizeof(color_modes[0]); i++)
for (i = 0; i < ARRAY_SIZE(color_modes); i++)
{
if (renderer->accum_modes & color_modes[i].mode)
TRACE("%d, ", color_modes[i].color_bits);
......@@ -493,7 +493,7 @@ static void dump_renderer(const renderer_properties* renderer)
TRACE("}\n");
TRACE("Depth buffer sizes: { ");
for (i = 0; i < sizeof(depth_stencil_modes)/sizeof(depth_stencil_modes[0]); i++)
for (i = 0; i < ARRAY_SIZE(depth_stencil_modes); i++)
{
if (renderer->depth_modes & depth_stencil_modes[i].mode)
TRACE("%d, ", depth_stencil_modes[i].bits);
......@@ -501,7 +501,7 @@ static void dump_renderer(const renderer_properties* renderer)
TRACE("}\n");
TRACE("Stencil buffer sizes: { ");
for (i = 0; i < sizeof(depth_stencil_modes)/sizeof(depth_stencil_modes[0]); i++)
for (i = 0; i < ARRAY_SIZE(depth_stencil_modes); i++)
{
if (renderer->stencil_modes & depth_stencil_modes[i].mode)
TRACE("%d, ", depth_stencil_modes[i].bits);
......@@ -565,7 +565,7 @@ static unsigned int best_color_mode(GLint modes, GLint color_size, GLint alpha_s
int best = -1;
int i;
for (i = 0; i < sizeof(color_modes)/sizeof(color_modes[0]); i++)
for (i = 0; i < ARRAY_SIZE(color_modes); i++)
{
if ((modes & color_modes[i].mode) &&
color_modes[i].color_bits >= color_size &&
......@@ -593,7 +593,7 @@ static unsigned int best_color_mode(GLint modes, GLint color_size, GLint alpha_s
if (best < 0)
{
/* Couldn't find a match. Return first one that renderer supports. */
for (i = 0; i < sizeof(color_modes)/sizeof(color_modes[0]); i++)
for (i = 0; i < ARRAY_SIZE(color_modes); i++)
{
if (modes & color_modes[i].mode)
return i;
......@@ -609,7 +609,7 @@ static unsigned int best_accum_mode(GLint modes, GLint accum_size)
int best = -1;
int i;
for (i = 0; i < sizeof(color_modes)/sizeof(color_modes[0]); i++)
for (i = 0; i < ARRAY_SIZE(color_modes); i++)
{
if ((modes & color_modes[i].mode) && color_modes[i].color_bits >= accum_size)
{
......@@ -633,7 +633,7 @@ static unsigned int best_accum_mode(GLint modes, GLint accum_size)
if (best < 0)
{
/* Couldn't find a match. Return last one that renderer supports. */
for (i = sizeof(color_modes)/sizeof(color_modes[0]) - 1; i >= 0; i--)
for (i = ARRAY_SIZE(color_modes) - 1; i >= 0; i--)
{
if (modes & color_modes[i].mode)
return i;
......@@ -701,7 +701,7 @@ static void enum_renderer_pixel_formats(renderer_properties renderer, CFMutableA
request.aux_buffers = aux;
n_stack[++n_stack_idx] = n;
for (color_mode = 0; color_mode < sizeof(color_modes)/sizeof(color_modes[0]); color_mode++)
for (color_mode = 0; color_mode < ARRAY_SIZE(color_modes); color_mode++)
{
unsigned int depth_mode;
......@@ -719,7 +719,7 @@ static void enum_renderer_pixel_formats(renderer_properties renderer, CFMutableA
request.color_mode = color_mode;
n_stack[++n_stack_idx] = n;
for (depth_mode = 0; depth_mode < sizeof(depth_stencil_modes)/sizeof(depth_stencil_modes[0]); depth_mode++)
for (depth_mode = 0; depth_mode < ARRAY_SIZE(depth_stencil_modes); depth_mode++)
{
unsigned int stencil_mode;
......@@ -733,7 +733,7 @@ static void enum_renderer_pixel_formats(renderer_properties renderer, CFMutableA
request.depth_bits = depth_stencil_modes[depth_mode].bits;
n_stack[++n_stack_idx] = n;
for (stencil_mode = 0; stencil_mode < sizeof(depth_stencil_modes)/sizeof(depth_stencil_modes[0]); stencil_mode++)
for (stencil_mode = 0; stencil_mode < ARRAY_SIZE(depth_stencil_modes); stencil_mode++)
{
unsigned int stereo;
......@@ -767,7 +767,7 @@ static void enum_renderer_pixel_formats(renderer_properties renderer, CFMutableA
/* Starts at -1 for a 0 accum size */
n_stack[++n_stack_idx] = n;
for (accum_mode = -1; accum_mode < (int)(sizeof(color_modes)/sizeof(color_modes[0])); accum_mode++)
for (accum_mode = -1; accum_mode < (int) ARRAY_SIZE(color_modes); accum_mode++)
{
unsigned int target_pass;
......@@ -4265,7 +4265,7 @@ static BOOL init_opengl(void)
return FALSE;
}
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] = wine_dlsym(opengl_handle, opengl_func_names[i], NULL, 0)))
{
......
......@@ -147,7 +147,7 @@ static BOOL modify_icon(struct tray_icon *icon, NOTIFYICONDATAW *nid)
}
if (nid->uFlags & NIF_TIP)
{
lstrcpynW(icon->tiptext, nid->szTip, sizeof(icon->tiptext)/sizeof(WCHAR));
lstrcpynW(icon->tiptext, nid->szTip, ARRAY_SIZE(icon->tiptext));
if (icon->status_item)
update_tooltip = TRUE;
}
......
......@@ -710,7 +710,7 @@ static void create_cocoa_window(struct macdrv_win_data *data)
set_cocoa_window_properties(data);
/* set the window text */
if (!InternalGetWindowText(data->hwnd, text, sizeof(text)/sizeof(WCHAR))) text[0] = 0;
if (!InternalGetWindowText(data->hwnd, text, ARRAY_SIZE(text))) text[0] = 0;
macdrv_set_cocoa_window_title(data->cocoa_window, text, strlenW(text));
/* set the window region */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment