rnd-20001211-1-src
[rocksndiamonds.git] / src / libgame / misc.c
index b2ee47177cb9131596f4558f04c17d946091151b..b72fa146cd684385f84190b654cfd66b8a784233 100644 (file)
@@ -1,14 +1,14 @@
 /***********************************************************
-*  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
+* Artsoft Retro-Game Library                               *
 *----------------------------------------------------------*
-*  (c) 1995-98 Artsoft Entertainment                       *
-*              Holger Schemel                              *
-*              Oststrasse 11a                              *
-*              33604 Bielefeld                             *
-*              phone: ++49 +521 290471                     *
-*              email: aeglos@valinor.owl.de                *
+* (c) 1994-2000 Artsoft Entertainment                      *
+*               Holger Schemel                             *
+*               Detmolder Strasse 189                      *
+*               33604 Bielefeld                            *
+*               Germany                                    *
+*               e-mail: info@artsoft.org                   *
 *----------------------------------------------------------*
-*  misc.c                                                  *
+* misc.c                                                   *
 ***********************************************************/
 
 #include <time.h>
 #include <sys/param.h>
 #endif
 
-#include "libgame.h"
-
 #include "misc.h"
+#include "random.h"
 
-#if 0
-#include "joystick_TMP.h"
-#endif
 
 #if defined(PLATFORM_MSDOS)
 volatile unsigned long counter = 0;
@@ -634,6 +630,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)
@@ -1318,7 +1324,7 @@ FILE *openErrorFile()
   FILE *error_file;
 
   filename = getPath2(getUserDataDir(), ERROR_FILENAME);
-  error_file = fopen(filename, "a");
+  error_file = fopen(filename, MODE_APPEND);
   free(filename);
 
   return error_file;
@@ -1330,7 +1336,7 @@ void dumpErrorFile()
   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)