Previous 15994 Revisions Next

r6275 Tuesday 3rd November, 2009 at 22:52:43 UTC by Stefano Priore
Replaced (sizeof(foo) / sizeof(foo[0])) with ARRAY_LENGTH(foo)
[src/mess]artworkx.c device.c inputx.c messopts.c mesvalid.c opresolv.c
[src/mess/devices]appldriv.c cassette.c chd_cd.c flopdrv.c harddriv.c
[src/mess/drivers]a2600.c c65.c palm_dbg.c psx.c svision.c
[src/mess/formats]ap2_dsk.c ap_dsk35.c cassimg.c flopimg.c pc_dsk.c
[src/mess/machine]apple2gs.c bebox.c c64.c cbmb.c cbmdrive.c coco.c dgn_beta.c mac.c nes_ines.c nes_unif.c pet.c upd765.c vtech2.c
[src/mess/osd/sdl]glob.c sdlmess.c
[src/mess/osd/windows]dialog.c glob.c menu.c opcntrl.c winmess.c
[src/mess/osd/winui]devview.c messui.c softwarepicker.c
[src/mess/tools]pile.c
[src/mess/tools/imgtool]filtbas.c imgterrs.c imgtool.c main.c modules.c tstsuite.c
[src/mess/tools/imgtool/modules]cococas.c concept.c fat.c mac.c os9.c pc_hard.c prodos.c rsdos.c ti99.c ti990hd.c
[src/mess/tools/imgtool/windows]assoc.c assocdlg.c attrdlg.c hexview.c secview.c wimgtool.c
[src/mess/tools/messdocs]messdocs.c
[src/mess/tools/messtest]core.c testimgt.c testmess.c
[src/mess/video]coco3.c coco6847.c crtc6845.c

src/mess/devices/harddriv.c
r6274r6275
4848
4949static const char *chd_get_error_string(int chderr)
5050{
51   if ((chderr < 0 ) || (chderr >= (sizeof(error_strings) / sizeof(error_strings[0]))))
51   if ((chderr < 0 ) || (chderr >= ARRAY_LENGTH(error_strings)))
5252      return NULL;
5353   return error_strings[chderr];
5454}
src/mess/devices/cassette.c
r6274r6275
359359   /* THE ANIMATION HASN'T WORKED SINCE 0.114 - LEFT HERE FOR REFERENCE */
360360   /* NEVER SEEN THE PLAY / RECORD ICONS */
361361   /* character pairs 2-3, 4-5, 6-7, 8-9 form little tape cassette images */
362   snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%c%c %c %02d:%02d (%04d) [%02d:%02d (%04d)]",
362   snprintf(buf, ARRAY_LENGTH(buf), "%c%c %c %02d:%02d (%04d) [%02d:%02d (%04d)]",
363363      n * 2 + 2,                        /* cassette icon left */
364364      n * 2 + 3,                        /* cassette icon right */
365365      (uistate == CASSETTE_PLAY) ? 16 : 14,   /* play or record icon */
366366#endif
367367   /* Since you can have anything in a BDF file, we will use crude ascii characters instead */
368   snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%c%c %c %02d:%02d (%04d) [%02d:%02d (%04d)]",
368   snprintf(buf, ARRAY_LENGTH(buf), "%c%c %c %02d:%02d (%04d) [%02d:%02d (%04d)]",
369369      shapes[n],               /* cassette icon left */
370370      shapes[n|4],               /* cassette icon right */
371371      (uistate == CASSETTE_PLAY) ? 0x50 : 0x52,   /* play (P) or record (R) */
src/mess/devices/flopdrv.c
r6274r6275
774774   return INIT_PASS;
775775
776776error:
777   for (i = 0; i < sizeof(errmap) / sizeof(errmap[0]); i++)
777   for (i = 0; i < ARRAY_LENGTH(errmap); i++)
778778   {
779779      if (err == errmap[i].ferr)
780780         image_seterror(image, errmap[i].ierr, errmap[i].message);
src/mess/devices/chd_cd.c
r6274r6275
4040
4141static const char *chd_get_error_string(int chderr)
4242{
43   if ((chderr < 0 ) || (chderr >= (sizeof(error_strings) / sizeof(error_strings[0]))))
43   if ((chderr < 0 ) || (chderr >= ARRAY_LENGTH(error_strings)))
4444      return NULL;
4545   return error_strings[chderr];
4646}
src/mess/devices/appldriv.c
r6274r6275
200200   }
201201
202202   disk->position++;
203   disk->position %= (sizeof(disk->track_data) / sizeof(disk->track_data[0]));
203   disk->position %= ARRAY_LENGTH(disk->track_data);
204204
205205   /* when writing; save the current track after every full sector write */
206206   if ((write_value >= 0) && ((disk->position % APPLE2_NIBBLE_SIZE) == 0))
src/mess/opresolv.c
r6274r6275
542542   struct OptionRange ranges[256];
543543   int i;
544544
545   err = option_resolution_listranges(specification, option_char, ranges, sizeof(ranges) / sizeof(ranges[0]));
545   err = option_resolution_listranges(specification, option_char, ranges, ARRAY_LENGTH(ranges));
546546   if (err)
547547      return err;
548548
r6274r6275
578578      "Internal error"                     /* OPTIONRESOLTUION_ERROR_INTERNAL */
579579   };
580580
581   if ((err < 0) || (err >= sizeof(errors) / sizeof(errors[0])))
581   if ((err < 0) || (err >= ARRAY_LENGTH(errors)))
582582      return NULL;
583583   return errors[err];
584584}
src/mess/tools/messdocs/messdocs.c
r6274r6275
117117   char buf[1024];
118118   char *path;
119119
120   snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s", dir);
121   combine_path(buf, sizeof(buf) / sizeof(buf[0]), filepath);
120   snprintf(buf, ARRAY_LENGTH(buf), "%s", dir);
121   combine_path(buf, ARRAY_LENGTH(buf), filepath);
122122
123123   path = malloc(strlen(buf) + 1);
124124   if (!path)
r6274r6275
294294         return;
295295      }
296296
297      snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s", state->dest_dir);
298      combine_path(buf, sizeof(buf) / sizeof(buf[0]), destpath);
297      snprintf(buf, ARRAY_LENGTH(buf), "%s", state->dest_dir);
298      combine_path(buf, ARRAY_LENGTH(buf), destpath);
299299      osd_mkdir(buf);
300300
301301      sysinfo_array = NULL;
r6274r6275
304304
305305      while(!feof(datfile))
306306      {
307         fgets(buf, sizeof(buf) / sizeof(buf[0]), datfile);
307         fgets(buf, ARRAY_LENGTH(buf), datfile);
308308         s = strchr(buf, '\n');
309309         if (s)
310310            *s = '\0';
r6274r6275
352352            if (!sysfile)
353353               break;
354354
355            html_encode(buf, sizeof(buf) / sizeof(buf[0]));
355            html_encode(buf, ARRAY_LENGTH(buf));
356356
357357            if (!strncmp(buf, "======", 6) && lineno == 0)
358358            {
src/mess/tools/messtest/testimgt.c
r6274r6275
334334
335335   for (child_node = xml_get_sibling(node->child, "entry"); child_node; child_node = xml_get_sibling(child_node->next, "entry"))
336336   {
337      if (entry_count >= sizeof(entries) / sizeof(entries[0]))
337      if (entry_count >= ARRAY_LENGTH(entries))
338338      {
339339         report_message(MSG_FAILURE, "Too many directory entries");
340340         return;
r6274r6275
354354   for (i = 0; i < entry_count; i++)
355355   {
356356      append_to_list(expected_listing,
357         sizeof(expected_listing) / sizeof(expected_listing[0]),
357         ARRAY_LENGTH(expected_listing),
358358         entries[i].filename);
359359   }
360360
r6274r6275
379379      if (!ent.eof)
380380      {
381381         append_to_list(actual_listing,
382            sizeof(actual_listing) / sizeof(actual_listing[0]),
382            ARRAY_LENGTH(actual_listing),
383383            ent.filename);
384384
385385         if (i < entry_count && (strcmp(ent.filename, entries[i].filename)))
src/mess/tools/messtest/testmess.c
r6274r6275
216216   if (write_file)
217217   {
218218      /* dump a screenshot */
219      snprintf(buf, sizeof(buf) / sizeof(buf[0]),
219      snprintf(buf, ARRAY_LENGTH(buf),
220220         (screenshot_num >= 0) ? "_%s_%d.png" : "_%s.png",
221221         current_testcase.name, screenshot_num);
222222      filerr = mame_fopen(SEARCHPATH_SCREENSHOT, buf, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &fp);
r6274r6275
280280   char *s;
281281   int pos, nextpos;
282282
283   vsnprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), format, argptr);
283   vsnprintf(buffer, ARRAY_LENGTH(buffer), format, argptr);
284284
285285   pos = 0;
286286   while(buffer[pos] != '\0')
r6274r6275
451451
452452   if (current_testcase.wavwrite)
453453   {
454      snprintf(buf, sizeof(buf) / sizeof(buf[0]), "snap/_%s.wav", current_testcase.name);
454      snprintf(buf, ARRAY_LENGTH(buf), "snap/_%s.wav", current_testcase.name);
455455      wavptr = wav_open(buf, machine->sample_rate, 2);
456456   }
457457   else
r6274r6275
777777   filename = current_command->u.image_args.filename;
778778   if (!filename)
779779   {
780      snprintf(buf, sizeof(buf) / sizeof(buf[0]),   "%s.%s",
780      snprintf(buf, ARRAY_LENGTH(buf),   "%s.%s",
781781         current_testcase.name, file_extensions);
782782      osd_get_temp_filename(buf, ARRAY_LENGTH(buf), buf);
783783      filename = buf;
r6274r6275
951951   for (cpu = cpu_first(machine->config); cpu != NULL; cpu = cpu_next(cpu))
952952   {
953953      if (cpu_next(cpu_first(machine->config)) == NULL)
954         snprintf(filename, sizeof(filename) / sizeof(filename[0]), "_%s.tr", current_testcase.name);
954         snprintf(filename, ARRAY_LENGTH(filename), "_%s.tr", current_testcase.name);
955955      else
956         snprintf(filename, sizeof(filename) / sizeof(filename[0]), "_%s.%d.tr", current_testcase.name, cpunum);
956         snprintf(filename, ARRAY_LENGTH(filename), "_%s.%d.tr", current_testcase.name, cpunum);
957957
958958      file = fopen(filename, "w");
959959      if (file)
r6274r6275
10551055      return;
10561056   }
10571057
1058   for (i = 0; i < sizeof(commands) / sizeof(commands[i]); i++)
1058   for (i = 0; i < ARRAY_LENGTH(commands); i++)
10591059   {
10601060      if (current_command->command_type == commands[i].command_type)
10611061      {
src/mess/tools/messtest/core.c
r6274r6275
6060   va_list va;
6161
6262   va_start(va, fmt);
63   vsnprintf(buf, sizeof(buf) / sizeof(buf[0]), fmt, va);
63   vsnprintf(buf, ARRAY_LENGTH(buf), fmt, va);
6464   va_end(va);
6565
6666   error_report(buf);
r6274r6275
402402
403403      if (c != INPUT_CODE_INVALID)
404404      {
405         snprintf(buf, sizeof(buf) / sizeof(buf[0]), "<%s%s>&#%d;</%s%s>",
405         snprintf(buf, ARRAY_LENGTH(buf), "<%s%s>&#%d;</%s%s>",
406406            mamekey_prefix, context,
407407            UCHAR_MAMEKEY_BEGIN + c,
408408            mamekey_prefix, context);
r6274r6275
413413   }
414414   else if (!strcmp(context, "eoln"))
415415   {
416      snprintf(buf, sizeof(buf) / sizeof(buf[0]), "<eoln>%s</eoln>", EOLN);
416      snprintf(buf, ARRAY_LENGTH(buf), "<eoln>%s</eoln>", EOLN);
417417
418418      if (XML_Parse(extparser, buf, strlen(buf), 0) == XML_STATUS_ERROR)
419419         goto done;
r6274r6275
524524      script_directory = osd_dirname(opts->script_filename);
525525      if (script_directory)
526526      {
527         osd_getcurdir(saved_directory, sizeof(saved_directory) / sizeof(saved_directory[0]));
527         osd_getcurdir(saved_directory, ARRAY_LENGTH(saved_directory));
528528         osd_setcurdir(script_directory);
529529         free(script_directory);
530530      }
r6274r6275
582582   int last_space, base, i;
583583
584584   va_start(va, fmt);
585   vsnprintf(buf, sizeof(buf) / sizeof(buf[0]), fmt, va);
585   vsnprintf(buf, ARRAY_LENGTH(buf), fmt, va);
586586   va_end(va);
587587
588588   prefix1 = current_testcase_name;
src/mess/tools/imgtool/modules.c
r6274r6275
4545   }
4646
4747   /* create all modules */
48   for (i = 0; i < sizeof(modules) / sizeof(modules[0]); i++)
48   for (i = 0; i < ARRAY_LENGTH(modules); i++)
4949      imgtool_library_add(lib, modules[i]);
5050
5151   /* remove irrelevant modules */
src/mess/tools/imgtool/windows/assocdlg.c
r6274r6275
9696         {
9797            style = WS_CHILD | WS_VISIBLE | BS_CHECKBOX | BS_AUTOCHECKBOX;
9898            t_extension = tstring_from_utf8(dlginfo->extensions[i]);
99            _sntprintf(buf, sizeof(buf) / sizeof(buf[0]), TEXT(".%s"), t_extension);
99            _sntprintf(buf, ARRAY_LENGTH(buf), TEXT(".%s"), t_extension);
100100            free(t_extension);
101101
102102            control = CreateWindow(TEXT("BUTTON"), buf, style,
r6274r6275
141141                     is_set = SendMessage(GetDlgItem(dialog, CONTROL_START + i), BM_GETCHECK, 0, 0);
142142
143143                     t_extension = tstring_from_utf8(dlginfo->extensions[i]);
144                     _sntprintf(buf, sizeof(buf) / sizeof(buf[0]), TEXT(".%s"), t_extension);
144                     _sntprintf(buf, ARRAY_LENGTH(buf), TEXT(".%s"), t_extension);
145145                     free(t_extension);
146146                     currently_set = win_is_extension_associated(&assoc_info, buf);
147147
src/mess/tools/imgtool/windows/attrdlg.c
r6274r6275
7575      for (i = 0; guide[i].option_type != OPTIONTYPE_END; i++)
7676      {
7777         // set up label control
78         snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s:", guide[i].display_name);
78         snprintf(buf, ARRAY_LENGTH(buf), "%s:", guide[i].display_name);
7979         control = win_create_window_ex_utf8(0, "STATIC", buf, WS_CHILD | WS_VISIBLE,
8080            margin, *y + 2, label_width, control_height, dialog, NULL, NULL, NULL);
8181         SendMessage(control, WM_SETFONT, (WPARAM) font, 0);
src/mess/tools/imgtool/windows/wimgtool.c
r6274r6275
187187   }
188188
189189   if (source)
190      snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%s: %s", source, error_text);
190      snprintf(buffer, ARRAY_LENGTH(buffer), "%s: %s", source, error_text);
191191   else
192192      message = error_text;
193193   win_message_box_utf8(window, message, wimgtool_producttext, MB_OK);
r6274r6275
314314   info = get_wimgtool_info(window);
315315
316316   /* retrieve temporary file path */
317   GetTempPath(sizeof(file_path) / sizeof(file_path[0]), file_path);
317   GetTempPath(ARRAY_LENGTH(file_path), file_path);
318318
319319   if (extension != FOLDER_ICON)
320320   {
r6274r6275
449449
450450   if (entry->directory)
451451   {
452      _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), TEXT("<DIR>"));
452      _sntprintf(buffer, ARRAY_LENGTH(buffer), TEXT("<DIR>"));
453453   }
454454   else
455455   {
456456      // set the file size
457      _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]),
457      _sntprintf(buffer, ARRAY_LENGTH(buffer),
458458         TEXT("%d"), entry->filesize);
459459   }
460460   column_index = 1;
r6274r6275
466466      if (entry->creation_time != 0)
467467      {
468468         local_time = localtime(&entry->creation_time);
469         _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _tasctime(local_time));
469         _sntprintf(buffer, ARRAY_LENGTH(buffer), _tasctime(local_time));
470470         tstring_rtrim(buffer);
471471         ListView_SetItemText(info->listview, new_index, column_index, buffer);
472472      }
r6274r6275
479479      if (entry->lastmodified_time != 0)
480480      {
481481         local_time = localtime(&entry->lastmodified_time);
482         _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _tasctime(local_time));
482         _sntprintf(buffer, ARRAY_LENGTH(buffer), _tasctime(local_time));
483483         tstring_rtrim(buffer);
484484         ListView_SetItemText(info->listview, new_index, column_index, buffer);
485485      }
r6274r6275
577577         err = imgtool_partition_get_free_space(info->partition, &filesize);
578578         if (err)
579579            goto done;
580         snprintf(size_buf, sizeof(size_buf) / sizeof(size_buf[0]), "%u bytes free", (unsigned) filesize);
580         snprintf(size_buf, ARRAY_LENGTH(size_buf), "%u bytes free", (unsigned) filesize);
581581      }
582582
583583   }
r6274r6275
621621   {
622622      // get file title from Windows
623623      t_filename = tstring_from_utf8(info->filename);
624      GetFileTitle(t_filename, file_title_buf, sizeof(file_title_buf) / sizeof(file_title_buf[0]));
624      GetFileTitle(t_filename, file_title_buf, ARRAY_LENGTH(file_title_buf));
625625      free(t_filename);
626626      file_title = utf8_from_tstring(file_title_buf);
627627
r6274r6275
639639         // has a current directory
640640         if (imageinfo)
641641         {
642            snprintf(buf, sizeof(buf) / sizeof(buf[0]),
642            snprintf(buf, ARRAY_LENGTH(buf),
643643               "%s (\"%s\") - %s", file_title, imageinfo, info->current_directory);
644644         }
645645         else
646646         {
647            snprintf(buf, sizeof(buf) / sizeof(buf[0]),
647            snprintf(buf, ARRAY_LENGTH(buf),
648648               "%s - %s", file_title, info->current_directory);
649649         }
650650      }
651651      else
652652      {
653653         // no current directory
654         snprintf(buf, sizeof(buf) / sizeof(buf[0]),
654         snprintf(buf, ARRAY_LENGTH(buf),
655655            imageinfo ? "%s (\"%s\")" : "%s",
656656            file_title, imageinfo);
657657      }
r6274r6275
663663   }
664664   else
665665   {
666      snprintf(buf, sizeof(buf) / sizeof(buf[0]),
666      snprintf(buf, ARRAY_LENGTH(buf),
667667         "%s %s", wimgtool_producttext, build_version);
668668      statusbar_text[0] = NULL;
669669      statusbar_text[1] = NULL;
r6274r6275
671671
672672   win_set_window_text_utf8(window, buf);
673673
674   for (i = 0; i < sizeof(statusbar_text) / sizeof(statusbar_text[0]); i++)
674   for (i = 0; i < ARRAY_LENGTH(statusbar_text); i++)
675675   {
676676      TCHAR *tempstr = statusbar_text[i] ? tstring_from_utf8(statusbar_text[i]) : NULL;
677677      SendMessage(info->statusbar, SB_SETTEXT, i, (LPARAM) tempstr);
r6274r6275
897897
898898      if (!entry.eof)
899899      {
900         snprintf(local_subpath, sizeof(local_subpath) / sizeof(local_subpath[0]),
900         snprintf(local_subpath, ARRAY_LENGTH(local_subpath),
901901            "%s\\%s", local_path, entry.filename);
902902         subpath = imgtool_partition_path_concatenate(partition, path, entry.filename);
903903
r6274r6275
933933   if (err)
934934      goto done;
935935
936   _sntprintf(local_subpath, sizeof(local_subpath) / sizeof(local_subpath[0]), TEXT("%s\\*.*"), local_path, wfd.cFileName);
936   _sntprintf(local_subpath, ARRAY_LENGTH(local_subpath), TEXT("%s\\*.*"), local_path, wfd.cFileName);
937937
938938   h = FindFirstFile(local_subpath, &wfd);
939939   if (h && (h != INVALID_HANDLE_VALUE))
r6274r6275
942942      {
943943         if (_tcscmp(wfd.cFileName, TEXT(".")) && _tcscmp(wfd.cFileName, TEXT("..")))
944944         {
945            _sntprintf(local_subpath, sizeof(local_subpath) / sizeof(local_subpath[0]), TEXT("%s\\%s"), local_path, wfd.cFileName);
945            _sntprintf(local_subpath, ARRAY_LENGTH(local_subpath), TEXT("%s\\%s"), local_path, wfd.cFileName);
946946            filename = utf8_from_tstring(wfd.cFileName);
947947            subpath = imgtool_partition_path_concatenate(partition, path, filename);
948948            free(filename);
r6274r6275
11941194
11951195   /* figure out which filters are appropriate for this file */
11961196   imgtool_partition_suggest_file_filters(info->partition, NULL, stream, suggestion_info.suggestions,
1197      sizeof(suggestion_info.suggestions) / sizeof(suggestion_info.suggestions[0]));
1197      ARRAY_LENGTH(suggestion_info.suggestions));
11981198
11991199   /* do we need to show an option dialog? */
12001200   writefile_optguide = (const option_guide *) imgtool_partition_get_info_ptr(info->partition, IMGTOOLINFO_PTR_WRITEFILE_OPTGUIDE);
r6274r6275
13161316   if (!entry->directory)
13171317   {
13181318      imgtool_partition_suggest_file_filters(info->partition, filename, NULL, suggestion_info.suggestions,
1319         sizeof(suggestion_info.suggestions) / sizeof(suggestion_info.suggestions[0]));
1319         ARRAY_LENGTH(suggestion_info.suggestions));
13201320
13211321      suggestion_info.selected = 0;
1322      for (i = 0; i < sizeof(suggestion_info.suggestions) / sizeof(suggestion_info.suggestions[0]); i++)
1322      for (i = 0; i < ARRAY_LENGTH(suggestion_info.suggestions); i++)
13231323      {
13241324         if (suggestion_info.suggestions[i].viability == SUGGESTION_RECOMMENDED)
13251325         {
r6274r6275
14371437
14381438            case EN_CHANGE:
14391439               GetWindowText(info->edit_box,
1440                  info->buf, sizeof(info->buf) / sizeof(info->buf[0]));
1440                  info->buf, ARRAY_LENGTH(info->buf));
14411441               EnableWindow(info->ok_button, info->buf[0] != '\0');
14421442               break;
14431443         }
r6274r6275
15731573      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, window, NULL, NULL, NULL);
15741574   if (!info->statusbar)
15751575      return -1;
1576   SendMessage(info->statusbar, SB_SETPARTS, sizeof(status_widths) / sizeof(status_widths[0]),
1576   SendMessage(info->statusbar, SB_SETPARTS, ARRAY_LENGTH(status_widths),
15771577      (LPARAM) status_widths);
15781578
15791579   // create imagelists
r6274r6275
16321632   count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0);
16331633   for (i = 0; i < count; i++)
16341634   {
1635      DragQueryFile(drop, i, buffer, sizeof(buffer) / sizeof(buffer[0]));
1635      DragQueryFile(drop, i, buffer, ARRAY_LENGTH(buffer));
16361636      filename = utf8_from_tstring(buffer);
16371637
16381638      // figure out the file/dir name on the image
1639      snprintf(subpath, sizeof(subpath) / sizeof(subpath[0]), "%s%s",
1639      snprintf(subpath, ARRAY_LENGTH(subpath), "%s%s",
16401640         info->current_directory ? info->current_directory : "", osd_basename(filename));
16411641
16421642      if (GetFileAttributes(buffer) & FILE_ATTRIBUTE_DIRECTORY)
src/mess/tools/imgtool/windows/secview.c
r6274r6275
216216   info = get_sectorview_info(dialog);
217217
218218   if (info->track != ~0)
219      snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%u", (unsigned int) info->track);
219      snprintf(buf, ARRAY_LENGTH(buf), "%u", (unsigned int) info->track);
220220   else
221221      buf[0] = '\0';
222222   win_set_window_text_utf8(GetDlgItem(dialog, IDC_TRACKEDIT), buf);
223223
224224   if (info->head != ~0)
225      snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%u", (unsigned int) info->head);
225      snprintf(buf, ARRAY_LENGTH(buf), "%u", (unsigned int) info->head);
226226   else
227227      buf[0] = '\0';
228228   win_set_window_text_utf8(GetDlgItem(dialog, IDC_HEADEDIT), buf);
229229
230230   if (info->sector != ~0)
231      snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%u", (unsigned int) info->sector);
231      snprintf(buf, ARRAY_LENGTH(buf), "%u", (unsigned int) info->sector);
232232   else
233233      buf[0] = '\0';
234234   win_set_window_text_utf8(GetDlgItem(dialog, IDC_SECTOREDIT), buf);
r6274r6275
245245
246246   info = get_sectorview_info(dialog);
247247
248   GetWindowText(GetDlgItem(dialog, IDC_TRACKEDIT), buf, sizeof(buf) / sizeof(buf[0]));
248   GetWindowText(GetDlgItem(dialog, IDC_TRACKEDIT), buf, ARRAY_LENGTH(buf));
249249   new_track = (UINT32) _ttoi(buf);
250   GetWindowText(GetDlgItem(dialog, IDC_HEADEDIT), buf, sizeof(buf) / sizeof(buf[0]));
250   GetWindowText(GetDlgItem(dialog, IDC_HEADEDIT), buf, ARRAY_LENGTH(buf));
251251   new_head = (UINT32) _ttoi(buf);
252   GetWindowText(GetDlgItem(dialog, IDC_SECTOREDIT), buf, sizeof(buf) / sizeof(buf[0]));
252   GetWindowText(GetDlgItem(dialog, IDC_SECTOREDIT), buf, ARRAY_LENGTH(buf));
253253   new_sector = (UINT32) _ttoi(buf);
254254
255255   if ((info->track != new_track) || (info->head != new_head) || (info->sector != new_sector))
src/mess/tools/imgtool/windows/assoc.c
r6274r6275
5252   if (RegOpenKey(key1, TEXT("shell\\open\\command"), &key2))
5353      goto done;
5454
55   if (reg_query_string(key2, buf, sizeof(buf) / sizeof(buf[0])))
55   if (reg_query_string(key2, buf, ARRAY_LENGTH(buf)))
5656      goto done;
5757
58   get_open_command(assoc, expected, sizeof(expected) / sizeof(expected[0]));
58   get_open_command(assoc, expected, ARRAY_LENGTH(expected));
5959   rc = !_tcscmp(expected, buf);
6060
6161done:
r6274r6275
8282   if (RegOpenKey(HKEY_CLASSES_ROOT, extension, &key))
8383      goto done;
8484
85   if (reg_query_string(key, buf, sizeof(buf) / sizeof(buf[0])))
85   if (reg_query_string(key, buf, ARRAY_LENGTH(buf)))
8686      goto done;
8787
8888   rc = !_tcscmp(buf, assoc->file_class);
r6274r6275
131131               KEY_ALL_ACCESS, NULL, &key4, &disposition))
132132            goto done;
133133
134         get_open_command(assoc, buf, sizeof(buf) / sizeof(buf[0]));
134         get_open_command(assoc, buf, ARRAY_LENGTH(buf));
135135         if (RegSetValue(key4, NULL, REG_SZ, buf, sizeof(buf)))
136136            goto done;
137137      }
src/mess/tools/imgtool/windows/hexview.c
r6274r6275
8484      SelectObject(dc, info->font);
8585   SetBkColor(dc, GetSysColor(COLOR_WINDOW));
8686
87   _sntprintf(offset_format, sizeof(offset_format) / sizeof(offset_format[0]),
87   _sntprintf(offset_format, ARRAY_LENGTH(offset_format),
8888      TEXT("%%0%dX"), info->index_width);
8989
9090   // figure out how many bytes go in one row
r6274r6275
103103   end_row = (ps.rcPaint.bottom + scroll_y - 1) / metrics.tmHeight;
104104   for (row = begin_row; row <= end_row; row++)
105105   {
106      _sntprintf(buf, sizeof(buf) / sizeof(buf[0]), offset_format, row * bytes_per_row);
106      _sntprintf(buf, ARRAY_LENGTH(buf), offset_format, row * bytes_per_row);
107107
108108      r.top = row * metrics.tmHeight - scroll_y;
109109      r.left = 0;
r6274r6275
122122            r.left = (info->index_width + col * (2 + info->byte_spacing)) * metrics.tmMaxCharWidth
123123               + info->left_margin;
124124            r.right = r.left + metrics.tmMaxCharWidth * 2;
125            _sntprintf(buf, sizeof(buf) / sizeof(buf[0]), TEXT("%02X"), b);
125            _sntprintf(buf, ARRAY_LENGTH(buf), TEXT("%02X"), b);
126126            DrawText(dc, buf, -1, &r, DT_LEFT);
127127
128128            r.left = (info->index_width + bytes_per_row * (2 + info->byte_spacing) + col) * metrics.tmMaxCharWidth
src/mess/tools/imgtool/imgtool.c
r6274r6275
662662   if (image->module->list_partitions)
663663   {
664664      /* this image supports partitions */
665      if ((partition_index < 0) || (partition_index >= (sizeof(partition_info) / sizeof(partition_info[0]))))
665      if ((partition_index < 0) || (partition_index >= ARRAY_LENGTH(partition_info)))
666666         return IMGTOOLERR_INVALIDPARTITION;
667667
668668      /* retrieve the info on the partitions */
669669      memset(partition_info, '\0', sizeof(partition_info));
670      err = image->module->list_partitions(image, partition_info, sizeof(partition_info) / sizeof(partition_info[0]));
670      err = image->module->list_partitions(image, partition_info, ARRAY_LENGTH(partition_info));
671671      if (err)
672672         return err;
673673
r6274r6275
10201020{
10211021   static int index;
10221022   static char temp_string_pool[32][256];
1023   return temp_string_pool[index++ % (sizeof(temp_string_pool) / sizeof(temp_string_pool[0]))];
1023   return temp_string_pool[index++ % ARRAY_LENGTH(temp_string_pool)];
10241024}
10251025
10261026
r6274r6275
17501750   chain[0].block = ~0;
17511751   last_block = chain[0].block;
17521752
1753   err = imgtool_partition_get_chain(partition, path, chain, sizeof(chain) / sizeof(chain[0]));
1753   err = imgtool_partition_get_chain(partition, path, chain, ARRAY_LENGTH(chain));
17541754   if (err)
17551755      return err;
17561756
src/mess/tools/imgtool/filtbas.c
r6274r6275
28002800
28012801static const basictoken_tableent cocobas_tokenents[] =
28022802{
2803   { 0x00,   0x80,   cocobas_statements,   sizeof(cocobas_statements) / sizeof(cocobas_statements[0]) },
2804   { 0xff,   0x80,   cocobas_functions,   sizeof(cocobas_functions) / sizeof(cocobas_functions[0]) }
2803   { 0x00,   0x80,   cocobas_statements,   ARRAY_LENGTH(cocobas_statements) },
2804   { 0xff,   0x80,   cocobas_functions,   ARRAY_LENGTH(cocobas_functions) }
28052805};
28062806
28072807static const basictokens cocobas_tokens =
r6274r6275
28102810   3,
28112811   TRUE,
28122812   cocobas_tokenents,
2813   sizeof(cocobas_tokenents) / sizeof(cocobas_tokenents[0])
2813   ARRAY_LENGTH(cocobas_tokenents)
28142814};
28152815
28162816static imgtoolerr_t cocobas_readfile(imgtool_partition *partition, const char *filename,
r6274r6275
28442844
28452845static const basictoken_tableent dragonbas_tokenents[] =
28462846{
2847   { 0x00,   0x80,   dragonbas_statements,   sizeof(dragonbas_statements) / sizeof(dragonbas_statements[0]) },
2848   { 0xff,   0x80,   dragonbas_functions,   sizeof(dragonbas_functions) / sizeof(dragonbas_functions[0]) }
2847   { 0x00,   0x80,   dragonbas_statements,   ARRAY_LENGTH(dragonbas_statements) },
2848   { 0xff,   0x80,   dragonbas_functions,   ARRAY_LENGTH(dragonbas_functions) }
28492849};
28502850
28512851static const basictokens dragonbas_tokens =
r6274r6275
28542854   4,
28552855   TRUE,
28562856   dragonbas_tokenents,
2857   sizeof(dragonbas_tokenents) / sizeof(dragonbas_tokenents[0])
2857   ARRAY_LENGTH(dragonbas_tokenents)
28582858};
28592859
28602860static imgtoolerr_t dragonbas_readfile(imgtool_partition *partition, const char *filename,
r6274r6275
28882888
28892889static const basictoken_tableent vzbas_tokenents[] =
28902890{
2891   { 0x00, 0x80,   vzbas,   sizeof(vzbas) / sizeof(vzbas[0]) }
2891   { 0x00, 0x80,   vzbas,   ARRAY_LENGTH(vzbas) }
28922892};
28932893
28942894
r6274r6275
28992899   0,
29002900   FALSE,
29012901   vzbas_tokenents,
2902   sizeof(vzbas_tokenents) / sizeof(vzbas_tokenents[0])
2902   ARRAY_LENGTH(vzbas_tokenents)
29032903};
29042904
29052905static imgtoolerr_t vzbas_readfile(imgtool_partition *partition, const char *filename,
src/mess/tools/imgtool/main.c
r6274r6275
9696            if (*fork)
9797               goto optionalreadyspecified;
9898
99            snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s", value);
99            snprintf(buf, ARRAY_LENGTH(buf), "%s", value);
100100            *fork = buf;
101101         }
102102         else
r6274r6275
567567   imgtoolerr_t err;
568568   int i;
569569
570   err = imgtool_identify_file(argv[0], modules, sizeof(modules) / sizeof(modules[0]));
570   err = imgtool_identify_file(argv[0], modules, ARRAY_LENGTH(modules));
571571   if (err)
572572      goto error;
573573
r6274r6275
786786   while(opt_guide->option_type != OPTIONTYPE_END)
787787   {
788788      range_buffer[0] = 0;
789      snprintf(opt_name, sizeof(opt_name) / sizeof(opt_name[0]), "--%s", opt_guide->identifier);
789      snprintf(opt_name, ARRAY_LENGTH(opt_name), "--%s", opt_guide->identifier);
790790      opt_desc = opt_guide->display_name;
791791
792792      /* is this option relevant? */
r6274r6275
799799      switch(opt_guide->option_type) {
800800      case OPTIONTYPE_INT:
801801         option_resolution_listranges(opt_spec, opt_guide->parameter,
802            range, sizeof(range) / sizeof(range[0]));
802            range, ARRAY_LENGTH(range));
803803
804804         for (i = 0; range[i].max >= 0; i++)
805805         {
806            snprintf(buf, sizeof(buf) / sizeof(buf[0]),
806            snprintf(buf, ARRAY_LENGTH(buf),
807807               (range[i].min == range[i].max) ? "%i" : "%i-%i",
808808               range[i].min,
809809               range[i].max);
r6274r6275
938938   if (argc > 1)
939939   {
940940      /* figure out what command they are running, and run it */
941      for (i = 0; i < (sizeof(cmds) / sizeof(cmds[0])); i++)
941      for (i = 0; i < ARRAY_LENGTH(cmds); i++)
942942      {
943943         c = &cmds[i];
944944         if (!mame_stricmp(c->name, argv[1]))
r6274r6275
977977
978978   /* Usage */
979979   fprintf(stderr, "imgtool - Generic image manipulation tool for use with MESS\n\n");
980   for (i = 0; i < (sizeof(cmds) / sizeof(cmds[0])); i++)
980   for (i = 0; i < ARRAY_LENGTH(cmds); i++)
981981   {
982982      writeusage(stdout, (i == 0), &cmds[i], argv);
983983   }
src/mess/tools/imgtool/tstsuite.c
r6274r6275
4646   while(!feof(inifile))
4747   {
4848      buffer[0] = '\0';
49      fgets(buffer, sizeof(buffer) / sizeof(buffer[0]), inifile);
49      fgets(buffer, ARRAY_LENGTH(buffer), inifile);
5050
5151      if (buffer[0] != '\0')
5252      {
src/mess/tools/imgtool/modules/ti99.c
r6274r6275
42534253   {
42544254      if (iter->listing_subdirs)
42554255      {
4256         fname_to_str(ent->filename, iter->image->u.dsk.catalogs[0].subdirs[iter->index[iter->level]].name, sizeof(ent->filename) / sizeof(ent->filename[0]));
4256         fname_to_str(ent->filename, iter->image->u.dsk.catalogs[0].subdirs[iter->index[iter->level]].name, ARRAY_LENGTH(ent->filename));
42574257
42584258         /* set type of DIR */
4259         snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "DIR");
4259         snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "DIR");
42604260
42614261         /* len in physrecs */
42624262         /* @BN@ return length in bytes */
r6274r6275
42774277         if (reply)
42784278            return IMGTOOLERR_READERROR;
42794279#if 0
4280         fname_to_str(ent->filename, fdr.name, sizeof(ent->filename) / sizeof(ent->filename[0]));
4280         fname_to_str(ent->filename, fdr.name, ARRAY_LENGTH(ent->filename));
42814281#else
42824282         {
42834283            char buf[11];
r6274r6275
42854285            ent->filename[0] = '\0';
42864286            if (iter->level)
42874287            {
4288               fname_to_str(ent->filename, iter->image->u.dsk.catalogs[0].subdirs[iter->index[0]].name, sizeof(ent->filename) / sizeof(ent->filename[0]));
4289               strncat(ent->filename, ".", sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
4288               fname_to_str(ent->filename, iter->image->u.dsk.catalogs[0].subdirs[iter->index[0]].name, ARRAY_LENGTH(ent->filename));
4289               strncat(ent->filename, ".", ARRAY_LENGTH(ent->filename) - 1);
42904290            }
42914291            fname_to_str(buf, fdr.name, 11);
4292            strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
4292            strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1);
42934293         }
42944294#endif
42954295         /* parse flags */
42964296         if (fdr.flags & fdr99_f_program)
4297            snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "PGM%s",
4297            snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "PGM%s",
42984298                     (fdr.flags & fdr99_f_wp) ? " R/O" : "");
42994299         else
4300            snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "%c/%c %d%s",
4300            snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "%c/%c %d%s",
43014301                     (fdr.flags & fdr99_f_int) ? 'I' : 'D',
43024302                     (fdr.flags & fdr99_f_var) ? 'V' : 'F',
43034303                     fdr.reclen,
r6274r6275
43774377      if (iter->listing_subdirs)
43784378      {
43794379#if 0
4380         fname_to_str(ent->filename, iter->catalog[iter->level].subdirs[iter->index[iter->level]].name, sizeof(ent->filename) / sizeof(ent->filename[0]));
4380         fname_to_str(ent->filename, iter->catalog[iter->level].subdirs[iter->index[iter->level]].name, ARRAY_LENGTH(ent->filename));
43814381#else
43824382         {
43834383            char buf[11];
r6274r6275
43864386            for (i=0; i<iter->level; i++)
43874387            {
43884388               fname_to_str(buf, iter->catalog[i].subdirs[iter->index[i]].name, 11);
4389               strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
4390               strncat(ent->filename, ".", sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
4389               strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1);
4390               strncat(ent->filename, ".", ARRAY_LENGTH(ent->filename) - 1);
43914391            }
43924392            fname_to_str(buf, iter->catalog[iter->level].subdirs[iter->index[iter->level]].name, 11);
4393            strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
4393            strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1);
43944394         }
43954395#endif
43964396
43974397         /* set type of DIR */
4398         snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "DIR");
4398         snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "DIR");
43994399
44004400         /* len in physrecs */
44014401         /* @BN@ return length in bytes */
r6274r6275
44204420         if (reply)
44214421            return IMGTOOLERR_READERROR;
44224422#if 0
4423         fname_to_str(ent->filename, iter->catalog[iter->level].files[iter->index[iter->level]].name, sizeof(ent->filename) / sizeof(ent->filename[0]));
4423         fname_to_str(ent->filename, iter->catalog[iter->level].files[iter->index[iter->level]].name, ARRAY_LENGTH(ent->filename));
44244424#else
44254425         {
44264426            char buf[11];
r6274r6275
44294429            for (i=0; i<iter->level; i++)
44304430            {
44314431               fname_to_str(buf, iter->catalog[i].subdirs[iter->index[i]].name, 11);
4432               strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
4433               strncat(ent->filename, ".", sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
4432               strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1);
4433               strncat(ent->filename, ".", ARRAY_LENGTH(ent->filename) - 1);
44344434            }
44354435            fname_to_str(buf, iter->catalog[iter->level].files[iter->index[iter->level]].name, 11);
4436            strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
4436            strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1);
44374437         }
44384438#endif
44394439         /* parse flags */
44404440         if (fdr.flags & fdr99_f_program)
4441            snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "PGM%s",
4441            snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "PGM%s",
44424442                     (fdr.flags & fdr99_f_wp) ? " R/O" : "");
44434443         else
4444            snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "%c/%c %d%s",
4444            snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "%c/%c %d%s",
44454445                     (fdr.flags & fdr99_f_int) ? 'I' : 'D',
44464446                     (fdr.flags & fdr99_f_var) ? 'V' : 'F',
44474447                     fdr.reclen,
src/mess/tools/imgtool/modules/pc_hard.c
r6274r6275
209209   if ((buffer[510] != 0x55) || (buffer[511] != 0xAA))
210210      return IMGTOOLERR_CORRUPTIMAGE;
211211
212   for (i = 0; i < sizeof(info->partitions) / sizeof(info->partitions[0]); i++)
212   for (i = 0; i < ARRAY_LENGTH(info->partitions); i++)
213213   {
214214      partition_info = &buffer[446 + i * 16];
215215
src/mess/tools/imgtool/modules/os9.c
r6274r6275
274274
275275   /* read all sector map entries */
276276   max_entries = (disk_info->sector_size - 16) / 5;
277   max_entries = MIN(max_entries, sizeof(info->sector_map) / sizeof(info->sector_map[0]) - 1);
277   max_entries = MIN(max_entries, ARRAY_LENGTH(info->sector_map) - 1);
278278   for (i = 0; i < max_entries; i++)
279279   {
280280      lsn = pick_integer_be(header, 16 + (i * 5) + 0, 3);
r6274r6275
392392      /* first find out the size of our sector map */
393393      sector_map_length = 0;
394394      lsn = 0;
395      while((lsn < current_lsn_count) && (sector_map_length < sizeof(file_info->sector_map) / sizeof(file_info->sector_map[0])))
395      while((lsn < current_lsn_count) && (sector_map_length < ARRAY_LENGTH(file_info->sector_map)))
396396      {
397397         if (file_info->sector_map[sector_map_length].count == 0)
398398            return os9_corrupt_file_error(file_info);
r6274r6275
433433         {
434434            file_info->sector_map[sector_map_length - 1].count++;
435435         }
436         else if (sector_map_length >= sizeof(file_info->sector_map) / sizeof(file_info->sector_map[0]))
436         else if (sector_map_length >= ARRAY_LENGTH(file_info->sector_map))
437437         {
438438            return IMGTOOLERR_NOSPACE;
439439         }
r6274r6275
460460   /* do we have to write the sector map? */
461461   if (sector_map_length >= 0)
462462   {
463      for (i = 0; i < MIN(sector_map_length + 1, sizeof(file_info->sector_map) / sizeof(file_info->sector_map[0])); i++)
463      for (i = 0; i < MIN(sector_map_length + 1, ARRAY_LENGTH(file_info->sector_map)); i++)
464464      {
465465         place_integer_be(header, 16 + (i * 5) + 0, 3, file_info->sector_map[i].lsn);
466466         place_integer_be(header, 16 + (i * 5) + 3, 2, file_info->sector_map[i].count);
r6274r6275
959959      return err;
960960
961961   /* fill out imgtool_dirent structure */
962   snprintf(ent->filename, sizeof(ent->filename) / sizeof(ent->filename[0]), "%s", filename);
963   snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "%c%c%c%c%c%c%c%c",
962   snprintf(ent->filename, ARRAY_LENGTH(ent->filename), "%s", filename);
963   snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "%c%c%c%c%c%c%c%c",
964964      file_info.directory      ? 'd' : '-',
965965      file_info.non_sharable   ? 's' : '-',
966966      file_info.public_execute ? 'x' : '-',
r6274r6275
11581158      if (err)
11591159         return err;
11601160
1161      for (i = 0; (i < sizeof(file_info.sector_map) / sizeof(file_info.sector_map[0])) && file_info.sector_map[i].count; i++)
1161      for (i = 0; (i < ARRAY_LENGTH(file_info.sector_map)) && file_info.sector_map[i].count; i++)
11621162      {
11631163         lsn = file_info.sector_map[i].lsn;
11641164         for (j = 0;  j < file_info.sector_map[i].count; j++)
src/mess/tools/imgtool/modules/cococas.c
r6274r6275
2121   IMGMODULE_FLAG_FILENAMES_PREFERUCASE,
2222   1200, 1600, 2400,                  /* 0=1200 Hz, 1=2400 Hz, threshold=1600 Hz */
2323   WAVEIMAGE_LSB_FIRST,
24   blockheader, sizeof(blockheader) / sizeof(blockheader[0]),
24   blockheader, ARRAY_LENGTH(blockheader),
2525   cococas_initalt,                  /* alternate initializer */
2626   cococas_nextfile,                  /* enumerate next */
2727   cococas_readfile                  /* read file */
src/mess/tools/imgtool/modules/ti990hd.c
r6274r6275
12451245   else
12461246   {
12471247#if 0
1248      fname_to_str(ent->filename, iter->xdr[iter->level].fdr.fnm, sizeof(ent->filename) / sizeof(ent->filename[0]));
1248      fname_to_str(ent->filename, iter->xdr[iter->level].fdr.fnm, ARRAY_LENGTH(ent->filename));
12491249#else
12501250      {
12511251         int i;
r6274r6275
12551255         for (i=0; i<iter->level; i++)
12561256         {
12571257            fname_to_str(buf, iter->xdr[i].fdr.fnm, 9);
1258            strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
1259            strncat(ent->filename, ".", sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
1258            strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1);
1259            strncat(ent->filename, ".", ARRAY_LENGTH(ent->filename) - 1);
12601260         }
12611261         fname_to_str(buf, iter->xdr[iter->level].fdr.fnm, 9);
1262         strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1);
1262         strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1);
12631263      }
12641264#endif
12651265
r6274r6275
12671267      flag = get_UINT16BE(iter->xdr[iter->level].fdr.flg);
12681268      if (flag & fdr_flg_cdr)
12691269      {
1270         snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "CHANNEL");
1270         snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "CHANNEL");
12711271
12721272         ent->filesize = 0;
12731273      }
r6274r6275
12851285
12861286         fname_to_str(buf, target_fdr.fnm, 9);
12871287
1288         snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "ALIAS OF %s", buf);
1288         snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "ALIAS OF %s", buf);
12891289
12901290         ent->filesize = 0;
12911291      }
r6274r6275
13351335            }
13361336            break;
13371337         }
1338         snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]),
1338         snprintf(ent->attr, ARRAY_LENGTH(ent->attr),
13391339                  "%s %c %s%s%s%s%s", fmt, (flag & fdr_flg_all) ? 'N' : 'C', type,
13401340                     (flag & fdr_flg_blb) ? "" : " BLK",
13411341                     (flag & fdr_flg_tmp) ? " TMP" : "",
src/mess/tools/imgtool/modules/mac.c
r6274r6275
53715371   }
53725372
53735373   /* copy info */
5374   mac_to_c_strncpy(ent->filename, sizeof(ent->filename) / sizeof(ent->filename[0]), cur_dir_entry->name);
5374   mac_to_c_strncpy(ent->filename, ARRAY_LENGTH(ent->filename), cur_dir_entry->name);
53755375   ent->filesize = get_UINT32BE(cur_dir_entry->dataPhysicalSize)
53765376                  + get_UINT32BE(cur_dir_entry->rsrcPhysicalSize);
53775377
r6274r6275
54635463   }
54645464
54655465   /* initialize file path buffer */
5466   cur_name_head = sizeof(ent->filename) / sizeof(ent->filename[0]);
5466   cur_name_head = ARRAY_LENGTH(ent->filename);
54675467   if (cur_name_head > 0)
54685468   {
54695469      cur_name_head--;
r6274r6275
54715471   }
54725472
54735473   /* insert folder/file name in buffer */
5474   mac_to_c_strncpy(ent->filename, sizeof(ent->filename) / sizeof(ent->filename[0]), catrec_key->cName);
5475//  concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1, buf);
5474   mac_to_c_strncpy(ent->filename, ARRAY_LENGTH(ent->filename), catrec_key->cName);
5475//  concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename) - 1, buf);
54765476
54775477#if 0
54785478   /* extract parent directory ID */
r6274r6275
54875487      if (err)
54885488      {
54895489         /* error */
5490         concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1, ":");
5491         concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1, "???");
5490         concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename) - 1, ":");
5491         concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename) - 1, "???");
54925492
5493         memmove(ent->filename, ent->filename+cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - cur_name_head);
5493         memmove(ent->filename, ent->filename+cur_name_head, ARRAY_LENGTH(ent->filename) - cur_name_head);
54945494         ent->corrupt = 1;
54955495         return err;
54965496      }
r6274r6275
55005500      if (dataRecType != hcrt_FolderThread)
55015501      {
55025502         /* error */
5503         concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0])-1, ":");
5504         concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0])-1, "???");
5503         concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename)-1, ":");
5504         concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename)-1, "???");
55055505
5506         memmove(ent->filename, ent->filename+cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0])-cur_name_head);
5506         memmove(ent->filename, ent->filename+cur_name_head, ARRAY_LENGTH(ent->filename)-cur_name_head);
55075507         ent->corrupt = 1;
55085508         return IMGTOOLERR_CORRUPTIMAGE;
55095509      }
r6274r6275
55115511      /* got folder thread record: insert the folder name at the start of
55125512        file path, then iterate */
55135513      mac_to_c_strncpy(buf, sizeof(buf), catrec_data->thread.nodeName);
5514      concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1, ":");
5515      concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1, buf);
5514      concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename) - 1, ":");
5515      concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename) - 1, buf);
55165516
55175517      /* extract parent directory ID */
55185518      parID = get_UINT32BE(catrec_data->thread.parID);
55195519   }
5520   memmove(ent->filename, ent->filename+cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) -cur_name_head);
5520   memmove(ent->filename, ent->filename+cur_name_head, ARRAY_LENGTH(ent->filename) -cur_name_head);
55215521#endif
55225522   return IMGTOOLERR_SUCCESS;
55235523}
r6274r6275
61676167   const void *fref;
61686168   UINT32 resource_length;
61696169
6170   assert((sizeof(attrs) / sizeof(attrs[0]) - 1)
6171      == (sizeof(attr_values) / sizeof(attr_values[0])));
6170   assert((ARRAY_LENGTH(attrs) - 1)
6171      == ARRAY_LENGTH(attr_values));
61726172
61736173   /* first retrieve type and creator code */
61746174   err = mac_image_getattrs(partition, path, attrs, attr_values);
src/mess/tools/imgtool/modules/prodos.c
r6274r6275
11891189         ent->key_pointer[0] = new_file_block;
11901190         ent->file_type = 0x3F3F3F3F;
11911191         ent->file_creator = 0x3F3F3F3F;
1192         strncpy(ent->filename, old_path, sizeof(ent->filename) / sizeof(ent->filename[0]));
1192         strncpy(ent->filename, old_path, ARRAY_LENGTH(ent->filename));
11931193
11941194         /* and place it */
11951195         err = prodos_put_dirent(image, direnum, ent);
src/mess/tools/imgtool/modules/fat.c
r6274r6275
13291329            lfn_checksum = entry[13];
13301330         }
13311331         lfn_lastentry = entry[0] & 0x3F;
1332         prepend_lfn_bytes(lfn_buf, sizeof(lfn_buf) / sizeof(lfn_buf[0]),
1332         prepend_lfn_bytes(lfn_buf, ARRAY_LENGTH(lfn_buf),
13331333            &lfn_len, entry, 28, 2);
1334         prepend_lfn_bytes(lfn_buf, sizeof(lfn_buf) / sizeof(lfn_buf[0]),
1334         prepend_lfn_bytes(lfn_buf, ARRAY_LENGTH(lfn_buf),
13351335            &lfn_len, entry, 14, 6);
1336         prepend_lfn_bytes(lfn_buf, sizeof(lfn_buf) / sizeof(lfn_buf[0]),
1336         prepend_lfn_bytes(lfn_buf, ARRAY_LENGTH(lfn_buf),
13371337            &lfn_len, entry,  1, 5);
13381338      }
13391339      else if (freeent && (freeent->position == ~0))
r6274r6275
13751375         j = 0;
13761376         do
13771377         {
1378            i += uchar_from_utf16(&ch, &lfn_buf[i], sizeof(lfn_buf) / sizeof(lfn_buf[0]) - i);
1379            j += utf8_from_uchar(&ent->long_filename[j], sizeof(ent->long_filename) / sizeof(ent->long_filename[0]) - j, ch);
1378            i += uchar_from_utf16(&ch, &lfn_buf[i], ARRAY_LENGTH(lfn_buf) - i);
1379            j += utf8_from_uchar(&ent->long_filename[j], ARRAY_LENGTH(ent->long_filename) - j, ch);
13801380         }
13811381         while(ch != 0);
13821382      }
r6274r6275
18341834      return err;
18351835
18361836   /* copy stuff from the FAT dirent to the Imgtool dirent */
1837   snprintf(ent->filename, sizeof(ent->filename) / sizeof(ent->filename[0]), "%s", fatent.long_filename[0]
1837   snprintf(ent->filename, ARRAY_LENGTH(ent->filename), "%s", fatent.long_filename[0]
18381838      ? fatent.long_filename : fatent.short_filename);
18391839   ent->filesize = fatent.filesize;
18401840   ent->directory = fatent.directory;
src/mess/tools/imgtool/modules/rsdos.c
r6274r6275
321321
322322      get_dirent_fname(fname, &rsent);
323323
324      snprintf(ent->filename, sizeof(ent->filename) / sizeof(ent->filename[0]), "%s", fname);
325      snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "%d %c", (int) rsent.ftype, (char) (rsent.asciiflag + 'B'));
324      snprintf(ent->filename, ARRAY_LENGTH(ent->filename), "%s", fname);
325      snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "%d %c", (int) rsent.ftype, (char) (rsent.asciiflag + 'B'));
326326   }
327327   return IMGTOOLERR_SUCCESS;
328328}
src/mess/tools/imgtool/modules/concept.c
r6274r6275
349349      int len = iter->image->dev_dir.file_dir[iter->index].filename[0];
350350      const char *type;
351351
352      if (len > sizeof(ent->filename) / sizeof(ent->filename[0]))
353         len = sizeof(ent->filename) / sizeof(ent->filename[0]);
352      if (len > ARRAY_LENGTH(ent->filename))
353         len = ARRAY_LENGTH(ent->filename);
354354      memcpy(ent->filename, iter->image->dev_dir.file_dir[iter->index].filename + 1, len);
355355      ent->filename[len] = 0;
356356
r6274r6275
374374         type = "???";
375375         break;
376376      }
377      snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "%s", type);
377      snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "%s", type);
378378
379379      /* len in physrecs */
380380      ent->filesize = get_UINT16xE(iter->image->dev_dir.vol_hdr.disk_flipped, iter->image->dev_dir.file_dir[iter->index].next_block)
src/mess/tools/imgtool/imgterrs.c
r6274r6275
4747{
4848   err = ERRORCODE(err) - 1;
4949   assert(err >= 0);
50   assert(err < (sizeof(msgs) / sizeof(msgs[0])));
50   assert(err < ARRAY_LENGTH(msgs));
5151   return msgs[err];
5252}
src/mess/tools/pile.c
r6274r6275
1010#include <string.h>
1111#include <stdio.h>
1212
13#include "osdcomm.h"
1314#include "pile.h"
1415
1516void pile_init(mess_pile *pile)
r6274r6275
100101   int count;
101102   char buf[1024];
102103
103   count = vsnprintf(buf, sizeof(buf) / sizeof(buf[0]), fmt, args);
104   count = vsnprintf(buf, ARRAY_LENGTH(buf), fmt, args);
104105   if (pile_write(pile, buf, count * sizeof(*buf)))
105106      return 0;
106107   return count;
src/mess/video/coco6847.c
r6274r6275
10521052      | ((attr & (M6847_GM1 | M6847_GM0)) << 5);
10531053
10541054   /* sanity check */
1055   assert(result < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0]));
1055   assert(result < ARRAY_LENGTH(m6847->fontdata));
10561056   return result;
10571057}
10581058
r6274r6275
10621062{
10631063   /* sanity check */
10641064   assert(attr_index >= 0);
1065   assert(attr_index < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0]));
1065   assert(attr_index < ARRAY_LENGTH(m6847->fontdata));
10661066
10671067   return (UINT8) ((attr_index & 0x1F) << 3)
10681068      | ((attr_index & 0x60) >> 5);
r6274r6275
17941794   int byte;
17951795   const UINT8 *char_data;
17961796
1797   for (attr_index = 0; attr_index < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0]); attr_index++)
1797   for (attr_index = 0; attr_index < ARRAY_LENGTH(m6847->fontdata); attr_index++)
17981798   {
17991799      UINT8 attr = attribute_from_attr_index(attr_index);
18001800
r6274r6275
18331833   double total_scanlines;
18341834
18351835   /* identify proper M6847 variant */
1836   assert(cfg->type < sizeof(variants) / sizeof(variants[0]));
1836   assert(cfg->type < ARRAY_LENGTH(variants));
18371837   v = &variants[cfg->type];
18381838
18391839   /* allocate instance */
src/mess/video/crtc6845.c
r6274r6275
242242   if (offset & 1)
243243   {
244244      idx = crtc->idx & 0x1f;
245      if (idx < (sizeof(crtc->reg) / sizeof(crtc->reg[0])))
245      if (idx < ARRAY_LENGTH(crtc->reg))
246246         val = crtc->reg[idx] & mscrtc6845_reg_mask[crtc->config.personality][idx].read_mask;
247247   }
248248   else
r6274r6275
262262   {
263263      /* write to a 6845 register, if supported */
264264      idx = crtc->idx & 0x1f;
265      if (idx < (sizeof(crtc->reg) / sizeof(crtc->reg[0])))
265      if (idx < ARRAY_LENGTH(crtc->reg))
266266      {
267267         mask = mscrtc6845_reg_mask[crtc->config.personality][idx].store_mask;
268268         /* Don't zero out bits not covered by the mask. */
src/mess/video/coco3.c
r6274r6275
463463static void coco3_set_dirty(void)
464464{
465465   int i;
466   for (i = 0; i < sizeof(video->dirty) / sizeof(video->dirty[0]); i++)
466   for (i = 0; i < ARRAY_LENGTH(video->dirty); i++)
467467      video->dirty[i] = TRUE;
468468}
469469
src/mess/inputx.c
r6274r6275
376376static const char_info *find_charinfo(unicode_char target_char)
377377{
378378   int low = 0;
379   int high = sizeof(charinfo) / sizeof(charinfo[0]);
379   int high = ARRAY_LENGTH(charinfo);
380380   int i;
381381   unicode_char ch;
382382
r6274r6275
592592   const char_info *ci;
593593
594594   /* check to make sure that charinfo is in order */
595   for (i = 0; i < sizeof(charinfo) / sizeof(charinfo[0]); i++)
595   for (i = 0; i < ARRAY_LENGTH(charinfo); i++)
596596   {
597597      if (last_char >= charinfo[i].ch)
598598      {
r6274r6275
603603   }
604604
605605   /* check to make sure that I can look up everything on alternate_charmap */
606   for (i = 0; i < sizeof(charinfo) / sizeof(charinfo[0]); i++)
606   for (i = 0; i < ARRAY_LENGTH(charinfo); i++)
607607   {
608608      ci = find_charinfo(charinfo[i].ch);
609609      if (ci != &charinfo[i])
r6274r6275
815815   }
816816
817817   keybuf->buffer[keybuf->end_pos++] = ch;
818   keybuf->end_pos %= sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]);
818   keybuf->end_pos %= ARRAY_LENGTH(keybuf->buffer);
819819}
820820
821821
r6274r6275
824824{
825825   key_buffer *keybuf;
826826   keybuf = get_buffer(machine);
827   return ((keybuf->end_pos + 1) % (sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]))) == keybuf->begin_pos;
827   return ((keybuf->end_pos + 1) % ARRAY_LENGTH(keybuf->buffer)) == keybuf->begin_pos;
828828}
829829
830830
r6274r6275
901901      while((keybuf->begin_pos != keybuf->end_pos) && queue_chars(&keybuf->buffer[keybuf->begin_pos], 1))
902902      {
903903         keybuf->begin_pos++;
904         keybuf->begin_pos %= sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]);
904         keybuf->begin_pos %= ARRAY_LENGTH(keybuf->buffer);
905905
906906         if (attotime_compare(current_rate, attotime_zero) != 0)
907907            break;
r6274r6275
914914      {
915915         keybuf->status_keydown = FALSE;
916916         keybuf->begin_pos++;
917         keybuf->begin_pos %= sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]);
917         keybuf->begin_pos %= ARRAY_LENGTH(keybuf->buffer);
918918      }
919919      else
920920      {
r6274r6275
11061106
11071107      if (ch == '{')
11081108      {
1109         for (j = 0; j < sizeof(codes) / sizeof(codes[0]); j++)
1109         for (j = 0; j < ARRAY_LENGTH(codes); j++)
11101110         {
11111111            key_len = strlen(codes[j].key);
11121112            if (i + key_len + 2 <= text_len)
r6274r6275
11811181
11821182   while(text_len > 0)
11831183   {
1184      if (len == (sizeof(buf) / sizeof(buf[0])))
1184      if (len == ARRAY_LENGTH(buf))
11851185      {
11861186         inputx_postn(machine, buf, len);
11871187         len = 0;
r6274r6275
12601260
12611261   while(text_len > 0)
12621262   {
1263      if (len == (sizeof(buf) / sizeof(buf[0])))
1263      if (len == ARRAY_LENGTH(buf))
12641264      {
12651265         inputx_postn(machine, buf, len);
12661266         len = 0;
src/mess/device.c
r6274r6275
151151iodevice_t device_typeid(const char *name)
152152{
153153   int i;
154   for (i = 0; i < sizeof(device_info_array) / sizeof(device_info_array[0]); i++)
154   for (i = 0; i < ARRAY_LENGTH(device_info_array); i++)
155155   {
156156      if (!mame_stricmp(name, device_info_array[i].name) || !mame_stricmp(name, device_info_array[i].shortname))
157157         return device_info_array[i].type;
r6274r6275
467467void mess_devices_setup(running_machine *machine, machine_config *config, const game_driver *gamedrv)
468468{
469469   device_getinfo_handler handlers[64];
470   int count_overrides[sizeof(handlers) / sizeof(handlers[0])];
470   int count_overrides[ARRAY_LENGTH(handlers)];
471471   int i, position = 0;
472472
473473   memset(handlers, 0, sizeof(handlers));
r6274r6275
479479      struct SystemConfigurationParamBlock params;
480480
481481      memset(&params, 0, sizeof(params));
482      params.device_slotcount = sizeof(handlers) / sizeof(handlers[0]);
482      params.device_slotcount = ARRAY_LENGTH(handlers);
483483      params.device_handlers = handlers;
484484      params.device_countoverrides = count_overrides;
485485      gamedrv->sysconfig_ctor(&params);
r6274r6275
572572   int i;
573573
574574   /* Check the device struct array */
575   for (i = 0; i < sizeof(device_info_array) / sizeof(device_info_array[0]); i++)
575   for (i = 0; i < ARRAY_LENGTH(device_info_array); i++)
576576   {
577577      if (!device_info_array[i].name)
578578      {
src/mess/mesvalid.c
r6274r6275
191191   struct SystemConfigurationParamBlock cfg;
192192   device_getinfo_handler handlers[64];
193193   mess_device_class devclass;
194   int count_overrides[sizeof(handlers) / sizeof(handlers[0])];
194   int count_overrides[ARRAY_LENGTH(handlers)];
195195
196196   if (drv->sysconfig_ctor)
197197   {
198198      memset(&cfg, 0, sizeof(cfg));
199199      memset(handlers, 0, sizeof(handlers));
200      cfg.device_slotcount = sizeof(handlers) / sizeof(handlers[0]);
200      cfg.device_slotcount = ARRAY_LENGTH(handlers);
201201      cfg.device_handlers = handlers;
202202      cfg.device_countoverrides = count_overrides;
203203      drv->sysconfig_ctor(&cfg);
src/mess/osd/sdl/glob.c
r6274r6275
437437   int c, err, oldpathc;
438438   Char *bufnext, patbuf[_MAX_PATH+1];
439439
440   qpatnext = globtilde(pattern, patbuf, sizeof(patbuf) / sizeof(Char),
441       pglob);
440   qpatnext = globtilde(pattern, patbuf, ARRAY_LENGTH(patbuf), pglob);
442441   oldpathc = pglob->gl_pathc;
443442   bufnext = patbuf;
444443
src/mess/osd/sdl/sdlmess.c
r6274r6275
454454   types[0] = XInternAtom( display, "UTF8_STRING", False );
455455   types[1] = XA_STRING; /* latin-1 */
456456
457   for ( i = 0; i < sizeof( types ) / sizeof( types[0] ); i++ )
457   for ( i = 0; i < ARRAY_LENGTH(types); i++ )
458458   {
459459
460460      XConvertSelection( display, XA_PRIMARY, types[i], types[i], our_win, CurrentTime );
src/mess/osd/windows/dialog.c
r6274r6275
297297      case WM_COMMAND:
298298         command = LOWORD(wparam);
299299
300         win_get_window_text_utf8((HWND) lparam, buf, sizeof(buf) / sizeof(buf[0]));
300         win_get_window_text_utf8((HWND) lparam, buf, ARRAY_LENGTH(buf));
301301         if (!strcmp(buf, DLGTEXT_OK))
302302            command = IDOK;
303303         else if (!strcmp(buf, DLGTEXT_CANCEL))
r6274r6275
524524   }
525525
526526
527   for (i = 0; i < sizeof(objpool->objects) / sizeof(objpool->objects[0]); i++)
527   for (i = 0; i < ARRAY_LENGTH(objpool->objects); i++)
528528   {
529529      if (!objpool->objects[i])
530530         break;
531531   }
532   if (i >= sizeof(objpool->objects) / sizeof(objpool->objects[0]))
532   if (i >= ARRAY_LENGTH(objpool->objects))
533533      return 1;
534534
535535   objpool->objects[i] = obj;
r6274r6275
622622static LRESULT dialog_get_adjuster_value(dialog_box *dialog, HWND dialog_item, UINT message, WPARAM wparam, LPARAM lparam)
623623{
624624   TCHAR buf[32];
625   GetWindowText(dialog_item, buf, sizeof(buf) / sizeof(buf[0]));
625   GetWindowText(dialog_item, buf, ARRAY_LENGTH(buf));
626626   return _ttoi(buf);
627627}
628628
r6274r6275
873873      id = GetWindowLong(sbwnd, GWL_ID);
874874      dlgwnd = GetParent(sbwnd);
875875      editwnd = GetDlgItem(dlgwnd, id - 1);
876      win_get_window_text_utf8(editwnd, buf, sizeof(buf) / sizeof(buf[0]));
876      win_get_window_text_utf8(editwnd, buf, ARRAY_LENGTH(buf));
877877      value = atoi(buf);
878878
879879      switch(wparam)
r6274r6275
893893         value = stuff->min_value;
894894      else if (value > stuff->max_value)
895895         value = stuff->max_value;
896      _snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", value);
896      _snprintf(buf, ARRAY_LENGTH(buf), "%d", value);
897897      win_set_window_text_utf8(editwnd, buf);
898898      result = 0;
899899   }
r6274r6275
958958      goto error;
959959   x += dialog->layout->combo_width - DIM_ADJUSTER_SCR_WIDTH;
960960
961   _sntprintf(buf, sizeof(buf) / sizeof(buf[0]),
961   _sntprintf(buf, ARRAY_LENGTH(buf),
962962      is_percentage ? TEXT("%d%%") : TEXT("%d"),
963963      default_value);
964964   s = win_dialog_tcsdup(dialog, buf);
r6274r6275
15751575   objpool = dialog->objpool;
15761576   if (objpool)
15771577   {
1578      for (i = 0; i < sizeof(objpool->objects) / sizeof(objpool->objects[0]); i++)
1578      for (i = 0; i < ARRAY_LENGTH(objpool->objects); i++)
15791579         DeleteObject(objpool->objects[i]);
15801580   }
15811581
src/mess/osd/windows/menu.c
r6274r6275
209209   /* check to see if there is any custom artwork for this configure dialog,
210210    * and if so, retrieve the info */
211211   portslot_count = artwork_get_inputscreen_customizations(&png, cust_type, section,
212      customizations, sizeof(customizations) / sizeof(customizations[0]));
212      customizations, ARRAY_LENGTH(customizations));
213213
214214   /* zero out the portslots that correspond to customizations */
215215   memset(portslots, 0, sizeof(portslots[0]) * portslot_count);
r6274r6275
263263                * want to reorder the tab order */
264264               if (customizations[i].ipt == IPT_END)
265265                  i = portslot_count++;
266               if (i < (sizeof(portslots) / sizeof(portslots[0])))
266               if (i < ARRAY_LENGTH(portslots))
267267               {
268268                  portslots[i].field = field;
269269                  portslots[i].pr = pr;
r6274r6275
274274   }
275275
276276   /* finally add the portselects to the dialog */
277   if (portslot_count > (sizeof(portslots) / sizeof(portslots[0])))
278      portslot_count = sizeof(portslots) / sizeof(portslots[0]);
277   if (portslot_count > ARRAY_LENGTH(portslots))
278      portslot_count = ARRAY_LENGTH(portslots);
279279   for (i = 0; i < portslot_count; i++)
280280   {
281281      if (portslots[i].field)
r6274r6275
528528            input_field_get_user_settings(field, &settings);
529529            name = input_field_name(field);
530530
531            _snprintf(buf, sizeof(buf) / sizeof(buf[0]),
531            _snprintf(buf, ARRAY_LENGTH(buf),
532532               "%s %s", name, ui_getstring(UI_keyjoyspeed));
533533            if (win_dialog_add_adjuster(dlg, buf, settings.delta, 1, 255, FALSE, store_delta, (void *) field))
534534               goto done;
535535
536            _snprintf(buf, sizeof(buf) / sizeof(buf[0]),
536            _snprintf(buf, ARRAY_LENGTH(buf),
537537               "%s %s", name, ui_getstring(UI_centerspeed));
538538            if (win_dialog_add_adjuster(dlg, buf, settings.centerdelta, 1, 255, FALSE, store_centerdelta, (void *) field))
539539               goto done;
540540
541            _snprintf(buf, sizeof(buf) / sizeof(buf[0]),
541            _snprintf(buf, ARRAY_LENGTH(buf),
542542               "%s %s", name, ui_getstring(UI_reverse));
543543            if (win_dialog_add_combobox(dlg, buf, settings.reverse ? 1 : 0, store_reverse, (void *) field))
544544               goto done;
r6274r6275
547547            if (win_dialog_add_combobox_item(dlg, ui_getstring(UI_on), 1))
548548               goto done;
549549
550            _snprintf(buf, sizeof(buf) / sizeof(buf[0]),
550            _snprintf(buf, ARRAY_LENGTH(buf),
551551               "%s %s", name, ui_getstring(UI_sensitivity));
552552            if (win_dialog_add_adjuster(dlg, buf, settings.sensitivity, 1, 255, TRUE, store_sensitivity, (void *) field))
553553               goto done;
r6274r6275
587587   }
588588   else
589589   {
590      snprintf(state_filename, sizeof(state_filename) / sizeof(state_filename[0]),
590      snprintf(state_filename, ARRAY_LENGTH(state_filename),
591591         "%s State.sta", machine->gamedrv->description);
592592      dir = NULL;
593593
r6274r6275
685685   while((wnd = FindWindowEx(dlgwnd, wnd, NULL, NULL)) != NULL)
686686   {
687687      // get label text, removing trailing NULL
688      GetWindowText(wnd, t_buf1, sizeof(t_buf1) / sizeof(t_buf1[0]));
688      GetWindowText(wnd, t_buf1, ARRAY_LENGTH(t_buf1));
689689      buf1 = utf8_from_tstring(t_buf1);
690690      assert(buf1[strlen(buf1)-1] == ':');
691691      buf1[strlen(buf1)-1] = '\0';
r6274r6275
746746      *(params->fdparams->create_args) = resolution;
747747   }
748748
749   snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", val);
749   snprintf(buf, ARRAY_LENGTH(buf), "%d", val);
750750   option_resolution_add_param(resolution, params->guide_entry->identifier, buf);
751751}
752752
r6274r6275
817817         switch(guide_entry->option_type)
818818         {
819819            case OPTIONTYPE_INT:
820               snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s:", guide_entry->display_name);
820               snprintf(buf, ARRAY_LENGTH(buf), "%s:", guide_entry->display_name);
821821               if (win_dialog_add_combobox(dialog, buf, 0, storeval_option_resolution, storeval_params))
822822                  goto error;
823823               break;
r6274r6275
977977      && (image_device_get_creation_option_guide(device) != NULL)
978978      && (image_device_get_creatable_formats(device) != NULL))
979979   {
980      dialog = build_option_dialog(device, filter, sizeof(filter) / sizeof(filter[0]), &create_format, &create_args);
980      dialog = build_option_dialog(device, filter, ARRAY_LENGTH(filter), &create_format, &create_args);
981981      if (!dialog)
982982         goto done;
983983   }
984984   else
985985   {
986986      // build a normal filter
987      build_generic_filter(device, is_save, filter, sizeof(filter) / sizeof(filter[0]));
987      build_generic_filter(device, is_save, filter, ARRAY_LENGTH(filter));
988988   }
989989
990990   // display the dialog
991991   result = win_file_dialog(device->machine, wnd, is_save ? WIN_FILE_DIALOG_SAVE : WIN_FILE_DIALOG_OPEN,
992      dialog, filter, initial_dir, filename, sizeof(filename) / sizeof(filename[0]));
992      dialog, filter, initial_dir, filename, ARRAY_LENGTH(filename));
993993   if (result)
994994   {
995995      // mount the image
r6274r6275
12511251      {
12521252         for (i = 0; i < joystick_count; i++)
12531253         {
1254            snprintf(buf, sizeof(buf) / sizeof(buf[0]), "Joystick %i", i + 1);
1254            snprintf(buf, ARRAY_LENGTH(buf), "Joystick %i", i + 1);
12551255            append_menu_utf8(joystick_menu, MF_STRING, ID_JOYSTICK_0 + i, buf);
12561256            child_count++;
12571257         }
r6274r6275
14851485      s = image_exists(img) ? image_filename(img) : ui_getstring(UI_emptyslot);
14861486      flags = MF_POPUP;
14871487
1488      snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s: %s", image_typename_id(img), s);
1488      snprintf(buf, ARRAY_LENGTH(buf), "%s: %s", image_typename_id(img), s);
14891489      append_menu_utf8(device_menu, flags, (UINT_PTR) sub_menu, buf);
14901490   }
14911491}
r6274r6275
16751675static void help_about_thissystem(running_machine *machine, HWND wnd)
16761676{
16771677   char buf[256];
1678   snprintf(buf, sizeof(buf) / sizeof(buf[0]), "mess.chm::/sysinfo/%s.htm", machine->gamedrv->name);
1678   snprintf(buf, ARRAY_LENGTH(buf), "mess.chm::/sysinfo/%s.htm", machine->gamedrv->name);
16791679   help_display(wnd, buf);
16801680}
16811681
r6274r6275
20312031
20322032   // get the device icons
20332033   memset(device_icons, 0, sizeof(device_icons));
2034   for (i = 0; i < sizeof(bitmap_ids) / sizeof(bitmap_ids[0]); i++)
2034   for (i = 0; i < ARRAY_LENGTH(bitmap_ids); i++)
20352035      device_icons[bitmap_ids[i][0]] = LoadIcon(module, MAKEINTRESOURCE(bitmap_ids[i][1]));
20362036
20372037   // remove the profiler menu item if it doesn't exist
r6274r6275
20582058      return 1;
20592059   for(i = 0; i < frameskip_level_count(); i++)
20602060   {
2061      snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%i", i);
2061      snprintf(buf, ARRAY_LENGTH(buf), "%i", i);
20622062      append_menu_utf8(frameskip_menu, MF_STRING, ID_FRAMESKIP_0 + i, buf);
20632063   }
20642064
20652065   // set the help menu to refer to this machine
2066   snprintf(buf, sizeof(buf) / sizeof(buf[0]), "About %s (%s)...", machine->gamedrv->description, machine->gamedrv->name);
2066   snprintf(buf, ARRAY_LENGTH(buf), "About %s (%s)...", machine->gamedrv->description, machine->gamedrv->name);
20672067   set_menu_text(menu_bar, ID_HELP_ABOUTSYSTEM, buf);
20682068   return 0;
20692069}
src/mess/osd/windows/opcntrl.c
r6274r6275
3232   int count = 0, i;
3333
3434   option_resolution_listranges(optspec, guide->parameter,
35      ranges, sizeof(ranges) / sizeof(ranges[0]));
35      ranges, ARRAY_LENGTH(ranges));
3636
3737   for (i = 0; ranges[i].min >= 0; i++)
3838      count += ranges[i].max - ranges[i].min + 1;
r6274r6275
6262         goto unexpected;
6363
6464      option_resolution_listranges(optspec, guide->parameter,
65         ranges, sizeof(ranges) / sizeof(ranges[0]));
65         ranges, ARRAY_LENGTH(ranges));
6666      option_resolution_getdefault(optspec, guide->parameter, &default_value);
6767
6868      option_count = 0;
r6274r6275
7575         {
7676            if (guide->option_type == OPTIONTYPE_INT)
7777            {
78               _sntprintf(buf2, sizeof(buf2) / sizeof(buf2[0]), TEXT("%d"), j);
78               _sntprintf(buf2, ARRAY_LENGTH(buf2), TEXT("%d"), j);
7979               SendMessage(control, CB_ADDSTRING, 0, (LPARAM) buf2);
8080            }
8181            else if (guide->option_type == OPTIONTYPE_ENUM_BEGIN)
r6274r6275
157157            err = option_resolution_getdefault(optspec, guide->parameter, &val);
158158            if (err)
159159               goto done;
160            _snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", val);
160            _snprintf(buf, ARRAY_LENGTH(buf), "%d", val);
161161            break;
162162
163163         default:
r6274r6275
194194   guide = (const option_guide *) GetProp(control, guide_prop);
195195   optspec = (const char *) GetProp(control, spec_prop);
196196
197   win_get_window_text_utf8(control, buf, sizeof(buf) / sizeof(buf[0]));
197   win_get_window_text_utf8(control, buf, ARRAY_LENGTH(buf));
198198
199199   switch(guide->option_type)
200200   {
r6274r6275
205205         {
206206            h = GetProp(control, value_prop);
207207            val = (FPTR) h;
208            _snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", val);
208            _snprintf(buf, ARRAY_LENGTH(buf), "%d", val);
209209            win_set_window_text_utf8(control, buf);
210210         }
211211         else
r6274r6275
283283      return TRUE;
284284
285285   option_resolution_listranges(optspec, guide->parameter,
286      ranges, sizeof(ranges) / sizeof(ranges[0]));
286      ranges, ARRAY_LENGTH(ranges));
287287
288   win_get_window_text_utf8(control, buf, sizeof(buf) / sizeof(buf[0]));
288   win_get_window_text_utf8(control, buf, ARRAY_LENGTH(buf));
289289   original_val = atoi(buf);
290290   val = original_val + delta;
291291
r6274r6275
306306
307307   if (val != original_val)
308308   {
309      _snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", val);
309      _snprintf(buf, ARRAY_LENGTH(buf), "%d", val);
310310      win_set_window_text_utf8(control, buf);
311311   }
312312   return TRUE;
r6274r6275
323323   const char *old_text;
324324   int i;
325325
326   if (!win_get_window_text_utf8(control, buf, sizeof(buf) / sizeof(buf[0])))
326   if (!win_get_window_text_utf8(control, buf, ARRAY_LENGTH(buf)))
327327   {
328328      err = OPTIONRESOLTUION_ERROR_INTERNAL;
329329      return err;
src/mess/osd/windows/glob.c
r6274r6275
443443   int c, err, oldpathc;
444444   Char *bufnext, patbuf[_MAX_PATH+1];
445445
446   qpatnext = globtilde(pattern, patbuf, sizeof(patbuf) / sizeof(Char),
447       pglob);
446   qpatnext = globtilde(pattern, patbuf, ARRAY_LENGTH(patbuf), pglob);
448447   oldpathc = pglob->gl_pathc;
449448   bufnext = patbuf;
450449
src/mess/osd/windows/winmess.c
r6274r6275
6565   if (!basename)
6666      basename = "tempfile.tmp";
6767
68   GetTempPath(sizeof(tempbuf) / sizeof(tempbuf[0]), tempbuf);
68   GetTempPath(ARRAY_LENGTH(tempbuf), tempbuf);
6969   t_filename = tstring_from_utf8(basename);
7070   _tcscat(tempbuf, t_filename);
7171   free(t_filename);
r6274r6275
478478   char *p;
479479   int i;
480480
481   GetLogicalDriveStringsA(sizeof(szBuffer) / sizeof(szBuffer[0]), szBuffer);
481   GetLogicalDriveStringsA(ARRAY_LENGTH(szBuffer), szBuffer);
482482
483483   i = 0;
484484   for (p = szBuffer; *p; p += (strlen(p) + 1))
r6274r6275
491491   static char szBuffer[128];
492492   const char *p;
493493
494   GetLogicalDriveStringsA(sizeof(szBuffer) / sizeof(szBuffer[0]), szBuffer);
494   GetLogicalDriveStringsA(ARRAY_LENGTH(szBuffer), szBuffer);
495495
496496   p = szBuffer;
497497   while(idx--)
src/mess/osd/winui/messui.c
r6274r6275
282282      {
283283         for (drv = drivers[drvindex]; drv; drv = driver_get_clone(drv))
284284         {
285            _snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%s/%s", drv->name, iconname);
285            _snprintf(buffer, ARRAY_LENGTH(buffer), "%s/%s", drv->name, iconname);
286286            hIcon = LoadIconFromFile(buffer);
287287            if (hIcon)
288288               break;
r6274r6275
433433         pszSoftware = GetSelectedSoftware(drvindex, config, dev);
434434         if (!pszSoftware || !*pszSoftware)
435435         {
436            snprintf(szMessage, sizeof(szMessage) / sizeof(szMessage[0]),
436            snprintf(szMessage, ARRAY_LENGTH(szMessage),
437437               "System '%s' requires that device %s must have an image to load\n",
438438               drivers[drvindex]->description,
439439               device_typename(info.type));
r6274r6275
815815   // allocate the machine config
816816   config = machine_config_alloc_with_mess_devices(drivers[drvindex]);
817817
818   SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev);
818   SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev);
819819
820820   if (CommonFileImageDialog(last_directory, cfd, filename, config, imagetypes))
821821   {
r6274r6275
911911   }
912912
913913   astring_free(as);
914   SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev);
914   SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev);
915915   bResult = CommonFileImageDialog(s, GetOpenFileName, pszFilename, config, imagetypes);
916916
917917   return bResult;
r6274r6275
972972
973973   astring_free(as);
974974
975   SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev);
975   SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev);
976976   bResult = CommonFileImageDialog(s, GetSaveFileName, pszFilename, config, imagetypes);
977977
978978   return bResult;
r6274r6275
11041104      MessSpecifyImage(drvindex, NULL, pszFullName);
11051105
11061106      // Set up s_szSelecteItem, for the benefit of UpdateScreenShot()
1107      strncpyz(g_szSelectedItem, pszName, sizeof(g_szSelectedItem) / sizeof(g_szSelectedItem[0]));
1107      strncpyz(g_szSelectedItem, pszName, ARRAY_LENGTH(g_szSelectedItem));
11081108      s = strrchr(g_szSelectedItem, '.');
11091109      if (s)
11101110         *s = '\0';
r6274r6275
13551355
13561356   memset(&opts, 0, sizeof(opts));
13571357   opts.pCallbacks = &s_softwareTabViewCallbacks;
1358   opts.nTabCount = sizeof(s_tabs) / sizeof(s_tabs[0]);
1358   opts.nTabCount = ARRAY_LENGTH(s_tabs);
13591359
13601360   SetupTabView(GetDlgItem(GetMainWindow(), IDC_SWTAB), &opts);
13611361}
src/mess/osd/winui/devview.c
r6274r6275
121121            pDevViewInfo->config->driver_index,
122122            pDevViewInfo->config->mconfig,
123123            pDevViewInfo->pEntries[i].dev,
124            szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]));
124            szBuffer, ARRAY_LENGTH(szBuffer));
125125
126126         if (!pszSelection)
127127            pszSelection = TEXT("");
r6274r6275
325325   {
326326      case 1:
327327         b = pDevViewInfo->pCallbacks->pfnGetOpenFileName(hwndDevView, pDevViewInfo->config->mconfig, pEnt->dev,
328            szPath, sizeof(szPath) / sizeof(szPath[0]));
328            szPath, ARRAY_LENGTH(szPath));
329329         break;
330330      case 2:
331331         b = pDevViewInfo->pCallbacks->pfnGetCreateFileName(hwndDevView, pDevViewInfo->config->mconfig, pEnt->dev,
332            szPath, sizeof(szPath) / sizeof(szPath[0]));
332            szPath, ARRAY_LENGTH(szPath));
333333         break;
334334      case 3:
335335         memset(szPath, 0, sizeof(szPath));
src/mess/osd/winui/softwarepicker.c
r6274r6275
410410   if ((device != NULL) && (image_device_getinfo(pPickerInfo->config->mconfig, device).has_partial_hash != 0))
411411      nCrc = 0;
412412   if (nCrc != 0)
413      snprintf(pInfo->hash_string, sizeof(pInfo->hash_string) / sizeof(pInfo->hash_string[0]), "c:%08x#", nCrc);
413      snprintf(pInfo->hash_string, ARRAY_LENGTH(pInfo->hash_string), "c:%08x#", nCrc);
414414
415415   // set up zip entry name length, if specified
416416   if (nZipEntryNameLength > 0)
src/mess/messopts.c
r6274r6275
108108
109109   /* retrieve info about the device instance */
110110   info = image_device_getinfo(config, device);
111   snprintf(dev_full_name, sizeof(dev_full_name) / sizeof(dev_full_name[0]),
111   snprintf(dev_full_name, ARRAY_LENGTH(dev_full_name),
112112      "%s;%s", info.instance_name, info.brief_instance_name);
113113
114114   /* add the option */
src/mess/artworkx.c
r6274r6275
4848
4949   /* concatenate the strings; first calculate length of the string */
5050   len = 1;
51   for (i = 0; i < sizeof(strs) / sizeof(strs[0]); i++)
51   for (i = 0; i < ARRAY_LENGTH(strs); i++)
5252   {
5353      if (strs[i])
5454         len += strlen(strs[i]) + 1;
r6274r6275
5959
6060   /* now actually concatenate the strings */
6161   pos = 0;
62   for (i = 0; i < sizeof(strs) / sizeof(strs[0]); i++)
62   for (i = 0; i < ARRAY_LENGTH(strs); i++)
6363   {
6464      if (strs[i])
6565      {
r6274r6275
104104      "misc.png",         "misc.ini"
105105   };
106106
107   if ((cust_type >= 0) && (cust_type < ((sizeof(cust_files) / sizeof(cust_files[0])) / 2)))
107   if ((cust_type >= 0) && (cust_type < (ARRAY_LENGTH(cust_files) / 2)))
108108   {
109109      png_filename = cust_files[cust_type * 2 + 0];
110110      ini_filename = cust_files[cust_type * 2 + 1];
r6274r6275
136136            if (buffer[0] == '[')
137137            {
138138               strncpyz(current_section, &buffer[1],
139                  sizeof(current_section) / sizeof(current_section[0]));
139                  ARRAY_LENGTH(current_section));
140140               p = strchr(current_section, ']');
141141               if (!p)
142142                  continue;
src/mess/machine/dgn_beta.c
r6274r6275
12921292   if ((oprom[0] == 0x10) && (oprom[1] == 0x3F))
12931293   {
12941294      call = oprom[2];
1295      if ((call >= 0) && (call < sizeof(os9syscalls) / sizeof(os9syscalls[0])) && os9syscalls[call])
1295      if ((call >= 0) && (call < ARRAY_LENGTH(os9syscalls)) && os9syscalls[call])
12961296      {
12971297         sprintf(buffer, "OS9   %s", os9syscalls[call]);
12981298         result = 3;
src/mess/machine/upd765.c
r6274r6275
18621862
18631863   if (LOG_COMMAND)
18641864   {
1865      if ((fdc->upd765_command_bytes[0] & 0x1f) < sizeof(commands) / sizeof(commands[0]))
1865      if ((fdc->upd765_command_bytes[0] & 0x1f) < ARRAY_LENGTH(commands))
18661866         cmd = commands[fdc->upd765_command_bytes[0] & 0x1f];
18671867      logerror("upd765_setup_command(): Setting up command 0x%02X (%s)\n",
18681868         fdc->upd765_command_bytes[0] & 0x1f, cmd ? cmd : "???");
src/mess/machine/cbmb.c
r6274r6275
512512
513513   /* Finally load the cart */
514514//  This could be needed with .crt support
515//  for (i = 0; (i < sizeof(pet_cbm_cart) / sizeof(pet_cbm_cart[0])) && (pet_cbm_cart[i].size != 0); i++)
515//  for (i = 0; (i < ARRAY_LENGTH(pet_cbm_cart)) && (pet_cbm_cart[i].size != 0); i++)
516516//      memcpy(cbmb_memory + cbmb_cbm_cart[i].addr + 0xf0000, cbmb_cbm_cart[i].chip, cbmb_cbm_cart[i].size);
517517   memcpy(cbmb_memory + cbmb_cbm_cart[0].addr + 0xf0000, cbmb_cbm_cart[0].chip, cbmb_cbm_cart[0].size);
518518
src/mess/machine/coco.c
r6274r6275
31663166   if ((oprom[0] == 0x10) && (oprom[1] == 0x3F))
31673167   {
31683168      call = oprom[2];
3169      if ((call >= 0) && (call < sizeof(os9syscalls) / sizeof(os9syscalls[0])) && os9syscalls[call])
3169      if ((call >= 0) && (call < ARRAY_LENGTH(os9syscalls)) && os9syscalls[call])
31703170      {
31713171         sprintf(buffer, "OS9   %s", os9syscalls[call]);
31723172         result = 3;
src/mess/machine/pet.c
r6274r6275
794794
795795   /* Finally load the cart */
796796//  This could be needed with .crt support
797//  for (i = 0; (i < sizeof(pet_cbm_cart) / sizeof(pet_cbm_cart[0])) && (pet_cbm_cart[i].size != 0); i++)
797//  for (i = 0; (i < ARRAY_LENGTH(pet_cbm_cart)) && (pet_cbm_cart[i].size != 0); i++)
798798//      memcpy(pet_memory + pet_cbm_cart[i].addr, pet_cbm_cart[i].chip, pet_cbm_cart[i].size);
799799   memcpy(pet_memory + pet_cbm_cart[0].addr, pet_cbm_cart[0].chip, pet_cbm_cart[0].size);
800800
src/mess/machine/cbmdrive.c
r6274r6275
17791779   cbm_drive_open_helper();
17801780
17811781   cbm_serial.count = 0;
1782   for (i = 0; i < sizeof(cbm_serial.atn) / sizeof(int); i++)
1782   for (i = 0; i < ARRAY_LENGTH(cbm_serial.atn); i++)
17831783
17841784   {
17851785      cbm_serial.atn[i] =
r6274r6275
17931793   int i;
17941794
17951795   cbm_serial.count = 0;
1796   for (i = 0; i < sizeof(cbm_drive) / sizeof(CBM_Drive); i++)
1796   for (i = 0; i < ARRAY_LENGTH(cbm_drive); i++)
17971797   {
17981798      cbm_drive[i].interface = 0;
17991799
src/mess/machine/vtech2.c
r6274r6275
109109   laser_latch = -1;
110110    mem = memory_region(machine, "maincpu");
111111
112   for (i = 0; i < sizeof(laser_bank) / sizeof(laser_bank[0]); i++)
112   for (i = 0; i < ARRAY_LENGTH(laser_bank); i++)
113113      laser_bank[i] = -1;
114114}
115115
r6274r6275
124124   videoram = mem + laser_video_bank * 0x04000;
125125   logerror("laser_machine_init(): bank mask $%04X, video %d [$%05X]\n", laser_bank_mask, laser_video_bank, laser_video_bank * 0x04000);
126126
127   for (i = 0; i < sizeof(laser_bank) / sizeof(laser_bank[0]); i++)
127   for (i = 0; i < ARRAY_LENGTH(laser_bank); i++)
128128      laser_bank_select_w(cputag_get_address_space(machine,"maincpu",ADDRESS_SPACE_PROGRAM), i, 0);
129129}
130130
src/mess/machine/apple2gs.c
r6274r6275
400400
401401static UINT8 adb_read_memory(UINT32 address)
402402{
403   if (address < (sizeof(adb_memory) / sizeof(adb_memory[0])))
403   if (address < ARRAY_LENGTH(adb_memory))
404404      return adb_memory[address];
405405   else
406406      return 0x00;
r6274r6275
410410
411411static void adb_write_memory(UINT32 address, UINT8 data)
412412{
413   if (address < (sizeof(adb_memory) / sizeof(adb_memory[0])))
413   if (address < ARRAY_LENGTH(adb_memory))
414414      adb_memory[address] = data;
415415}
416416
r6274r6275
432432
433433static void adb_post_response(const UINT8 *bytes, size_t length)
434434{
435   assert(length < (sizeof(adb_response_bytes) / sizeof(adb_response_bytes[0])));
435   assert(length < ARRAY_LENGTH(adb_response_bytes));
436436   memcpy(adb_response_bytes, bytes, length);
437437
438438   adb_state = ADBSTATE_INRESPONSE;
r6274r6275
666666         break;
667667
668668      case ADBSTATE_INCOMMAND:
669         assert(adb_command_pos < (sizeof(adb_command_bytes) / sizeof(adb_command_bytes[0])));
669         assert(adb_command_pos < ARRAY_LENGTH(adb_command_bytes));
670670         adb_command_bytes[adb_command_pos++] = data;
671671         break;
672672
src/mess/machine/mac.c
r6274r6275
32573257
32583258   int i;
32593259
3260   for (i = 0; i < (sizeof(traps) / sizeof(traps[0])); i++)
3260   for (i = 0; i < ARRAY_LENGTH(traps); i++)
32613261   {
32623262      if (traps[i].trap == opcode)
32633263         return traps[i].name;
r6274r6275
33543354      csCode = *((UINT16*) (mem + a0 + 26));
33553355      sprintf(s, " ioVRefNum=%i ioCRefNum=%i csCode=%i", ioVRefNum, ioCRefNum, csCode);
33563356
3357      for (i = 0; i < (sizeof(cscodes) / sizeof(cscodes[0])); i++)
3357      for (i = 0; i < ARRAY_LENGTH(cscodes); i++)
33583358      {
33593359         if (cscodes[i].csCode == csCode)
33603360         {
r6274r6275
33903390
33913391   case 0xa815:   /* _SCSIDispatch */
33923392      i = *((UINT16*) (mem + a7));
3393      if (i < (sizeof(scsisels) / sizeof(scsisels[0])))
3393      if (i < ARRAY_LENGTH(scsisels))
33943394         if (scsisels[i])
33953395            sprintf(s, " (%s)", scsisels[i]);
33963396      break;
src/mess/machine/nes_unif.c
r6274r6275
11851185const unif *nes_unif_lookup( const char *board )
11861186{
11871187   int i;
1188   for (i = 0; i < sizeof(unif_list) / sizeof(unif_list[0]); i++)
1188   for (i = 0; i < ARRAY_LENGTH(unif_list); i++)
11891189   {
11901190      if (!mame_stricmp(unif_list[i].board, board))
11911191         return &unif_list[i];
src/mess/machine/nes_ines.c
r6274r6275
1066510665const mmc *nes_mapper_lookup( int mapper )
1066610666{
1066710667   int i;
10668   for (i = 0; i < sizeof(mmc_list) / sizeof(mmc_list[0]); i++)
10668   for (i = 0; i < ARRAY_LENGTH(mmc_list); i++)
1066910669   {
1067010670      if (mmc_list[i].iNesMapper == nes.mapper)
1067110671         return &mmc_list[i];
src/mess/machine/bebox.c
r6274r6275
224224
225225   bebox_mbreg32_w(&bebox_crossproc_interrupts, data, mem_mask);
226226
227   for (i = 0; i < sizeof(crossproc_map) / sizeof(crossproc_map[0]); i++)
227   for (i = 0; i < ARRAY_LENGTH(crossproc_map); i++)
228228   {
229229      if ((old_crossproc_interrupts ^ bebox_crossproc_interrupts) & crossproc_map[i].mask)
230230      {
src/mess/machine/c64.c
r6274r6275
10941094      int j;
10951095      unsigned short c64_cart_type;
10961096
1097      for (i = 0; (i < sizeof(c64_cbm_cart) / sizeof(c64_cbm_cart[0])) && (c64_cbm_cart[i].size != 0); i++)
1097      for (i = 0; (i < ARRAY_LENGTH(c64_cbm_cart)) && (c64_cbm_cart[i].size != 0); i++)
10981098      ;
10991099
1100      if (i >= sizeof(c64_cbm_cart) / sizeof(c64_cbm_cart[0]))
1100      if (i >= ARRAY_LENGTH(c64_cbm_cart))
11011101         return INIT_FAIL;
11021102
11031103      /* Start to parse the .crt header */
src/mess/formats/flopimg.c
r6274r6275
911911      "Required parameter not specified"
912912   };
913913
914   if ((err < 0) || (err >= sizeof(error_messages) / sizeof(error_messages[0])))
914   if ((err < 0) || (err >= ARRAY_LENGTH(error_messages)))
915915      return NULL;
916916   return error_messages[err];
917917}
src/mess/formats/ap_dsk35.c
r6274r6275
200200   int sectors;
201201
202202   assert(track >= 0);
203   assert(track < sizeof(apple35_tracklen_800kb) / sizeof(apple35_tracklen_800kb[0]));
203   assert(track < ARRAY_LENGTH(apple35_tracklen_800kb));
204204
205205   if (get_apple35_tag(image)->is_1440k)
206206      sectors = 18;
r6274r6275
426426
427427   tag = get_apple35_tag(floppy);
428428
429   if (track >= (sizeof(apple35_tracklen_800kb) / sizeof(apple35_tracklen_800kb[0])))
429   if (track >= ARRAY_LENGTH(apple35_tracklen_800kb))
430430      return ~0;
431431   if (head >= tag->sides)
432432      return ~0;
r6274r6275
576576
577577   tag = get_apple35_tag(floppy);
578578
579   if (track >= (sizeof(apple35_tracklen_800kb) / sizeof(apple35_tracklen_800kb[0])))
579   if (track >= ARRAY_LENGTH(apple35_tracklen_800kb))
580580      return FLOPPY_ERROR_SEEKERROR;
581581   if (offset != 0)
582582      return FLOPPY_ERROR_UNSUPPORTED;
r6274r6275
588588   for (sector = 0; sector < sector_count; sector++)
589589   {
590590      /* read the sector */
591      err = apple35_read_sector_td(floppy, head, track, sector, sector_data, sizeof(sector_data) / sizeof(sector_data[0]));
591      err = apple35_read_sector_td(floppy, head, track, sector, sector_data, ARRAY_LENGTH(sector_data));
592592      if (err)
593593         return err;
594594      sony_nibblize35(sector_data, nibble_data, checksum);
595595
596      for (i = 0; i < (sizeof(blk1) / sizeof(blk1[0])); i++)
596      for (i = 0; i < ARRAY_LENGTH(blk1); i++)
597597         sony_filltrack(buffer, buflen, &pos, blk1[i]);
598598
599599      sum = (track ^ sector ^ side ^ tag->format_byte) & 0x3F;
r6274r6275
604604      sony_filltrack(buffer, buflen, &pos, diskbytes[tag->format_byte]);
605605      sony_filltrack(buffer, buflen, &pos, diskbytes[sum]);
606606
607      for (i = 0; i < (sizeof(blk2) / sizeof(blk2[0])); i++)
607      for (i = 0; i < ARRAY_LENGTH(blk2); i++)
608608         sony_filltrack(buffer, buflen, &pos, blk2[i]);
609609
610610      sony_filltrack(buffer, buflen, &pos, diskbytes[sector]);
611611
612      for (i = 0; i < (sizeof(nibble_data) / sizeof(nibble_data[0])); i++)
612      for (i = 0; i < ARRAY_LENGTH(nibble_data); i++)
613613         sony_filltrack(buffer, buflen, &pos, diskbytes[nibble_data[i]]);
614614
615615      for (i = 3; i >= 0; i--)
616616         sony_filltrack(buffer, buflen, &pos, diskbytes[checksum[i]]);
617617
618      for (i = 0; i < (sizeof(blk3) / sizeof(blk3[0])); i++)
618      for (i = 0; i < ARRAY_LENGTH(blk3); i++)
619619         sony_filltrack(buffer, buflen, &pos, blk3[i]);
620620   }
621621   return FLOPPY_ERROR_SUCCESS;
r6274r6275
637637
638638   tag = get_apple35_tag(floppy);
639639
640   if (track >= (sizeof(apple35_tracklen_800kb) / sizeof(apple35_tracklen_800kb[0])))
640   if (track >= ARRAY_LENGTH(apple35_tracklen_800kb))
641641      return FLOPPY_ERROR_SEEKERROR;
642642   if (offset != 0)
643643      return FLOPPY_ERROR_UNSUPPORTED;
r6274r6275
712712         continue;
713713      j++;
714714
715      for (i = 0; i < (sizeof(nibble_data) / sizeof(nibble_data[0])); i++)
715      for (i = 0; i < ARRAY_LENGTH(nibble_data); i++)
716716      {
717717         nibble_data[i] = rev_diskbytes[sony_fetchtrack(buffer, buflen, &pos)];
718718         j++;
r6274r6275
734734         sony_denibblize35(sector_data, nibble_data, checksum);
735735
736736         /* write the sector */
737         err = apple35_write_sector_td(floppy, head, track, sector, sector_data, sizeof(sector_data) / sizeof(sector_data[0]), 0);
737         err = apple35_write_sector_td(floppy, head, track, sector, sector_data, ARRAY_LENGTH(sector_data), 0);
738738         if (err)
739739            return err;
740740
src/mess/formats/ap2_dsk.c
r6274r6275
6565   if (!map_inited)
6666   {
6767      memset(map, 0xff, sizeof(map));
68      for (i = 0; i < sizeof(translate6) / sizeof(translate6[0]); i++)
68      for (i = 0; i < ARRAY_LENGTH(translate6); i++)
6969         map[translate6[i]] = i;
7070      map_inited = 1;
7171   }
src/mess/formats/pc_dsk.c
r6274r6275
4444   memset(geometry, 0, sizeof(*geometry));
4545   size = floppy_image_size(floppy);
4646
47   for (i = 0; i < sizeof(disk_sizes) / sizeof(disk_sizes[0]); i++)
47   for (i = 0; i < ARRAY_LENGTH(disk_sizes); i++)
4848   {
4949      if (disk_sizes[i].image_size == size)
5050      {
src/mess/formats/cassimg.c
r6274r6275
692692
693693   if (modulation->flags & CASSETTE_MODULATION_SINEWAVE)
694694   {
695      *wave_bytes_length = sizeof(sine_wave) / sizeof(sine_wave[0]);
695      *wave_bytes_length = ARRAY_LENGTH(sine_wave);
696696      return sine_wave;
697697   }
698698   else
699699   {
700      *wave_bytes_length = sizeof(square_wave) / sizeof(square_wave[0]);
700      *wave_bytes_length = ARRAY_LENGTH(square_wave);
701701      return square_wave;
702702   }
703703}
src/mess/drivers/c65.c
r6274r6275
226226   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
227227   MDRV_SCREEN_SIZE(525 * 2, 520 * 2)
228228   MDRV_SCREEN_VISIBLE_AREA(VIC6567_STARTVISIBLECOLUMNS ,(VIC6567_STARTVISIBLECOLUMNS + VIC6567_VISIBLECOLUMNS - 1) * 2, VIC6567_STARTVISIBLELINES, VIC6567_STARTVISIBLELINES + VIC6567_VISIBLELINES - 1)
229   MDRV_PALETTE_LENGTH(sizeof(vic3_palette) / sizeof(vic3_palette[0]) / 3)
229   MDRV_PALETTE_LENGTH(ARRAY_LENGTH(vic3_palette) / 3)
230230   MDRV_PALETTE_INIT( c65 )
231231
232232   /* sound hardware */
src/mess/drivers/a2600.c
r6274r6275
15071507{
15081508   int i;
15091509
1510   for ( i = 0; i < sizeof( supported_screen_heights ) / sizeof( supported_screen_heights[0] ); i++ )
1510   for ( i = 0; i < ARRAY_LENGTH(supported_screen_heights); i++ )
15111511   {
15121512      if ( data >= supported_screen_heights[i] - 3 && data <= supported_screen_heights[i] + 3 )
15131513      {
r6274r6275
15241524{
15251525   int i;
15261526
1527   for ( i = 0; i < sizeof( supported_screen_heights ) / sizeof( supported_screen_heights[0] ); i++ )
1527   for ( i = 0; i < ARRAY_LENGTH(supported_screen_heights); i++ )
15281528   {
15291529      if ( data >= supported_screen_heights[i] - 3 && data <= supported_screen_heights[i] + 3 )
15301530      {
src/mess/drivers/palm_dbg.c
r6274r6275
11521152
11531153    int i;
11541154
1155    for (i = 0; i < (sizeof(traps) / sizeof(traps[0])); i++)
1155    for (i = 0; i < ARRAY_LENGTH(traps); i++)
11561156    {
11571157        if (traps[i].trap == opcode)
11581158            return traps[i].name;
src/mess/drivers/psx.c
r6274r6275
909909      data = (data >> 8) & 0xff;
910910      logerror( "%08x cd1 write %02x\n", cpu_get_pc(space->cpu), data );
911911
912      if (data <= sizeof(psx_cdcmds) / sizeof(psx_cdcmds[0]))
912      if (data <= ARRAY_LENGTH(psx_cdcmds))
913913         psx_cdcmd = psx_cdcmds[data];
914914      else
915915         psx_cdcmd = NULL;
src/mess/drivers/svision.c
r6274r6275
494494   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
495495   MDRV_SCREEN_SIZE(3+160+3, 160)
496496   MDRV_SCREEN_VISIBLE_AREA(3+0, 3+160-1, 0, 160-1)
497   MDRV_PALETTE_LENGTH(sizeof(svision_palette) / (sizeof(svision_palette[0]) * 3))
497   MDRV_PALETTE_LENGTH(ARRAY_LENGTH(svision_palette) * 3)
498498   MDRV_PALETTE_INIT( svision )
499499
500500   MDRV_VIDEO_UPDATE( svision )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team