diff --git a/dlls/msvcrt/console.c b/dlls/msvcrt/console.c index 75e95ebcfcc..3a2301ef186 100644 --- a/dlls/msvcrt/console.c +++ b/dlls/msvcrt/console.c @@ -124,7 +124,7 @@ static BOOL handle_enhanced_keys(INPUT_RECORD *ir, unsigned char *ch1, unsigned { int i; - for (i = 0; i < sizeof(enh_map) / sizeof(enh_map[0]); i++) + for (i = 0; i < ARRAY_SIZE(enh_map); i++) { if (ir->Event.KeyEvent.wVirtualScanCode == enh_map[i].vk) { diff --git a/dlls/msvcrt/ctype.c b/dlls/msvcrt/ctype.c index 2c39a566867..758411a7a40 100644 --- a/dlls/msvcrt/ctype.c +++ b/dlls/msvcrt/ctype.c @@ -493,7 +493,7 @@ unsigned short __cdecl wctype(const char *property) }; unsigned int i; - for(i=0; iExceptionRecord->ExceptionCode) diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c index b84c50adbc8..51bc6f07e1b 100644 --- a/dlls/msvcrt/exit.c +++ b/dlls/msvcrt/exit.c @@ -209,8 +209,7 @@ static void DoMessageBoxW(const MSVCRT_wchar_t *lead, const MSVCRT_wchar_t *mess MSVCRT_wchar_t text[2048]; INT ret; - MSVCRT__snwprintf(text, sizeof(text)/sizeof(text[0]), message_format, - lead, MSVCRT__wpgmptr, message); + MSVCRT__snwprintf(text, ARRAY_SIZE(text), message_format, lead, MSVCRT__wpgmptr, message); msgbox.cbSize = sizeof(msgbox); msgbox.hwndOwner = GetActiveWindow(); diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 2c05f25c6a0..224e6eae0c8 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -1223,7 +1223,7 @@ void msvcrt_free_io(void) MSVCRT__flushall(); MSVCRT__fcloseall(); - for(i=0; istr.str)/sizeof(cur->str.str[0]); i++) + for(i=0; istr.str); i++) size += strlen(cur->str.str[i])+1; ret = MSVCRT_malloc(size); @@ -604,7 +604,7 @@ void* CDECL _Gettnames(void) memcpy(ret, cur, size); size = 0; - for(i=0; istr.str)/sizeof(cur->str.str[0]); i++) { + for(i=0; istr.str); i++) { ret->str.str[i] = &ret->data[size]; size += strlen(&ret->data[size])+1; } @@ -1605,7 +1605,7 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category, size = sizeof(MSVCRT___lc_time_data); lcid_tmp = lcid[MSVCRT_LC_TIME] ? lcid[MSVCRT_LC_TIME] : MAKELCID(LANG_ENGLISH, SORT_DEFAULT); - for(i=0; ilc_time_curr->str.str[i] = &locinfo->lc_time_curr->data[ret]; if(time_data[i]==LOCALE_SSHORTDATE && !lcid[MSVCRT_LC_TIME]) { memcpy(&locinfo->lc_time_curr->data[ret], cloc_short_date, sizeof(cloc_short_date)); @@ -1653,7 +1653,7 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category, &locinfo->lc_time_curr->data[ret], size-ret); } } - for(i=0; ilc_time_curr->wstr.wstr[i] = (MSVCRT_wchar_t*)&locinfo->lc_time_curr->data[ret]; if(time_data[i]==LOCALE_SSHORTDATE && !lcid[MSVCRT_LC_TIME]) { memcpy(&locinfo->lc_time_curr->data[ret], cloc_short_dateW, sizeof(cloc_short_dateW)); diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h index ee8120e1493..077dafa5504 100644 --- a/dlls/msvcrt/printf.h +++ b/dlls/msvcrt/printf.h @@ -518,7 +518,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API flags.PadZero = '0'; i = flags.Precision; flags.Precision = 2*sizeof(void*); - FUNC_NAME(pf_integer_conv)(buf, sizeof(buf)/sizeof(APICHAR), &flags, + FUNC_NAME(pf_integer_conv)(buf, ARRAY_SIZE(buf), &flags, (ULONG_PTR)pf_args(args_ctx, pos, VT_PTR, valist).get_ptr); flags.PadZero = 0; flags.Precision = i; @@ -549,7 +549,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API flags.Precision = flags.FieldLength - 2; max_len = (flags.FieldLength>flags.Precision ? flags.FieldLength : flags.Precision) + 10; - if(max_len > sizeof(buf)/sizeof(APICHAR)) + if(max_len > ARRAY_SIZE(buf)) tmp = HeapAlloc(GetProcessHeap(), 0, max_len); if(!tmp) return -1; diff --git a/dlls/msvcrt/process.c b/dlls/msvcrt/process.c index fac3bd4d20a..9a192e7e9b0 100644 --- a/dlls/msvcrt/process.c +++ b/dlls/msvcrt/process.c @@ -345,7 +345,7 @@ static MSVCRT_wchar_t *msvcrt_get_comspec(void) MSVCRT_wchar_t *ret; unsigned int len; - if (!(len = GetEnvironmentVariableW(comspec, NULL, 0))) len = sizeof(cmd)/sizeof(MSVCRT_wchar_t); + if (!(len = GetEnvironmentVariableW(comspec, NULL, 0))) len = ARRAY_SIZE(cmd); if ((ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(MSVCRT_wchar_t)))) { if (!GetEnvironmentVariableW(comspec, ret, len)) strcpyW(ret, cmd); diff --git a/dlls/msvcrt/scheduler.c b/dlls/msvcrt/scheduler.c index c6c0fa7e389..55ab1c549e2 100644 --- a/dlls/msvcrt/scheduler.c +++ b/dlls/msvcrt/scheduler.c @@ -344,7 +344,7 @@ static void ExternalContextBase_dtor(ExternalContextBase *this) int i; /* TODO: move the allocator cache to scheduler so it can be reused */ - for(i=0; iallocator_cache)/sizeof(this->allocator_cache[0]); i++) { + for(i=0; iallocator_cache); i++) { for(cur = this->allocator_cache[i]; cur; cur=next) { next = cur->free.next; MSVCRT_operator_delete(cur); @@ -413,10 +413,10 @@ void * CDECL Concurrency_Alloc(MSVCRT_size_t size) int i; C_ASSERT(sizeof(union allocator_cache_entry) <= 1 << 4); - for(i=0; iallocator_cache)/sizeof(context->allocator_cache[0]); i++) + for(i=0; iallocator_cache); i++) if (1 << (i+4) >= size) break; - if(i==sizeof(context->allocator_cache)/sizeof(context->allocator_cache[0])) { + if(i==ARRAY_SIZE(context->allocator_cache)) { p = MSVCRT_operator_new(size); p->alloc.bucket = -1; }else if (context->allocator_cache[i]) { @@ -446,7 +446,7 @@ void CDECL Concurrency_Free(void* mem) if (context->context.vtable != &MSVCRT_ExternalContextBase_vtable) { MSVCRT_operator_delete(p); }else { - if(bucket >= 0 && bucket < sizeof(context->allocator_cache)/sizeof(context->allocator_cache[0]) && + if(bucket >= 0 && bucket < ARRAY_SIZE(context->allocator_cache) && (!context->allocator_cache[bucket] || context->allocator_cache[bucket]->free.depth < 20)) { p->free.next = context->allocator_cache[bucket]; p->free.depth = p->free.next ? p->free.next->free.depth+1 : 0; diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 098e0d5ba80..ed73fc6163c 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -2109,7 +2109,7 @@ static int wctoint(WCHAR c, int base) 0xd66, 0xe50, 0xed0, 0xf20, 0x1040, 0x17e0, 0x1810, 0xff10 }; int i; - for (i = 0; i < sizeof(zeros)/sizeof(zeros[0]) && c >= zeros[i]; ++i) { + for (i = 0; i < ARRAY_SIZE(zeros) && c >= zeros[i]; ++i) { if (zeros[i] <= c && c <= zeros[i] + 9) { v = c - zeros[i]; break;