--- uae/src/missing.c 2018/04/24 16:40:05 1.1.1.1 +++ uae/src/missing.c 2018/04/24 16:58:27 1.1.1.3 @@ -25,52 +25,22 @@ char *my_strdup (const char *s) #endif -#ifndef HAVE_GETOPT - -/* This isn't a complete getopt, but it's good enough for UAE. */ -char *optarg; -int optind = 0; - -int getopt (int argc, char *const *argv, const char *str) +void *xmalloc (size_t n) { - char *p, c; - - if (optind == 0) - optind = 1; - for (;;) { - while (optind < argc && (argv[optind][0] != '-' || argv[optind][1] == '\0')) - optind++; - if (optind >= argc) - return EOF; - p = strchr (str, c = argv[optind][1]); - if (p == 0) { - sprintf (warning_buffer, "Commandline parsing error - invalid option \"-%c\".\n", argv[optind][1]); - write_log (warning_buffer); - optind++; - continue; - } - break; - } - if (*(p+1) == ':') { - if (argv[optind][2] == '\0') { - optarg = argv[optind + 1]; - optind++; - } else { - optarg = argv[optind] + 2; - } + void *a = malloc (n); + if (a == NULL) { + fprintf (stderr, "virtual memory exhausted\n"); + abort (); } - optind++; - return c; + return a; } -#endif - -void *xmalloc(size_t n) +void *xcalloc (size_t n, size_t size) { - void *a = malloc (n); + void *a = calloc (n, size); if (a == NULL) { - write_log ("virtual memory exhausted\n"); - abort(); + fprintf (stderr, "virtual memory exhausted\n"); + abort (); } return a; }