projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20010115-1-src
[rocksndiamonds.git]
/
src
/
libgame
/
misc.c
diff --git
a/src/libgame/misc.c
b/src/libgame/misc.c
index 5814e8d17f9e42464e69c39f77fe6b67c58cb5f5..e144979a7bb40ed1c2a38132e7860629477041ff 100644
(file)
--- a/
src/libgame/misc.c
+++ b/
src/libgame/misc.c
@@
-1,7
+1,7
@@
/***********************************************************
* Artsoft Retro-Game Library *
*----------------------------------------------------------*
/***********************************************************
* Artsoft Retro-Game Library *
*----------------------------------------------------------*
-* (c) 1994-200
0
Artsoft Entertainment *
+* (c) 1994-200
1
Artsoft Entertainment *
* Holger Schemel *
* Detmolder Strasse 189 *
* 33604 Bielefeld *
* Holger Schemel *
* Detmolder Strasse 189 *
* 33604 Bielefeld *
@@
-551,15
+551,18
@@
void Error(int mode, char *format, ...)
{
char *process_name = "";
FILE *error = stderr;
{
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)
/* 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)
{
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
program.exit_function(1);
}
#endif
@@
-584,15
+587,16
@@
void Error(int mode, char *format, ...)
vfprintf(error, format, ap);
va_end(ap);
vfprintf(error, format, ap);
va_end(ap);
- fprintf(error, "
\n"
);
+ fprintf(error, "
%s", newline
);
}
if (mode & ERR_HELP)
}
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)
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);
if (error != stderr)
fclose(error);
@@
-630,6
+634,16
@@
void *checked_calloc(unsigned long size)
return ptr;
}
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)
short getFile16BitInteger(FILE *file, int byte_order)
{
if (byte_order == BYTE_ORDER_BIG_ENDIAN)
@@
-1314,7
+1328,7
@@
FILE *openErrorFile()
FILE *error_file;
filename = getPath2(getUserDataDir(), ERROR_FILENAME);
FILE *error_file;
filename = getPath2(getUserDataDir(), ERROR_FILENAME);
- error_file = fopen(filename,
"a"
);
+ error_file = fopen(filename,
MODE_APPEND
);
free(filename);
return error_file;
free(filename);
return error_file;
@@
-1326,7
+1340,7
@@
void dumpErrorFile()
FILE *error_file;
filename = getPath2(getUserDataDir(), ERROR_FILENAME);
FILE *error_file;
filename = getPath2(getUserDataDir(), ERROR_FILENAME);
- error_file = fopen(filename,
"r"
);
+ error_file = fopen(filename,
MODE_READ
);
free(filename);
if (error_file != NULL)
free(filename);
if (error_file != NULL)