Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[Freeciv-Dev] (PR#3609) Set members of sprite to NULL in free_sprite
Home

[Freeciv-Dev] (PR#3609) Set members of sprite to NULL in free_sprite

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3609) Set members of sprite to NULL in free_sprite
From: "Raimar Falke" <rf13@xxxxxxxxxxxxxxxxx>
Date: Tue, 4 Mar 2003 11:30:42 -0800
Reply-to: rt@xxxxxxxxxxxxxx


This is a debugging aid for the new sprite loading to find sprite
pointer which are already freed.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Are you saying that you actually used the Classpath Java AWT classes in 
  addition to the GTK peers and got them to display something?
  Wow.  That's way better than I did and I wrote the code!"
    -- Aaron M. Renn in the classpath mailing list

Index: client/gui-gtk/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/graphics.c,v
retrieving revision 1.48
diff -u -u -r1.48 graphics.c
--- client/gui-gtk/graphics.c   2003/01/29 05:10:49     1.48
+++ client/gui-gtk/graphics.c   2003/03/04 19:28:30
@@ -339,11 +339,11 @@
 /***************************************************************************
    Deletes a sprite.  These things can use a lot of memory.
 ***************************************************************************/
-void free_sprite(SPRITE *s)
+void free_sprite(SPRITE * s)
 {
   gdk_imlib_free_pixmap(s->pixmap);
+  s->pixmap = NULL;
   free(s);
-  return;
 }
 
 /***************************************************************************
Index: client/gui-gtk-2.0/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/graphics.c,v
retrieving revision 1.13
diff -u -u -r1.13 graphics.c
--- client/gui-gtk-2.0/graphics.c       2003/02/26 23:49:49     1.13
+++ client/gui-gtk-2.0/graphics.c       2003/03/04 19:28:31
@@ -329,14 +329,17 @@
 /***************************************************************************
    Deletes a sprite.  These things can use a lot of memory.
 ***************************************************************************/
-void free_sprite(SPRITE *s)
+void free_sprite(SPRITE * s)
 {
-  if (s->pixmap)
+  if (s->pixmap) {
     g_object_unref(s->pixmap);
-  if (s->mask)
+    s->pixmap = NULL;
+  }
+  if (s->mask) {
     g_object_unref(s->mask);
+    s->mask = NULL;
+  }
   free(s);
-  return;
 }
 
 /***************************************************************************
Index: client/gui-win32/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/graphics.c,v
retrieving revision 1.13
diff -u -u -r1.13 graphics.c
--- client/gui-win32/graphics.c 2003/01/23 21:39:32     1.13
+++ client/gui-win32/graphics.c 2003/03/04 19:28:33
@@ -507,21 +507,21 @@
 /**************************************************************************
 
 **************************************************************************/
-void
-free_sprite(struct Sprite *s)
+void free_sprite(struct Sprite *s)
 {
-  if (s->has_mask)
-    {
-      free(s->mask.bmBits);
-    }
-  
-  
+  if (s->has_mask) {
+    free(s->mask.bmBits);
+    s->mask = NULL;
+  }
+
   free(s->bmp.bmBits);
-  
+  s->bmp = NULL;
+
   free(s);
-  if (bitmapcache)
+  if (bitmapcache) {
     DeleteObject(bitmapcache);
-  sprcache=NULL;
+  }
+  sprcache = NULL;
 }
 
 /**************************************************************************
Index: client/gui-xaw/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/graphics.c,v
retrieving revision 1.46
diff -u -u -r1.46 graphics.c
--- client/gui-xaw/graphics.c   2002/12/17 22:41:04     1.46
+++ client/gui-xaw/graphics.c   2003/03/04 19:28:34
@@ -497,9 +497,9 @@
   }
   free_colors(s->pcolorarray, s->ncols);
   free(s->pcolorarray);
+  s->pcolorarray = NULL;
   free(s);
 }
-
 
 /***************************************************************************
 ...

[Prev in Thread] Current Thread [Next in Thread]