diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11_common.c XBlast-TNT.modify/x11_common.c
--- XBlast-TNT.orig/x11_common.c	2000-05-30 11:06:57.000000000 +0200
+++ XBlast-TNT.modify/x11_common.c	2002-05-25 12:57:09.000000000 +0200
@@ -39,9 +39,9 @@
 char *xblastResName  = "xblast"; 
 char *xblastResClass = "XBlast";
 
-GC gcFromPix;  /* context to draw from pixmap into window */
-GC gcWindow;   /* context to clear window */
-GC gcClearPix; /* context to clear pixmap */
+GC gcFromPix=NULL;  /* context to draw from pixmap into window */
+GC gcWindow=NULL;   /* context to clear window */
+GC gcClearPix=NULL; /* context to clear pixmap */
 
 Pixmap pix;    /* pixmap for double buffering */

diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11c_image.c XBlast-TNT.modify/x11c_image.c
--- XBlast-TNT.orig/x11c_image.c	2001-04-16 16:48:16.000000000 +0200
+++ XBlast-TNT.modify/x11c_image.c	2002-05-25 12:38:31.000000000 +0200
@@ -255,6 +255,7 @@
     fprintf (stderr, "Blue:  mask=%08lx, bits=%d, shift=%d\n", bmask, bbits, bshift);
 #endif
     ppm_to_image   = PpmToImageRgb;
+    XFree(result);
   } else {
     /* 8 bit display with color map */
     int r,g,b;
diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11c_init.c XBlast-TNT.modify/x11c_init.c
--- XBlast-TNT.orig/x11c_init.c	2001-05-04 22:26:40.000000000 +0200
+++ XBlast-TNT.modify/x11c_init.c	2002-05-25 13:24:18.000000000 +0200
@@ -189,6 +189,7 @@
   xch->res_class = xblastResClass;
 
   XSetClassHint(dpy, win, xch);
+  XFree(xch);
   /* set min and max geometry */
   if (NULL == (xsh = XAllocSizeHints())) {
     fprintf (stderr, "alloc failed\n");
@@ -200,6 +201,7 @@
   xsh->min_height = PIXH+SCOREH;
   xsh->max_height = PIXH+SCOREH;
   XSetWMSizeHints (dpy, win, xsh, XA_WM_NORMAL_HINTS);
+  XFree(xsh);
   /* create graphics context for window */
   xgcv.foreground = blackPixel;
   xgcv.background = whitePixel;
@@ -313,6 +315,12 @@
   FinishEvent ();
   /* shutdown connection to x-server */
   if (dpy != NULL) {
+    if (gcWindow)
+      XFreeGC(dpy,gcWindow);
+    ReleaseTiles(dpy);
+    ReleaseSprites(dpy);
+    ReleasePixmap(dpy);
+    ReleaseFonts(dpy);
     XCloseDisplay (dpy);
   }
 } /* GUI_Finish */
diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11c_pixmap.c XBlast-TNT.modify/x11c_pixmap.c
--- XBlast-TNT.orig/x11c_pixmap.c	2001-06-04 16:48:48.000000000 +0200
+++ XBlast-TNT.modify/x11c_pixmap.c	2002-05-25 13:30:40.000000000 +0200
@@ -72,6 +72,19 @@
   return XBTrue;
 } /* InitPixmap */
 
+/*
+ *
+ */
+void
+ReleasePixmap (void *arg)
+{
+  Display *dpy = arg;
+  if (gcFromPix)
+    XFreeGC(dpy,gcFromPix);
+  if (gcClearPix)
+    XFreeGC(dpy,gcClearPix);
+} /* ReleasePixmap */
+
 /* 
  *
  */
diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11c_pixmap.h XBlast-TNT.modify/x11c_pixmap.h
--- XBlast-TNT.orig/x11c_pixmap.h	2000-05-30 11:05:28.000000000 +0200
+++ XBlast-TNT.modify/x11c_pixmap.h	2002-05-25 13:30:51.000000000 +0200
@@ -26,6 +26,7 @@
 #include "xblast.h"
 
 extern XBBool InitPixmap (void);
+extern void ReleasePixmap (void *);
 
 #endif
 /*
diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11c_sprite.c XBlast-TNT.modify/x11c_sprite.c
--- XBlast-TNT.orig/x11c_sprite.c	2001-07-01 18:05:46.000000000 +0200
+++ XBlast-TNT.modify/x11c_sprite.c	2002-05-25 14:11:49.000000000 +0200
@@ -34,8 +34,8 @@
 /*
  * local variables
  */
-static GC gcSpriteMask;
-static GC gcSpriteBits;
+static GC gcSpriteMask=NULL;
+static GC gcSpriteBits=NULL;
 
 static Pixmap pixBombMask[MAX_BOMBS][MAX_BOMB_ANIME];
 static Pixmap pixBombBits[MAX_BOMBS][MAX_BOMB_ANIME];
@@ -122,6 +122,19 @@
 } /* Init Sprites */
 
 /*
+ *
+ */
+void
+ReleaseSprites (void *arg)
+{
+  Display *dpy = arg;
+  if (gcSpriteMask)
+    XFreeGC(dpy,gcSpriteMask);
+  if (gcSpriteBits)
+    XFreeGC(dpy,gcSpriteBits);
+} /* ReleaseSprites */
+
+/*
  * load a single player sprite animation
  */
 XBBool
diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11c_sprite.h XBlast-TNT.modify/x11c_sprite.h
--- XBlast-TNT.orig/x11c_sprite.h	2000-05-30 11:04:07.000000000 +0200
+++ XBlast-TNT.modify/x11c_sprite.h	2002-05-25 14:10:57.000000000 +0200
@@ -30,6 +30,7 @@
  */
 extern XBBool InitSprites (void);
 extern void CopyExplosion (Pixmap pix_tile, int i);
+extern void ReleaseSprites (void *);
 
 #endif
 /*
diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11c_text.c XBlast-TNT.modify/x11c_text.c
--- XBlast-TNT.orig/x11c_text.c	2001-07-01 18:05:21.000000000 +0200
+++ XBlast-TNT.modify/x11c_text.c	2002-05-25 13:30:22.000000000 +0200
@@ -33,8 +33,8 @@
 /*
  * local variables
  */
-static GC gcTextBlack;
-static GC gcTextWhite;
+static GC gcTextBlack=NULL;
+static GC gcTextWhite=NULL;
 static XFontStruct *fontStruct[NUM_FONTS];
 
 /*
@@ -71,11 +71,15 @@
   /* gc black text */
   xgcv.fill_style = FillTiled;
   xgcv.tile       = ReadCchPixmap (imgPathMisc, imgFileTextBg, COLOR_BLACK, cfgColor->darkText1, cfgColor->darkText2);
+  if (xgcv.tile == 0)
+    return XBFalse;
   xgcv.line_width = BASE_X/4;
   gcTextBlack     = XCreateGC(dpy, pix, GCTile|GCFillStyle|GCLineWidth, &xgcv);
   /* gc white text */
   xgcv.fill_style = FillTiled;
   xgcv.tile       = ReadCchPixmap (imgPathMisc, imgFileTextFg, COLOR_BLACK, cfgColor->lightText1, cfgColor->lightText2);
+  if (xgcv.tile == 0)
+    return XBFalse;
   xgcv.line_width = BASE_X/4;
   gcTextWhite     = XCreateGC (dpy, pix, GCTile|GCFillStyle| GCLineWidth, &xgcv);
   /* try to load fonts */
@@ -91,6 +95,19 @@
 } /* InitFonts */
 
 /*
+ *
+ */
+void
+ReleaseFonts (void *arg) 
+{
+  Display *dpy = arg;
+  if (gcTextBlack)
+    XFreeGC(dpy,gcTextBlack);
+  if (gcTextWhite)
+    XFreeGC(dpy,gcTextWhite);
+} /* ReleaseFonts */
+
+/*
  * draw simple textbox (in game)
  */
 void
diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11c_text.h XBlast-TNT.modify/x11c_text.h
--- XBlast-TNT.orig/x11c_text.h	2000-05-30 11:03:50.000000000 +0200
+++ XBlast-TNT.modify/x11c_text.h	2002-05-25 13:28:34.000000000 +0200
@@ -26,6 +26,7 @@
 #include "xblast.h"
 
 extern XBBool InitFonts (void);
+extern void ReleaseFonts (void *);
 
 #endif
 /*
diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11c_tile.c XBlast-TNT.modify/x11c_tile.c
--- XBlast-TNT.orig/x11c_tile.c	2001-07-01 19:20:23.000000000 +0200
+++ XBlast-TNT.modify/x11c_tile.c	2002-05-25 13:30:06.000000000 +0200
@@ -35,7 +35,7 @@
 /*
  * local variables
  */
-static GC gcDrawBlock;
+static GC gcDrawBlock=NULL;
 
 static Pixmap pixBlock[MAX_TILE];
 static Pixmap pixExplBlock[MAX_EXPLOSION];
@@ -108,6 +108,17 @@
   return XBTrue;
 } /* InitTiles */
 
+/*
+ *
+ */
+void
+ReleaseTiles (void *arg)
+{
+  Display *dpy = arg;
+  if (gcDrawBlock)
+    XFreeGC(dpy,gcDrawBlock);
+} /* ReleaseTiles */
+
 /* 
  * 
  */
diff -Naur --exclude=level --exclude=image --exclude=Makefile --exclude='*.raw' XBlast-TNT.orig/x11c_tile.h XBlast-TNT.modify/x11c_tile.h
--- XBlast-TNT.orig/x11c_tile.h	2000-05-30 11:02:11.000000000 +0200
+++ XBlast-TNT.modify/x11c_tile.h	2002-05-25 13:29:45.000000000 +0200
@@ -26,6 +26,7 @@
 #include "xblast.h"
 
 extern XBBool InitTiles (void);
+extern void ReleaseTiles (void *);
 
 #endif
 /*

