rocksndiamonds-3.0.8
[rocksndiamonds.git] / src / libgame / msdos.c
index ec19ef6389c7d639c99f9106ef17826ff53de950..a82da6cda9b3006e06b44ee4cea20a8d8e8fe3b7 100644 (file)
@@ -60,10 +60,10 @@ static void allegro_init_drivers()
 {
   int i;
 
-  for (i=0; i<MAX_EVENT_BUFFER; i++)
+  for (i = 0; i < MAX_EVENT_BUFFER; i++)
     event_buffer[i].type = 0;
 
-  for (i=0; i<MAX_SCANCODES; i++)
+  for (i = 0; i < MAX_SCANCODES; i++)
     key_press_state[i] = KeyReleaseMask;
 
   last_mouse_pos = mouse_pos;
@@ -244,7 +244,7 @@ Pixel AllegroAllocColorCell(int r, int g, int b)
   b >>= 10;
 
   /* try to use existing colors from the global colormap */
-  for (i=0; i<global_colormap_entries_used; i++)
+  for (i = 0; i < global_colormap_entries_used; i++)
   {
     if (r == global_colormap[i].r &&
        g == global_colormap[i].g &&
@@ -378,8 +378,7 @@ Status XStringListToTextProperty(char **list, int count,
 
 void XFree(void *data)
 {
-  if (data)
-    free(data);
+  checked_free(data);
 }
 
 GC XCreateGC(Display *display, Drawable d, unsigned long value_mask,
@@ -516,7 +515,7 @@ static BITMAP *Image_to_AllegroBitmap(Image *image)
   clear(bitmap);
 
   /* try to use existing colors from the global colormap */
-  for (i=0; i<MAX_COLORS; i++)
+  for (i = 0; i < MAX_COLORS; i++)
   {
     if (!image->rgb.color_used[i])
       continue;
@@ -527,8 +526,8 @@ static BITMAP *Image_to_AllegroBitmap(Image *image)
   }
 
   /* copy bitmap data */
-  for (y=0; y<image->height; y++)
-    for (x=0; x<image->width; x++)
+  for (y = 0; y < image->height; y++)
+    for (x = 0; x < image->width; x++)
       putpixel(bitmap, x, y, pixel_mapping[*src_ptr++]);
 
   return bitmap;
@@ -598,11 +597,9 @@ void XFreePixmap(Display *display, Pixmap pixmap)
 
 void XFreeGC(Display *display, GC gc)
 {
-  XGCValues *gcv;
+  XGCValues *gcv = (XGCValues *)gc;
 
-  gcv = (XGCValues *)gc;
-  if (gcv)
-    free(gcv);
+  checked_free(gcv);
 }
 
 void XUnmapWindow(Display *display, Window window)
@@ -616,11 +613,8 @@ void XCloseDisplay(Display *display)
   if (is_screen_bitmap(bitmap))
     destroy_bitmap(bitmap);
 
-  if (display->screens)
-    free(display->screens);
-
-  if (display)
-    free(display);
+  checked_free(display->screens);
+  checked_free(display);
 
   /* return to text mode (or DOS box on Windows screen) */
   set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
@@ -671,7 +665,7 @@ static void HandleKeyboardRaw(int mode)
 {
   int i;
 
-  for (i=0; i<MAX_SCANCODES; i++)
+  for (i = 0; i < MAX_SCANCODES; i++)
   {
     int scancode, new_state, event_type;
     char key_pressed;
@@ -783,7 +777,7 @@ int XPending(Display *display)
   /* mouse button event */
   if (mouse_b != last_mouse_b)
   {
-    for (i=0; i<3; i++)                /* check all three mouse buttons */
+    for (i = 0; i < 3; i++)    /* check all three mouse buttons */
     {
       int bitmask = (1 << i);
 
@@ -969,7 +963,7 @@ void MSDOSInitJoysticks()
       install_joystick(JOY_TYPE_AUTODETECT) == 0)
     joystick.status = JOYSTICK_ACTIVATED;
 
-  for (i=0; i<MAX_PLAYERS; i++)
+  for (i = 0; i < MAX_PLAYERS; i++)
   {
     char *device_name = setup.input[i].joy.device_name;
     int joystick_nr = getJoystickNrFromDeviceName(device_name);