Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] (PR#6885) Remove memory leaks in xaw with quit_freeciv
Home

[Freeciv-Dev] (PR#6885) Remove memory leaks in xaw with quit_freeciv

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#6885) Remove memory leaks in xaw with quit_freeciv
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Sun, 16 Nov 2003 04:29:49 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=6885 >


The xaw client doesn't leave the ui_main function in a normal
way. This leaves a lot of memory still allocated. The attached patch
fixes this.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "It is not yet possible to change operating system by writing
  to /proc/sys/kernel/ostype."              sysctl(2) man page

Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.180
diff -u -u -r1.180 civclient.c
--- client/civclient.c  2003/11/10 20:33:58     1.180
+++ client/civclient.c  2003/11/16 12:16:19
@@ -244,6 +244,17 @@
   ui_main(argc, argv);
 
   /* termination */
+  quit_freeciv();
+  
+  /* not reached */
+  return EXIT_SUCCESS;
+}
+
+/**************************************************************************
+...
+**************************************************************************/
+void quit_freeciv(void)
+{
   attribute_flush();
   client_remove_all_cli_conn();
   my_shutdown_network();
@@ -252,7 +263,6 @@
 
   exit(EXIT_SUCCESS);
 }
-
 
 /**************************************************************************
 ...
Index: client/civclient.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.h,v
retrieving revision 1.30
diff -u -u -r1.30 civclient.h
--- client/civclient.h  2003/07/10 03:34:29     1.30
+++ client/civclient.h  2003/11/16 12:16:19
@@ -64,5 +64,6 @@
 
 void client_game_init(void);
 void client_game_free(void);
+void quit_freeciv(void);
 
 #endif  /* FC__CIVCLIENT_H */
Index: client/gui-xaw/actions.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/actions.c,v
retrieving revision 1.17
diff -u -u -r1.17 actions.c
--- client/gui-xaw/actions.c    2003/07/23 13:46:03     1.17
+++ client/gui-xaw/actions.c    2003/11/16 12:16:20
@@ -596,7 +596,7 @@
 
 static void xaw_msg_quit_freeciv(Widget w, XEvent *event, String *argv, 
Cardinal *argc)
 {
-  main_quit_freeciv();
+  xaw_quit_freeciv();
 }
 
 
/*******************************************************************************
Index: client/gui-xaw/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.c,v
retrieving revision 1.83
diff -u -u -r1.83 gui_main.c
--- client/gui-xaw/gui_main.c   2003/08/06 07:34:38     1.83
+++ client/gui-xaw/gui_main.c   2003/11/16 12:16:20
@@ -685,9 +685,10 @@
 /**************************************************************************
 ...
 **************************************************************************/
-void main_quit_freeciv(void)
-{ 
-  exit(EXIT_SUCCESS);
+void xaw_quit_freeciv(void)
+{
+  tilespec_free_tiles();
+  quit_freeciv();
 }
 
 /**************************************************************************
Index: client/gui-xaw/gui_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.h,v
retrieving revision 1.10
diff -u -u -r1.10 gui_main.h
--- client/gui-xaw/gui_main.h   2003/07/23 13:46:03     1.10
+++ client/gui-xaw/gui_main.h   2003/11/16 12:16:20
@@ -17,7 +17,7 @@
 
 #include "gui_main_g.h"
 
-void main_quit_freeciv(void);
+void xaw_quit_freeciv(void);
 void main_show_info_popup(XEvent *event);
 
 extern Atom         wm_delete_window;
Index: client/gui-xaw/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/menu.c,v
retrieving revision 1.57
diff -u -u -r1.57 menu.c
--- client/gui-xaw/menu.c       2003/09/15 16:05:35     1.57
+++ client/gui-xaw/menu.c       2003/11/16 12:16:21
@@ -39,6 +39,7 @@
 #include "dialogs.h"
 #include "finddlg.h"
 #include "gotodlg.h"
+#include "gui_main.h"
 #include "gui_stuff.h"
 #include "helpdlg.h"
 #include "mapctrl.h" 
@@ -478,7 +479,7 @@
     disconnect_from_server();
     break;
   case MENU_GAME_QUIT:
-    exit(EXIT_SUCCESS);
+    xaw_quit_freeciv();
     break;
   }
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#6885) Remove memory leaks in xaw with quit_freeciv, Raimar Falke <=