X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flibgame%2Fmisc.c;h=e144979a7bb40ed1c2a38132e7860629477041ff;hb=681721dddc91bcdaef50002d1e861cc8d484e938;hp=e62229a42ec902ee55d3cc5411dee7f68d49f7b6;hpb=e0560b41a1796a02b15937b0ae5453bca745e5ff;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index e62229a4..e144979a 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1,7 +1,7 @@ /*********************************************************** * Artsoft Retro-Game Library * *----------------------------------------------------------* -* (c) 1994-2000 Artsoft Entertainment * +* (c) 1994-2001 Artsoft Entertainment * * Holger Schemel * * Detmolder Strasse 189 * * 33604 Bielefeld * @@ -551,15 +551,18 @@ void Error(int mode, char *format, ...) { char *process_name = ""; FILE *error = stderr; + char *newline = "\n"; /* display warnings only when running in verbose mode */ if (mode & ERR_WARN && !options.verbose) return; #if !defined(PLATFORM_UNIX) + newline = "\r\n"; + if ((error = openErrorFile()) == NULL) { - printf("Cannot write to error output file!\n"); + printf("Cannot write to error output file!%s", newline); program.exit_function(1); } #endif @@ -584,15 +587,16 @@ void Error(int mode, char *format, ...) vfprintf(error, format, ap); va_end(ap); - fprintf(error, "\n"); + fprintf(error, "%s", newline); } if (mode & ERR_HELP) - fprintf(error, "%s: Try option '--help' for more information.\n", - program.command_basename); + fprintf(error, "%s: Try option '--help' for more information.%s", + program.command_basename, newline); if (mode & ERR_EXIT) - fprintf(error, "%s%s: aborting\n", program.command_basename, process_name); + fprintf(error, "%s%s: aborting%s", + program.command_basename, process_name, newline); if (error != stderr) fclose(error); @@ -630,6 +634,16 @@ void *checked_calloc(unsigned long size) return ptr; } +void *checked_realloc(void *ptr, unsigned long size) +{ + ptr = realloc(ptr, size); + + if (ptr == NULL) + Error(ERR_EXIT, "cannot allocate %d bytes -- out of memory", size); + + return ptr; +} + short getFile16BitInteger(FILE *file, int byte_order) { if (byte_order == BYTE_ORDER_BIG_ENDIAN)