Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2006:
[Freeciv-Dev] (PR#3372) Clutter: gui_mem "hacks" in sdl client
Home

[Freeciv-Dev] (PR#3372) Clutter: gui_mem "hacks" in sdl client

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#3372) Clutter: gui_mem "hacks" in sdl client
From: "Christian Prochaska" <cp.ml.freeciv.dev@xxxxxxxxxxxxxx>
Date: Sun, 15 Jan 2006 10:25:11 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=3372 >

> [jdorje - Mo 10. Feb 2003, 03:30:20]:
> 
> The sdl client contains its own set of memory macros in gui_mem.  For
> the most part this is a hack: it is extra code that is unneeded in most
> cases.  It may hide some bugs, but those bugs should be found and fixed.
>  Valgrind may help with this.
> 
> jason
> 
> 

Here's a patch. The macros are replaced by the ones from utility/mem.h
and gui-mem.h will be removed.
Index: client/gui-sdl/optiondlg.c
===================================================================
--- client/gui-sdl/optiondlg.c  (Revision 11444)
+++ client/gui-sdl/optiondlg.c  (Arbeitskopie)
@@ -48,7 +48,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "mapctrl.h"
@@ -352,7 +351,7 @@
   }
   /* ----------------------------- */
   
-  pOption_Dlg->pADlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pOption_Dlg->pADlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
   pOption_Dlg->pADlg->pEndWidgetList = pOption_Dlg->pEndOptionsWidgetList;   
   
@@ -363,7 +362,7 @@
   pOption_Dlg->pADlg->pBeginWidgetList = pBuf;
   
   
-  pOption_Dlg->pADlg->pScroll = MALLOC(sizeof(struct ScrollBar));
+  pOption_Dlg->pADlg->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
   pOption_Dlg->pADlg->pScroll->count = count;
   pOption_Dlg->pADlg->pScroll->active = 13;
   pOption_Dlg->pADlg->pScroll->step = 1;
@@ -809,7 +808,7 @@
 {
   char *tmp = convert_to_chars(pWidget->string16->text);
   sscanf(tmp, "%d", &smooth_move_unit_msec);
-  FREE(tmp);
+  FC_FREE(tmp);
   return -1;
 }
 
@@ -1959,8 +1958,8 @@
 {
 
   if(pOption_Dlg->pADlg) {
-    FREE(pOption_Dlg->pADlg->pScroll);
-    FREE(pOption_Dlg->pADlg);
+    FC_FREE(pOption_Dlg->pADlg->pScroll);
+    FC_FREE(pOption_Dlg->pADlg);
   }
   
   if (SDL_Client_Flags & CF_OPTION_MAIN) {
@@ -2060,7 +2059,7 @@
   popdown_all_game_dialogs();
   flush_dirty();
   
-  pOption_Dlg = MALLOC(sizeof(struct OPT_DLG));
+  pOption_Dlg = fc_calloc(1, sizeof(struct OPT_DLG));
   pOption_Dlg->pADlg = NULL;
   pLogo = get_logo_gfx();
   
@@ -2242,7 +2241,7 @@
     SDL_Client_Flags &= ~CF_TOGGLED_FULLSCREEN;
     #endif
     
-    FREE(pOption_Dlg);
+    FC_FREE(pOption_Dlg);
     enable_main_widgets();
   }
 }
Index: client/gui-sdl/citydlg.c
===================================================================
--- client/gui-sdl/citydlg.c    (Revision 11444)
+++ client/gui-sdl/citydlg.c    (Arbeitskopie)
@@ -49,7 +49,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
@@ -160,14 +159,14 @@
       del_group_of_widgets_from_gui_list(pCityDlg->pImprv->pBeginWidgetList,
                                         pCityDlg->pImprv->pEndWidgetList);
     }
-    FREE(pCityDlg->pImprv->pScroll);
-    FREE(pCityDlg->pImprv);
+    FC_FREE(pCityDlg->pImprv->pScroll);
+    FC_FREE(pCityDlg->pImprv);
 
     if (pCityDlg->pPanel) {
       del_group_of_widgets_from_gui_list(pCityDlg->pPanel->pBeginWidgetList,
                                         pCityDlg->pPanel->pEndWidgetList);
-      FREE(pCityDlg->pPanel->pScroll);
-      FREE(pCityDlg->pPanel);
+      FC_FREE(pCityDlg->pPanel->pScroll);
+      FC_FREE(pCityDlg->pPanel);
     }
         
     if (pHurry_Prod_Dlg)
@@ -175,14 +174,14 @@
       del_group_of_widgets_from_gui_list(pHurry_Prod_Dlg->pBeginWidgetList,
                                         pHurry_Prod_Dlg->pEndWidgetList);
 
-      FREE(pHurry_Prod_Dlg);
+      FC_FREE(pHurry_Prod_Dlg);
     }
     
     free_city_units_lists();
     del_city_menu_dlg(FALSE);
     del_group_of_widgets_from_gui_list(pCityDlg->pBeginCityWidgetList,
                                       pCityDlg->pEndCityWidgetList);
-    FREE(pCityDlg);
+    FC_FREE(pCityDlg);
   }
 }
 
@@ -761,7 +760,7 @@
 
   } unit_list_iterate_end;
   
-  pCityDlg->pPanel = MALLOC(sizeof(struct ADVANCED_DLG));
+  pCityDlg->pPanel = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   pCityDlg->pPanel->pEndWidgetList = pEnd;
   pCityDlg->pPanel->pEndActiveWidgetList = pEnd;
   pCityDlg->pPanel->pBeginWidgetList = pBuf;
@@ -776,7 +775,7 @@
   
   if (i > NUM_UNITS_SHOWN * NUM_UNITS_SHOWN) {
     
-    pCityDlg->pPanel->pScroll = MALLOC(sizeof(struct ScrollBar));
+    pCityDlg->pPanel->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
     pCityDlg->pPanel->pScroll->active = NUM_UNITS_SHOWN;
     pCityDlg->pPanel->pScroll->step = NUM_UNITS_SHOWN;
     pCityDlg->pPanel->pScroll->count = i;
@@ -808,8 +807,8 @@
   if (pCityDlg && pCityDlg->pPanel) {
     del_group_of_widgets_from_gui_list(pCityDlg->pPanel->pBeginWidgetList,
                                         pCityDlg->pPanel->pEndWidgetList);
-    FREE(pCityDlg->pPanel->pScroll);
-    FREE(pCityDlg->pPanel);
+    FC_FREE(pCityDlg->pPanel->pScroll);
+    FC_FREE(pCityDlg->pPanel);
   }
 }
 
@@ -972,7 +971,7 @@
 
   /* ----- */
   
-  pCityDlg->pPanel = MALLOC(sizeof(struct ADVANCED_DLG));
+  pCityDlg->pPanel = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   pCityDlg->pPanel->pEndWidgetList = pBuf;
 
   /* ----- */
@@ -1082,7 +1081,7 @@
   {
     del_group_of_widgets_from_gui_list(pHurry_Prod_Dlg->pBeginWidgetList,
                                        pHurry_Prod_Dlg->pEndWidgetList);
-    FREE(pHurry_Prod_Dlg);
+    FC_FREE(pHurry_Prod_Dlg);
     /* enable city dlg */
     enable_city_dlg_widgets();
     unlock_buffer();
@@ -1115,7 +1114,7 @@
   if (pHurry_Prod_Dlg) {
     popdown_window_group_dialog(pHurry_Prod_Dlg->pBeginWidgetList,
                              pHurry_Prod_Dlg->pEndWidgetList);
-    FREE(pHurry_Prod_Dlg);
+    FC_FREE(pHurry_Prod_Dlg);
     flush_dirty();
   }
 }
@@ -1147,7 +1146,7 @@
     return;
   }
   
-  pHurry_Prod_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pHurry_Prod_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
   
   if (pCity->production.is_unit) {
     name = get_unit_type(pCity->production.value)->name;
@@ -1650,7 +1649,7 @@
     }
   }
 
-  array = MALLOC(size * sizeof(struct city *));
+  array = fc_calloc(1, size * sizeof(struct city *));
 
   non_open_size = 0;
   for (i = 0; i < size; i++) {
@@ -1660,7 +1659,7 @@
   assert(non_open_size > 0);
 
   if (non_open_size == 1) {
-    FREE(array);
+    FC_FREE(array);
     return -1;
   }
 
@@ -1675,7 +1674,7 @@
 
   assert(i < non_open_size);
   pCityDlg->pCity = array[(i + dir + non_open_size) % non_open_size];
-  FREE(array);
+  FC_FREE(array);
 
   /* free panel widgets */
   free_city_units_lists();
@@ -1703,7 +1702,7 @@
       city_rename(pCityDlg->pCity, tmp);
     }
     
-    FREE(tmp);
+    FC_FREE(tmp);
   } else {
     /* empty input -> restore previous content */
     copy_chars_to_string16(pEdit->string16, pCityDlg->pCity->name);
@@ -1823,8 +1822,8 @@
     } else {
       del_group_of_widgets_from_gui_list(pCityDlg->pPanel->pBeginWidgetList,
                                         pCityDlg->pPanel->pEndWidgetList);
-      FREE(pCityDlg->pPanel->pScroll);
-      FREE(pCityDlg->pPanel);
+      FC_FREE(pCityDlg->pPanel->pScroll);
+      FC_FREE(pCityDlg->pPanel);
     }
   } else {
     if (size) {
@@ -1884,8 +1883,8 @@
     } else {
       del_group_of_widgets_from_gui_list(pCityDlg->pPanel->pBeginWidgetList,
                                         pCityDlg->pPanel->pEndWidgetList);
-      FREE(pCityDlg->pPanel->pScroll);
-      FREE(pCityDlg->pPanel);
+      FC_FREE(pCityDlg->pPanel->pScroll);
+      FC_FREE(pCityDlg->pPanel);
     }
   } else {
     if (size) {
@@ -3534,7 +3533,7 @@
   struct player *pOwner = city_owner(pCity);
     
   if(!pCityDlg->pImprv) {
-    pCityDlg->pImprv = MALLOC(sizeof(struct ADVANCED_DLG));
+    pCityDlg->pImprv = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   }
   
   /* free old list */
@@ -3544,7 +3543,7 @@
     pCityDlg->pImprv->pEndWidgetList = NULL;
     pCityDlg->pImprv->pBeginWidgetList = NULL;
     pCityDlg->pImprv->pActiveWidgetList = NULL;
-    FREE(pCityDlg->pImprv->pScroll);
+    FC_FREE(pCityDlg->pImprv->pScroll);
   } 
     
   pAdd_Dock = pCityDlg->pAdd_Point;
@@ -3598,7 +3597,7 @@
     if (count > 8) {
       pCityDlg->pImprv->pActiveWidgetList =
                    pCityDlg->pImprv->pEndActiveWidgetList;
-      pCityDlg->pImprv->pScroll = MALLOC(sizeof(struct ScrollBar));
+      pCityDlg->pImprv->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
       pCityDlg->pImprv->pScroll->step = 1;  
       pCityDlg->pImprv->pScroll->active = 8;
       pCityDlg->pImprv->pScroll->count = count;
@@ -3663,7 +3662,7 @@
 
   update_menus();
 
-  pCityDlg = MALLOC(sizeof(struct city_dialog));
+  pCityDlg = fc_calloc(1, sizeof(struct city_dialog));
   pCityDlg->pCity = pCity;
   
   pStr = create_string16(NULL, 0, adj_font(12));
@@ -3940,14 +3939,14 @@
       del_group_of_widgets_from_gui_list(pCityDlg->pImprv->pBeginWidgetList,
                                         pCityDlg->pImprv->pEndWidgetList);
     }
-    FREE(pCityDlg->pImprv->pScroll);
-    FREE(pCityDlg->pImprv);
+    FC_FREE(pCityDlg->pImprv->pScroll);
+    FC_FREE(pCityDlg->pImprv);
 
     if (pCityDlg->pPanel) {
       del_group_of_widgets_from_gui_list(pCityDlg->pPanel->pBeginWidgetList,
                                         pCityDlg->pPanel->pEndWidgetList);
-      FREE(pCityDlg->pPanel->pScroll);
-      FREE(pCityDlg->pPanel);
+      FC_FREE(pCityDlg->pPanel->pScroll);
+      FC_FREE(pCityDlg->pPanel);
     }
     
     if (pHurry_Prod_Dlg)
@@ -3955,14 +3954,14 @@
       del_group_of_widgets_from_gui_list(pHurry_Prod_Dlg->pBeginWidgetList,
                                         pHurry_Prod_Dlg->pEndWidgetList);
 
-      FREE( pHurry_Prod_Dlg );
+      FC_FREE( pHurry_Prod_Dlg );
     }
     
     free_city_units_lists();
     del_city_menu_dlg(FALSE);
     popdown_window_group_dialog(pCityDlg->pBeginCityWidgetList,
                                pCityDlg->pEndCityWidgetList);
-    FREE(pCityDlg);
+    FC_FREE(pCityDlg);
     SDL_Client_Flags &= ~CF_CITY_STATUS_SPECIAL;
   }
   flush_dirty();
Index: client/gui-sdl/gotodlg.c
===================================================================
--- client/gui-sdl/gotodlg.c    (Revision 11444)
+++ client/gui-sdl/gotodlg.c    (Arbeitskopie)
@@ -36,7 +36,6 @@
 #include "graphics.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
@@ -220,7 +219,7 @@
     return;
   }
   
-  pGotoDlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pGotoDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
     
   pStr = create_str16_from_char(_("Select destination"), adj_font(12));
   pStr->style |= TTF_STYLE_BOLD;
@@ -286,7 +285,7 @@
     
   pGotoDlg->pBeginWidgetList = pBuf;
   
-  pGotoDlg->pScroll = MALLOC(sizeof(struct ScrollBar));
+  pGotoDlg->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
   pGotoDlg->pScroll->step = 1;
   pGotoDlg->pScroll->active = 17;
   create_vertical_scrollbar(pGotoDlg, 1, 17, TRUE, TRUE);
@@ -383,8 +382,8 @@
  if(pGotoDlg) {
     popdown_window_group_dialog(pGotoDlg->pBeginWidgetList,
                                            pGotoDlg->pEndWidgetList);
-    FREE(pGotoDlg->pScroll);
-    FREE(pGotoDlg);
+    FC_FREE(pGotoDlg->pScroll);
+    FC_FREE(pGotoDlg);
   }
   GOTO = TRUE;
 }
Index: client/gui-sdl/mapview.c
===================================================================
--- client/gui-sdl/mapview.c    (Revision 11444)
+++ client/gui-sdl/mapview.c    (Arbeitskopie)
@@ -47,7 +47,6 @@
 #include "graphics.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_zoom.h"
 #include "mapctrl.h"
@@ -829,7 +828,7 @@
     
          if (!pDlg->pScroll) {
              
-            pDlg->pScroll = MALLOC(sizeof(struct ScrollBar));
+            pDlg->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
             pDlg->pScroll->active = num_h;
             pDlg->pScroll->step = num_w;
             pDlg->pScroll->count = n;
Index: client/gui-sdl/canvas.c
===================================================================
--- client/gui-sdl/canvas.c     (Revision 11444)
+++ client/gui-sdl/canvas.c     (Arbeitskopie)
@@ -25,7 +25,6 @@
 #include "colors.h"
 #include "graphics.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_string.h"
 
 #include "canvas.h"
Index: client/gui-sdl/gui_tilespec.c
===================================================================
--- client/gui-sdl/gui_tilespec.c       (Revision 11444)
+++ client/gui-sdl/gui_tilespec.c       (Arbeitskopie)
@@ -31,7 +31,6 @@
 /* gui-sdl */
 #include "graphics.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "themespec.h"
 
 #include "gui_tilespec.h"
@@ -216,7 +215,7 @@
 
   struct sprite *pSpr = NULL;
   
-  pIcons = ( struct City_Icon *)MALLOC( sizeof( struct City_Icon ));
+  pIcons = ( struct City_Icon *)fc_calloc(1,  sizeof( struct City_Icon ));
   
   load_city_icon_surface(pSpr, pBIG_Food_Corr, "city.food_waste");
   load_city_icon_surface(pSpr, pBIG_Shield_Corr, "city.shield_waste");
@@ -311,7 +310,7 @@
   FREESURFACE(pIcons->pSpec_Tax); /* TaxMan */
   FREESURFACE(pIcons->pSpec_Sci); /* Scientist */
   
-  FREE(pIcons);
+  FC_FREE(pIcons);
   
 }
 
@@ -327,7 +326,7 @@
 {
   struct sprite *pBuf = NULL;
   
-  pTheme = MALLOC(sizeof(struct Theme));
+  pTheme = fc_calloc(1, sizeof(struct Theme));
   
   if(!theme_lookup_sprite_tag_alt(theme, "theme.tech_tree", "", FALSE, "", 
"")) {  
     freelog(LOG_FATAL, "Your current tileset don't contains ""all"" GUI theme 
graphic\n"
@@ -444,7 +443,7 @@
         SDL_Cursor      *cursor;
 
         w = (image->w + 7) / 8;
-        data = (Uint8 *)MALLOC(w * image->h * 2);
+        data = (Uint8 *)fc_calloc(1, w * image->h * 2);
         if (data == NULL)
                 return NULL;
         /*memset(data, 0, w * image->h * 2);*/
@@ -469,7 +468,7 @@
         
         cursor = SDL_CreateCursor(data, mask, w * 8, image->h, hx, hy);
        
-       FREE(data);
+       FC_FREE(data);
         return cursor;
 }
 
@@ -577,7 +576,7 @@
   FREESURFACE(pTheme->NSOUTH_BORDER_Icon);
   FREESURFACE(pTheme->NEAST_BORDER_Icon);
        
-  FREE(pTheme);
+  FC_FREE(pTheme);
   return;
 }
 
Index: client/gui-sdl/repodlgs.c
===================================================================
--- client/gui-sdl/repodlgs.c   (Revision 11444)
+++ client/gui-sdl/repodlgs.c   (Arbeitskopie)
@@ -41,7 +41,6 @@
 #include "graphics.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
 #include "helpdlg.h"
@@ -123,7 +122,7 @@
   popdown_window_group_dialog(pUnits_Upg_Dlg->pBeginWidgetList,
                              pUnits_Upg_Dlg->pEndWidgetList);
   unlock_buffer();
-  FREE(pUnits_Upg_Dlg);
+  FC_FREE(pUnits_Upg_Dlg);
    
   dsend_packet_unit_type_upgrade(&aconnection, ut1);
     
@@ -145,7 +144,7 @@
     popdown_window_group_dialog(pUnits_Upg_Dlg->pBeginWidgetList,
                              pUnits_Upg_Dlg->pEndWidgetList);
     unlock_buffer();
-    FREE(pUnits_Upg_Dlg);
+    FC_FREE(pUnits_Upg_Dlg);
     flush_dirty();
   }
   return -1;
@@ -174,7 +173,7 @@
   redraw_label(pWidget);
   sdl_dirty_rect(pWidget->size);
   
-  pUnits_Upg_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pUnits_Upg_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
 
   ut2 = can_upgrade_unittype(game.player_ptr, &ut1);
   value = unit_upgrade_price(game.player_ptr, &ut1, ut2);
@@ -295,12 +294,12 @@
     if (pUnits_Upg_Dlg) {
        del_group_of_widgets_from_gui_list(pUnits_Upg_Dlg->pBeginWidgetList,
                              pUnits_Upg_Dlg->pEndWidgetList);
-       FREE(pUnits_Upg_Dlg); 
+       FC_FREE(pUnits_Upg_Dlg); 
     }
     popdown_window_group_dialog(pUnitsDlg->pBeginWidgetList,
                                      pUnitsDlg->pEndWidgetList);
-    FREE(pUnitsDlg->pScroll);
-    FREE(pUnitsDlg);
+    FC_FREE(pUnitsDlg->pScroll);
+    FC_FREE(pUnitsDlg);
     flush_dirty();
   }
   return -1;
@@ -329,7 +328,7 @@
     popdown_window_group_dialog(pUnitsDlg->pBeginWidgetList,
                                                pUnitsDlg->pEndWidgetList);
   } else {
-    pUnitsDlg = MALLOC(sizeof(struct ADVANCED_DLG));  
+    pUnitsDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));  
   }
   
   my_snprintf(cBuf, sizeof(cBuf), _("active"));
@@ -993,12 +992,12 @@
     if (pUnits_Upg_Dlg) {
        del_group_of_widgets_from_gui_list(pUnits_Upg_Dlg->pBeginWidgetList,
                              pUnits_Upg_Dlg->pEndWidgetList);
-       FREE(pUnits_Upg_Dlg); 
+       FC_FREE(pUnits_Upg_Dlg); 
     }
     popdown_window_group_dialog(pUnitsDlg->pBeginWidgetList,
                                      pUnitsDlg->pEndWidgetList);
-    FREE(pUnitsDlg->pScroll);
-    FREE(pUnitsDlg);
+    FC_FREE(pUnitsDlg->pScroll);
+    FC_FREE(pUnitsDlg);
   }
 }
 /* ===================================================================== */
@@ -1025,12 +1024,12 @@
     if (pEconomy_Sell_Dlg) {
        del_group_of_widgets_from_gui_list(pEconomy_Sell_Dlg->pBeginWidgetList,
                              pEconomy_Sell_Dlg->pEndWidgetList);
-       FREE(pEconomy_Sell_Dlg); 
+       FC_FREE(pEconomy_Sell_Dlg); 
     }
     popdown_window_group_dialog(pEconomyDlg->pBeginWidgetList,
                                            pEconomyDlg->pEndWidgetList);
-    FREE(pEconomyDlg->pScroll);
-    FREE(pEconomyDlg);
+    FC_FREE(pEconomyDlg->pScroll);
+    FC_FREE(pEconomyDlg);
     set_wstate(get_tax_rates_widget(), FC_WS_NORMAL);
     redraw_icon2(get_tax_rates_widget());
     sdl_dirty_rect(get_tax_rates_widget()->size);
@@ -1385,7 +1384,7 @@
   /* popdown sell dlg */
   del_group_of_widgets_from_gui_list(pEconomy_Sell_Dlg->pBeginWidgetList,
                              pEconomy_Sell_Dlg->pEndWidgetList);
-  FREE(pEconomy_Sell_Dlg);
+  FC_FREE(pEconomy_Sell_Dlg);
   enable_economy_dlg();
   
   /* send sell */
@@ -1418,7 +1417,7 @@
     popdown_window_group_dialog(pEconomy_Sell_Dlg->pBeginWidgetList,
                              pEconomy_Sell_Dlg->pEndWidgetList);
     unlock_buffer();
-    FREE(pEconomy_Sell_Dlg);
+    FC_FREE(pEconomy_Sell_Dlg);
     enable_economy_dlg();
     flush_dirty();
   }
@@ -1446,7 +1445,7 @@
   redraw_icon2(pWidget);
   sdl_dirty_rect(pWidget->size);
   
-  pEconomy_Sell_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pEconomy_Sell_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
 
   imp = pWidget->data.cont->id0;
   total_count = pWidget->data.cont->id1;
@@ -1635,12 +1634,12 @@
     if (pEconomy_Sell_Dlg) {
        del_group_of_widgets_from_gui_list(pEconomy_Sell_Dlg->pBeginWidgetList,
                              pEconomy_Sell_Dlg->pEndWidgetList);
-       FREE(pEconomy_Sell_Dlg); 
+       FC_FREE(pEconomy_Sell_Dlg); 
     }    
     popdown_window_group_dialog(pEconomyDlg->pBeginWidgetList,
                                            pEconomyDlg->pEndWidgetList);
-    FREE(pEconomyDlg->pScroll);
-    FREE(pEconomyDlg);
+    FC_FREE(pEconomyDlg->pScroll);
+    FC_FREE(pEconomyDlg);
     set_wstate(get_tax_rates_widget(), FC_WS_NORMAL);
     redraw_icon2(get_tax_rates_widget());
     sdl_dirty_rect(get_tax_rates_widget()->size);
@@ -1676,7 +1675,7 @@
   redraw_icon2(pBuf);
   sdl_dirty_rect(pBuf->size);
   
-  pEconomyDlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pEconomyDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
   get_economy_report_data(entries, &entries_used, &total, &tax);
   
@@ -1779,7 +1778,7 @@
                        (WF_FREE_DATA | WF_DRAW_THEME_TRANSPARENT));
 
   pBuf->action = horiz_taxrate_callback;
-  pBuf->data.ptr = MALLOC(sizeof(int));
+  pBuf->data.ptr = fc_calloc(1, sizeof(int));
   *(int *)pBuf->data.ptr = game.player_ptr->economic.luxury;
   w2 += adj_size(184);
   set_wstate(pBuf, FC_WS_NORMAL);
@@ -1820,7 +1819,7 @@
                                (WF_FREE_DATA | WF_DRAW_THEME_TRANSPARENT));
 
   pBuf->action = horiz_taxrate_callback;
-  pBuf->data.ptr = MALLOC(sizeof(int));
+  pBuf->data.ptr = fc_calloc(1, sizeof(int));
   *(int *)pBuf->data.ptr = game.player_ptr->economic.science;
   
   set_wstate(pBuf, FC_WS_NORMAL);
@@ -1954,7 +1953,7 @@
       
       set_wstate(pBuf, FC_WS_NORMAL);
       
-      pBuf->data.cont = MALLOC(sizeof(struct CONTAINER));
+      pBuf->data.cont = fc_calloc(1, sizeof(struct CONTAINER));
       pBuf->data.cont->id0 = p->type;
       pBuf->data.cont->id1 = p->count;
       pBuf->action = popup_sell_impv_callback;
@@ -2736,7 +2735,7 @@
   if(pScienceDlg) {
     popdown_window_group_dialog(pScienceDlg->pBeginWidgetList,
                                  pScienceDlg->pEndWidgetList);
-    FREE(pScienceDlg);
+    FC_FREE(pScienceDlg);
     set_wstate(get_research_widget(), FC_WS_NORMAL);
     redraw_icon2(get_research_widget());
     sdl_dirty_rect(get_research_widget()->size);
@@ -2753,8 +2752,8 @@
   if (pChangeTechDlg) {
     popdown_window_group_dialog(pChangeTechDlg->pBeginWidgetList, 
                                pChangeTechDlg->pEndWidgetList);
-    FREE(pChangeTechDlg->pScroll);
-    FREE(pChangeTechDlg);
+    FC_FREE(pChangeTechDlg->pScroll);
+    FC_FREE(pChangeTechDlg);
     enable_science_dialog();
     if (pWidget) {
       flush_dirty();
@@ -2821,7 +2820,7 @@
     return -1;
   }
   
-  pChangeTechDlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pChangeTechDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
   pStr = create_str16_from_char(_("What should we focus on now?"), 
adj_font(12));
   pStr->style |= TTF_STYLE_BOLD;
@@ -3005,7 +3004,7 @@
     return -1;
   }
   
-  pChangeTechDlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pChangeTechDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
   pStr = create_str16_from_char(_("Sellect target :"), adj_font(12));
   pStr->style |= TTF_STYLE_BOLD;
@@ -3174,7 +3173,7 @@
   redraw_icon2(pBuf);
   sdl_dirty_rect(pBuf->size);
   
-  pScienceDlg = MALLOC(sizeof(struct SMALL_DLG));
+  pScienceDlg = fc_calloc(1, sizeof(struct SMALL_DLG));
     
   pStr = create_str16_from_char(_("Science"), adj_font(12));
   pStr->style |= TTF_STYLE_BOLD;
@@ -3267,13 +3266,13 @@
     popdown_window_group_dialog(pChangeTechDlg->pBeginWidgetList,
                                  pChangeTechDlg->pEndWidgetList);
     unlock_buffer();
-    FREE(pChangeTechDlg->pScroll);
-    FREE(pChangeTechDlg);
+    FC_FREE(pChangeTechDlg->pScroll);
+    FC_FREE(pChangeTechDlg);
   }
   if(pScienceDlg) {
     popdown_window_group_dialog(pScienceDlg->pBeginWidgetList,
                                  pScienceDlg->pEndWidgetList);
-    FREE(pScienceDlg);
+    FC_FREE(pScienceDlg);
     set_wstate(get_research_widget(), FC_WS_NORMAL);
     redraw_icon2(get_research_widget());
     sdl_dirty_rect(get_research_widget()->size);
Index: client/gui-sdl/unistring.c
===================================================================
--- client/gui-sdl/unistring.c  (Revision 11444)
+++ client/gui-sdl/unistring.c  (Arbeitskopie)
@@ -27,8 +27,10 @@
 
 #include <SDL/SDL_types.h>
 
+/* utility */
+#include "mem.h"
+
 /* gui-sdl */
-#include "gui_mem.h"
 
 #include "unistring.h"
 
@@ -54,7 +56,7 @@
 {
   size_t size = (unistrlen(pFromUniString) + 1) << 1;
   if (!pToUniString) {
-    pToUniString = MALLOC(size);
+    pToUniString = fc_calloc(1, size);
   }
   return memcpy(pToUniString, pFromUniString, size);
 }
@@ -67,7 +69,7 @@
 {
   size_t src_size = (unistrlen(pFromUniString) + 1) << 1;
   size_t dst_size = unistrlen(pToUniString) << 1;
-  pToUniString = REALLOC(pToUniString, src_size + dst_size);
+  pToUniString = fc_realloc(pToUniString, src_size + dst_size);
   return memcpy((Uint8 *) pToUniString + dst_size,
                pFromUniString, src_size);
 }
@@ -78,7 +80,7 @@
 Uint16 *unistrdup(const Uint16 *pUniString)
 {
   size_t size = (unistrlen(pUniString) + 1) << 1;
-  Uint16 *pNewUniString = MALLOC(size);
+  Uint16 *pNewUniString = fc_calloc(1, size);
   return memcpy(pNewUniString, pUniString, size);
 }
 
@@ -94,10 +96,10 @@
   while (*pUnistring != 0) {
     if (*pUnistring == 10) {   /* find new line char */
       if (len) {
-       pBuf[count] = CALLOC(len + 1, sizeof(Uint16));
+       pBuf[count] = fc_calloc(len + 1, sizeof(Uint16));
        memcpy(pBuf[count], pFromUnistring, len * sizeof(Uint16));
       } else {
-       pBuf[count] = CALLOC(2, sizeof(Uint16));
+       pBuf[count] = fc_calloc(2, sizeof(Uint16));
        pBuf[count][0] = 32;
       }
       pFromUnistring = (Uint16 *)pUnistring + 1;
@@ -110,7 +112,7 @@
     pUnistring++;
         
     if ((*pUnistring == 0) && len) {
-      pBuf[count] = CALLOC(len + 1, sizeof(Uint16));
+      pBuf[count] = fc_calloc(len + 1, sizeof(Uint16));
       memcpy(pBuf[count], pFromUnistring, len * sizeof(Uint16));
     }
   }
Index: client/gui-sdl/gui_main.c
===================================================================
--- client/gui-sdl/gui_main.c   (Revision 11444)
+++ client/gui-sdl/gui_main.c   (Arbeitskopie)
@@ -58,7 +58,6 @@
 #include "cityrep.h"
 #include "graphics.h"
 #include "gui_id.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"         /* gui */
 #include "gui_tilespec.h"
 #include "inteldlg.h"
@@ -751,7 +750,7 @@
 
   button_behavior.button_down_ticks = 0;
   button_behavior.hold_state = MB_HOLD_SHORT;
-  button_behavior.event = MALLOC(sizeof(SDL_MouseButtonEvent));
+  button_behavior.event = fc_calloc(1, sizeof(SDL_MouseButtonEvent));
   
   SDL_Client_Flags = 0;
   iSDL_Flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
@@ -976,7 +975,7 @@
   
   unload_cursors();
 
-  FREE(button_behavior.event);
+  FC_FREE(button_behavior.event);
 
 /* FIXME */  
 /*  del_main_list();*/
Index: client/gui-sdl/gui_stuff.c
===================================================================
--- client/gui-sdl/gui_stuff.c  (Revision 11444)
+++ client/gui-sdl/gui_stuff.c  (Arbeitskopie)
@@ -31,7 +31,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
 #include "mapview.h"
@@ -376,7 +375,7 @@
   widget_info_counter = 0;
   if (pInfo_Area) {
     sdl_dirty_rect(*pInfo_Area);
-    FREE(pInfo_Area);
+    FC_FREE(pInfo_Area);
   }
   
   switch (get_wtype(pWidget)) {
@@ -583,7 +582,7 @@
 
   if (pInfo_Area) {
     flush_rect(*pInfo_Area);
-    FREE(pInfo_Area);
+    FC_FREE(pInfo_Area);
   }
 
   pSellected_Widget = NULL;
@@ -665,7 +664,7 @@
     return;
   }
 
-  pInfo_Area = MALLOC(sizeof(SDL_Rect));
+  pInfo_Area = fc_calloc(1, sizeof(SDL_Rect));
 
   /*pWidget->string16->render = 3;*/
   
@@ -2248,7 +2247,7 @@
   pWindow = pDlg->pEndWidgetList;
   
   if(!pDlg->pScroll) {
-    pDlg->pScroll = MALLOC(sizeof(struct ScrollBar));
+    pDlg->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
         
     pBuf = pDlg->pEndActiveWidgetList;
     while(pBuf && pBuf != pDlg->pBeginActiveWidgetList->prev) {
@@ -2461,7 +2460,7 @@
   pWindow = pDlg->pEndWidgetList;
   
   if(!pDlg->pScroll) {
-    pDlg->pScroll = MALLOC(sizeof(struct ScrollBar));
+    pDlg->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
     
     pDlg->pScroll->active = active;
     
@@ -2634,7 +2633,7 @@
 struct GUI * create_themeicon(SDL_Surface *pIcon_theme, SDL_Surface *pDest,
                                                          Uint32 flags)
 {
-  struct GUI *pIcon_Widget = MALLOC(sizeof(struct GUI));
+  struct GUI *pIcon_Widget = fc_calloc(1, sizeof(struct GUI));
 
   pIcon_Widget->theme = pIcon_theme;
 
@@ -2785,7 +2784,7 @@
 struct GUI * create_icon2(SDL_Surface *pIcon, SDL_Surface *pDest, Uint32 flags)
 {
 
-  struct GUI *pIcon_Widget = MALLOC(sizeof(struct GUI));
+  struct GUI *pIcon_Widget = fc_calloc(1, sizeof(struct GUI));
 
   pIcon_Widget->theme = pIcon;
 
@@ -2895,7 +2894,7 @@
     return NULL;
   }
 
-  pButton = MALLOC(sizeof(struct GUI));
+  pButton = fc_calloc(1, sizeof(struct GUI));
 
   pButton->theme = pTheme->Button;
   pButton->gfx = pIcon;
@@ -3272,12 +3271,12 @@
     pChain = pChain->next;
     for (i = 0; i < len - 1; i++) {
       FREESURFACE(pChain->prev->pTsurf);
-      FREE(pChain->prev);
+      FC_FREE(pChain->prev);
       pChain = pChain->next;
     }
   }
 
-  FREE(pChain);
+  FC_FREE(pChain);
 }
 
 /**************************************************************************
@@ -3296,13 +3295,13 @@
     return pOutChain;
   }
 
-  pOutChain = MALLOC(sizeof(struct UniChar));
+  pOutChain = fc_calloc(1, sizeof(struct UniChar));
   pOutChain->chr[0] = pInText[0];
   pOutChain->chr[1] = 0;
   chr_tmp = pOutChain;
 
   for (i = 1; i < len; i++) {
-    chr_tmp->next = MALLOC(sizeof(struct UniChar));
+    chr_tmp->next = fc_calloc(1, sizeof(struct UniChar));
     chr_tmp->next->chr[0] = pInText[i];
     chr_tmp->next->chr[1] = 0;
     chr_tmp->next->prev = chr_tmp;
@@ -3325,7 +3324,7 @@
     return pOutText;
   }
 
-  pOutText = CALLOC(len + 1, sizeof(Uint16));
+  pOutText = fc_calloc(len + 1, sizeof(Uint16));
   for (i = 0; i < len; i++) {
     pOutText[i] = pInChain->chr[0];
     pInChain = pInChain->next;
@@ -3416,7 +3415,7 @@
 {
   SDL_Rect buf = {0, 0, 0, 0};
 
-  struct GUI *pEdit = MALLOC(sizeof(struct GUI));
+  struct GUI *pEdit = fc_calloc(1, sizeof(struct GUI));
 
   pEdit->theme = pTheme->Edit;
   pEdit->gfx = pBackground;
@@ -3489,14 +3488,14 @@
        get_wflags(pEdit_Widget) & WF_PASSWD_EDIT) {
       Uint16 *backup = pEdit_Widget->string16->text;
       size_t len = unistrlen(backup) + 1;
-      char *cBuf = MALLOC(len);
+      char *cBuf = fc_calloc(1, len);
     
       memset(cBuf, '*', len - 1);
       cBuf[len - 1] = '\0';
       pEdit_Widget->string16->text = convert_to_utf16(cBuf);
       pText = create_text_surf_from_str16(pEdit_Widget->string16);
-      FREE(pEdit_Widget->string16->text);
-      FREE(cBuf);
+      FC_FREE(pEdit_Widget->string16->text);
+      FC_FREE(cBuf);
       pEdit_Widget->string16->text = backup;
     } else {
       pText = create_text_surf_from_str16(pEdit_Widget->string16);
@@ -3673,12 +3672,12 @@
          pInputChain_TMP = pEdt->pInputChain->prev->prev;
          pEdt->Truelength -= pEdt->pInputChain->prev->pTsurf->w;
          FREESURFACE(pEdt->pInputChain->prev->pTsurf);
-         FREE(pEdt->pInputChain->prev);
+         FC_FREE(pEdt->pInputChain->prev);
          pEdt->pInputChain->prev = pInputChain_TMP;
        } else {
          pEdt->Truelength -= pEdt->pInputChain->prev->pTsurf->w;
          FREESURFACE(pEdt->pInputChain->prev->pTsurf);
-         FREE(pEdt->pInputChain->prev);
+         FC_FREE(pEdt->pInputChain->prev);
          pEdt->pBeginTextChain = pEdt->pInputChain;
        }
        
@@ -3700,7 +3699,7 @@
        pInputChain_TMP = pEdt->pInputChain->next;
        pEdt->Truelength -= pEdt->pInputChain->pTsurf->w;
        FREESURFACE(pEdt->pInputChain->pTsurf);
-       FREE(pEdt->pInputChain);
+       FC_FREE(pEdt->pInputChain);
        pEdt->pInputChain = pInputChain_TMP;
        pEdt->ChainLen--;
        Redraw = TRUE;
@@ -3710,7 +3709,7 @@
        pEdt->pInputChain = pEdt->pInputChain->next;
        pEdt->Truelength -= pEdt->pInputChain->prev->pTsurf->w;
        FREESURFACE(pEdt->pInputChain->prev->pTsurf);
-       FREE(pEdt->pInputChain->prev);
+       FC_FREE(pEdt->pInputChain->prev);
        pEdt->pBeginTextChain = pEdt->pInputChain;
        pEdt->ChainLen--;
        Redraw = TRUE;
@@ -3723,12 +3722,12 @@
       if (Key.unicode) {
        if (pEdt->pInputChain != pEdt->pBeginTextChain) {
          pInputChain_TMP = pEdt->pInputChain->prev;
-         pEdt->pInputChain->prev = MALLOC(sizeof(struct UniChar));
+         pEdt->pInputChain->prev = fc_calloc(1, sizeof(struct UniChar));
          pEdt->pInputChain->prev->next = pEdt->pInputChain;
          pEdt->pInputChain->prev->prev = pInputChain_TMP;
          pInputChain_TMP->next = pEdt->pInputChain->prev;
        } else {
-         pEdt->pInputChain->prev = MALLOC(sizeof(struct UniChar));
+         pEdt->pInputChain->prev = fc_calloc(1, sizeof(struct UniChar));
          pEdt->pInputChain->prev->next = pEdt->pInputChain;
          pEdt->pBeginTextChain = pEdt->pInputChain->prev;
        }
@@ -3903,7 +3902,7 @@
       }
       
       if(ret != ED_ESC) {
-        FREE(pEdit_Widget->string16->text);
+        FC_FREE(pEdit_Widget->string16->text);
         pEdit_Widget->string16->text =
            chain2text(pEdt.pBeginTextChain, pEdt.ChainLen);
         pEdit_Widget->string16->n_alloc = (pEdt.ChainLen + 1) * sizeof(Uint16);
@@ -4022,7 +4021,7 @@
 struct GUI * create_vertical(SDL_Surface *pVert_theme, SDL_Surface *pDest,
                        Uint16 high, Uint32 flags)
 {
-  struct GUI *pVer = MALLOC(sizeof(struct GUI));
+  struct GUI *pVer = fc_calloc(1, sizeof(struct GUI));
 
   pVer->theme = pVert_theme;
   pVer->size.w = pVert_theme->w;
@@ -4153,7 +4152,7 @@
 struct GUI * create_horizontal(SDL_Surface *pHoriz_theme, SDL_Surface *pDest,
                Uint16 width, Uint32 flags)
 {
-  struct GUI *pHor = MALLOC(sizeof(struct GUI));
+  struct GUI *pHor = fc_calloc(1, sizeof(struct GUI));
 
   pHor->theme = pHoriz_theme;
   pHor->size.w = width;
@@ -4254,7 +4253,7 @@
       }
     }
     Main.guis_count++;
-    Main.guis = REALLOC(Main.guis, Main.guis_count * sizeof(SDL_Surface *));
+    Main.guis = fc_realloc(Main.guis, Main.guis_count * sizeof(SDL_Surface *));
     if(Main.guis[Main.guis_count - 2] == pLocked_buffer) {
       Main.guis[Main.guis_count - 1] = Main.guis[Main.guis_count - 2];
       Main.guis[Main.guis_count - 2] = pBuffer;
@@ -4262,7 +4261,7 @@
       Main.guis[Main.guis_count - 1] = pBuffer;
     }
   } else {
-    Main.guis = MALLOC(sizeof(SDL_Surface *));
+    Main.guis = fc_calloc(1, sizeof(SDL_Surface *));
     Main.guis[0] = pBuffer;
     Main.guis_count = 1;
   }
@@ -4366,7 +4365,7 @@
 struct GUI * create_window(SDL_Surface *pDest, SDL_String16 *pTitle, 
                        Uint16 w, Uint16 h, Uint32 flags)
 {
-  struct GUI *pWindow = MALLOC(sizeof(struct GUI));
+  struct GUI *pWindow = fc_calloc(1, sizeof(struct GUI));
 
   pWindow->string16 = pTitle;
   set_wflag(pWindow, WF_FREE_STRING | WF_FREE_GFX | WF_FREE_THEME |
@@ -5282,7 +5281,7 @@
   SDL_Rect update;
   
   if (!pMove->pPixelArray) {
-   pMove->pPixelArray = CALLOC(3 * pMove->pWindow->size.w +
+   pMove->pPixelArray = fc_calloc(3 * pMove->pWindow->size.w +
                             2 * pMove->pWindow->size.h,
                                pMove->pWindow->dst->format->BytesPerPixel);
    
@@ -5356,7 +5355,7 @@
     draw_frame_of_window_from_array(pMove->pWindow,
                        pMove->pPixelArray, pMove->pWindow->dst);
     refresh_widget_background(pMove->pWindow);
-    FREE(pMove->pPixelArray);
+    FC_FREE(pMove->pPixelArray);
     return (Uint16)ID_MOVED_WINDOW;
   }
   
@@ -5582,7 +5581,7 @@
     return NULL;
   }
 
-  pLabel = MALLOC(sizeof(struct GUI));
+  pLabel = fc_calloc(1, sizeof(struct GUI));
   pLabel->theme = pIcon;
   pLabel->string16 = pText;
   set_wflag(pLabel,
@@ -5609,7 +5608,7 @@
 {
   struct GUI *pILabel = NULL;
 
-  pILabel = MALLOC(sizeof(struct GUI));
+  pILabel = fc_calloc(1, sizeof(struct GUI));
 
   pILabel->theme = pIcon;
   pILabel->string16 = pText;
@@ -5640,7 +5639,7 @@
     return NULL;
   }
 
-  pLabel = MALLOC(sizeof(struct GUI));
+  pLabel = fc_calloc(1, sizeof(struct GUI));
   pLabel->theme = pIcon;
   pLabel->string16 = pText;
   set_wflag(pLabel, (WF_FREE_THEME | WF_FREE_STRING | WF_FREE_GFX | flags));
@@ -6093,8 +6092,8 @@
 **************************************************************************/
 struct GUI *create_checkbox(SDL_Surface *pDest, bool state, Uint32 flags)
 {
-  struct GUI *pCBox = MALLOC(sizeof(struct GUI));
-  struct CHECKBOX *pTmp = MALLOC(sizeof(struct CHECKBOX));
+  struct GUI *pCBox = fc_calloc(1, sizeof(struct GUI));
+  struct CHECKBOX *pTmp = fc_calloc(1, sizeof(struct CHECKBOX));
     
   if (state) {
     pCBox->theme = pTheme->CBOX_Sell_Icon;
@@ -6132,7 +6131,7 @@
     return create_checkbox(pDest, state, flags);
   }
   
-  pTmp = MALLOC(sizeof(struct CHECKBOX));
+  pTmp = fc_calloc(1, sizeof(struct CHECKBOX));
     
   if (state) {
     pSurf = pTheme->CBOX_Sell_Icon;
@@ -6167,7 +6166,7 @@
   }
   
   if(!pCBox->private_data.cbox) {
-    pCBox->private_data.cbox = MALLOC(sizeof(struct CHECKBOX));
+    pCBox->private_data.cbox = fc_calloc(1, sizeof(struct CHECKBOX));
     set_wflag(pCBox, WF_FREE_PRIVATE_DATA);
     pCBox->private_data.cbox->state = FALSE;
   }
Index: client/gui-sdl/gui_stuff.h
===================================================================
--- client/gui-sdl/gui_stuff.h  (Revision 11447)
+++ client/gui-sdl/gui_stuff.h  (Arbeitskopie)
@@ -448,12 +448,12 @@
     }                                                          \
   }                                                            \
   if ((get_wflags(pGUI) & WF_FREE_DATA) == WF_FREE_DATA) {     \
-    FREE(pGUI->data.ptr);                                      \
+    FC_FREE(pGUI->data.ptr);                                   \
   }                                                            \
   if ((get_wflags(pGUI) & WF_FREE_PRIVATE_DATA) == WF_FREE_PRIVATE_DATA) {     
\
-    FREE(pGUI->private_data.ptr);                              \
+    FC_FREE(pGUI->private_data.ptr);                           \
   }                                                            \
-  FREE(pGUI);                                                  \
+  FC_FREE(pGUI);                                                       \
 } while(0)
 
 #define redraw_ID(ID) \
Index: client/gui-sdl/messagewin.c
===================================================================
--- client/gui-sdl/messagewin.c (Revision 11444)
+++ client/gui-sdl/messagewin.c (Arbeitskopie)
@@ -35,7 +35,6 @@
 #include "graphics.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "mapview.h"
 
@@ -204,7 +203,7 @@
     return;
   }
   
-  pMsg_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pMsg_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
 
   /* create window */
   pWindow = create_window(NULL, NULL, w, h, WF_DRAW_THEME_TRANSPARENT);
@@ -344,8 +343,8 @@
   if(pMsg_Dlg) {
     popdown_window_group_dialog(pMsg_Dlg->pBeginWidgetList,
                                  pMsg_Dlg->pEndWidgetList);
-    FREE(pMsg_Dlg->pScroll);
-    FREE(pMsg_Dlg);
+    FC_FREE(pMsg_Dlg->pScroll);
+    FC_FREE(pMsg_Dlg);
   }
   
 }
Index: client/gui-sdl/menu.c
===================================================================
--- client/gui-sdl/menu.c       (Revision 11444)
+++ client/gui-sdl/menu.c       (Arbeitskopie)
@@ -42,7 +42,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"         /* gui */
 #include "gui_tilespec.h"
 #include "mapctrl.h"
@@ -543,7 +542,7 @@
   set_wstate(pBuf, FC_WS_NORMAL);
   pBuf->action = unit_order_callback;
   len = (len + 1) * sizeof(Uint16);
-  unibuf = MALLOC(len);
+  unibuf = fc_calloc(1, len);
   convertcopy_to_utf16(unibuf, len, cBuf);
   pBuf->string16 = create_string16(unibuf, len, adj_font(10));
   pBuf->key = SDLK_a;
@@ -757,7 +756,7 @@
   set_wstate(pBuf, FC_WS_NORMAL);
   pBuf->action = unit_order_callback;
   len = (len + 1) * sizeof(Uint16);
-  unibuf = MALLOC(len);
+  unibuf = fc_calloc(1, len);
   convertcopy_to_utf16(unibuf, len, cBuf);
   pBuf->string16 = create_string16(unibuf, len, adj_font(10));
   pBuf->key = SDLK_r;
@@ -790,7 +789,7 @@
   set_wstate(pBuf, FC_WS_NORMAL);
   pBuf->action = unit_order_callback;
   len = (len + 1) * sizeof(Uint16);
-  unibuf = MALLOC(len);
+  unibuf = fc_calloc(1, len);
   convertcopy_to_utf16(unibuf, len, cBuf);
   pBuf->string16 = create_string16(unibuf, len, adj_font(10));
   pBuf->key = SDLK_b;
Index: client/gui-sdl/cma_fe.c
===================================================================
--- client/gui-sdl/cma_fe.c     (Revision 11444)
+++ client/gui-sdl/cma_fe.c     (Arbeitskopie)
@@ -32,7 +32,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "mapview.h"
@@ -221,7 +220,7 @@
  
     if(name) { 
       cmafec_preset_add(name, &pCma->edited_cm_parm);
-      FREE(name);
+      FC_FREE(name);
     } else {
       cmafec_preset_add(_("new preset"), &pCma->edited_cm_parm);
     }
@@ -230,7 +229,7 @@
     remove_locked_buffer();
     del_group_of_widgets_from_gui_list(pCma->pAdv->pBeginWidgetList,
                                                pCma->pAdv->pEndWidgetList);
-    FREE(pCma->pAdv);
+    FC_FREE(pCma->pAdv);
     
     update_city_cma_dialog();
   }
@@ -245,8 +244,8 @@
   if(pCma && pCma->pAdv) {
     popdown_window_group_dialog(pCma->pAdv->pBeginWidgetList,
                                pCma->pAdv->pEndWidgetList);
-    FREE(pCma->pAdv->pScroll);
-    FREE(pCma->pAdv);
+    FC_FREE(pCma->pAdv->pScroll);
+    FC_FREE(pCma->pAdv);
     flush_dirty();
   }
   return -1;
@@ -264,7 +263,7 @@
     return 1;
   }
   
-  pCma->pAdv = MALLOC(sizeof(struct ADVANCED_DLG));
+  pCma->pAdv = fc_calloc(1, sizeof(struct ADVANCED_DLG));
       
   hh = WINDOW_TILE_HIGH + adj_size(2);
   pStr = create_str16_from_char(_("Name new preset"), adj_font(12));
@@ -383,8 +382,8 @@
   remove_locked_buffer();
   del_group_of_widgets_from_gui_list(pCma->pAdv->pBeginWidgetList,
                                                pCma->pAdv->pEndWidgetList);
-  FREE(pCma->pAdv->pScroll);
-  FREE(pCma->pAdv);
+  FC_FREE(pCma->pAdv->pScroll);
+  FC_FREE(pCma->pAdv);
   
   if(load) {
     cm_copy_parameter(&pCma->edited_cm_parm, 
cmafec_preset_get_parameter(index));
@@ -433,7 +432,7 @@
     return;
   }
   
-  pCma->pAdv = MALLOC(sizeof(struct ADVANCED_DLG));
+  pCma->pAdv = fc_calloc(1, sizeof(struct ADVANCED_DLG));
       
   pStr = create_str16_from_char(_("Presets"), adj_font(12));
   pStr->style |= TTF_STYLE_BOLD;
@@ -812,9 +811,9 @@
     return;
   }
   
-  pCma = MALLOC(sizeof(struct cma_dialog));
+  pCma = fc_calloc(1, sizeof(struct cma_dialog));
   pCma->pCity = pCity;
-  pCma->pDlg = MALLOC(sizeof(struct SMALL_DLG));
+  pCma->pDlg = fc_calloc(1, sizeof(struct SMALL_DLG));
   pCma->pAdv = NULL;
   pCma->pResult = NULL;  
   pCity_Map = get_scaled_city_map(pCity);  
@@ -1170,14 +1169,14 @@
   if(pCma) {
     popdown_window_group_dialog(pCma->pDlg->pBeginWidgetList,
                                pCma->pDlg->pEndWidgetList);
-    FREE(pCma->pDlg);
+    FC_FREE(pCma->pDlg);
     if(pCma->pAdv) {
       lock_buffer(pCma->pAdv->pEndWidgetList->dst);
       remove_locked_buffer();
       del_group_of_widgets_from_gui_list(pCma->pAdv->pBeginWidgetList,
                                                pCma->pAdv->pEndWidgetList);
-      FREE(pCma->pAdv->pScroll);
-      FREE(pCma->pAdv);
+      FC_FREE(pCma->pAdv->pScroll);
+      FC_FREE(pCma->pAdv);
     }
     if(city_dialog_is_open(pCma->pCity)) {
       /* enable city dlg */
@@ -1185,6 +1184,6 @@
       refresh_city_dialog(pCma->pCity);
     }
     city_report_dialog_update();
-    FREE(pCma);
+    FC_FREE(pCma);
   }
 }
Index: client/gui-sdl/cityrep.c
===================================================================
--- client/gui-sdl/cityrep.c    (Revision 11444)
+++ client/gui-sdl/cityrep.c    (Arbeitskopie)
@@ -30,7 +30,6 @@
 #include "graphics.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
@@ -59,12 +58,12 @@
 /*    if (pUnits_Upg_Dlg) {
        del_group_of_widgets_from_gui_list(pUnits_Upg_Dlg->pBeginWidgetList,
                              pUnits_Upg_Dlg->pEndWidgetList);
-       FREE(pUnits_Upg_Dlg); 
+       FC_FREE(pUnits_Upg_Dlg); 
     } */
     popdown_window_group_dialog(pCityRep->pBeginWidgetList,
                                      pCityRep->pEndWidgetList);
-    FREE(pCityRep->pScroll);
-    FREE(pCityRep);
+    FC_FREE(pCityRep->pScroll);
+    FC_FREE(pCityRep);
     enable_and_redraw_find_city_button();
     flush_dirty();
   }
@@ -138,7 +137,7 @@
     popdown_window_group_dialog(pCityRep->pBeginWidgetList,
                                                pCityRep->pEndWidgetList);
   } else {
-    pCityRep = MALLOC(sizeof(struct ADVANCED_DLG));
+    pCityRep = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   }
   
   my_snprintf(cBuf, sizeof(cBuf), _("size"));
Index: client/gui-sdl/dialogs.c
===================================================================
--- client/gui-sdl/dialogs.c    (Revision 11444)
+++ client/gui-sdl/dialogs.c    (Arbeitskopie)
@@ -54,7 +54,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
@@ -235,8 +234,8 @@
   if(pNotifyDlg) {
     popdown_window_group_dialog(pNotifyDlg->pBeginWidgetList,
                                            pNotifyDlg->pEndWidgetList);
-    FREE(pNotifyDlg->pScroll);
-    FREE(pNotifyDlg);
+    FC_FREE(pNotifyDlg->pScroll);
+    FC_FREE(pNotifyDlg);
     flush_dirty();
   }
   return -1;
@@ -258,7 +257,7 @@
     return;
   }
   
-  pNotifyDlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pNotifyDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
    
   pStr = create_str16_from_char(caption, adj_font(12));
   pStr->style |= TTF_STYLE_BOLD;
@@ -404,7 +403,7 @@
   }
   CHECK_UNIT_TYPE(ut1);
     
-  pUnit_Upgrade_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pUnit_Upgrade_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
 
   ut2 = can_upgrade_unittype(game.player_ptr, ut1);
   
@@ -542,7 +541,7 @@
   if (pUnit_Upgrade_Dlg) {
     popdown_window_group_dialog(pUnit_Upgrade_Dlg->pBeginWidgetList,
                              pUnit_Upgrade_Dlg->pEndWidgetList);
-    FREE(pUnit_Upgrade_Dlg);
+    FC_FREE(pUnit_Upgrade_Dlg);
   }
 }
 
@@ -597,8 +596,8 @@
     popdown_window_group_dialog(pUnit_Select_Dlg->pBeginWidgetList,
                        pUnit_Select_Dlg->pEndWidgetList);
                                   
-    FREE(pUnit_Select_Dlg->pScroll);
-    FREE(pUnit_Select_Dlg);
+    FC_FREE(pUnit_Select_Dlg->pScroll);
+    FC_FREE(pUnit_Select_Dlg);
     flush_dirty();
   }
 }
@@ -624,7 +623,7 @@
   }
   
   is_unit_move_blocked = TRUE;  
-  pUnit_Select_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pUnit_Select_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
     
   my_snprintf(cBuf , sizeof(cBuf),"%s (%d)", _("Unit selection") , n);
   pStr = create_str16_from_char(cBuf , adj_font(12));
@@ -774,7 +773,7 @@
   if (pTerrain_Info_Dlg) {
     popdown_window_group_dialog(pTerrain_Info_Dlg->pBeginWidgetList,
                                pTerrain_Info_Dlg->pEndWidgetList);
-    FREE(pTerrain_Info_Dlg);
+    FC_FREE(pTerrain_Info_Dlg);
     flush_dirty();
   }
 }
@@ -824,7 +823,7 @@
   }
       
   pSurf = get_terrain_surface(ptile);
-  pTerrain_Info_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pTerrain_Info_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
     
   /* ----------- */  
   my_snprintf(cBuf, sizeof(cBuf), "%s [%d,%d]", _("Terrain Info"), ptile->x , 
ptile->y);
@@ -979,8 +978,8 @@
     popdown_window_group_dialog(pAdvanced_Terrain_Dlg->pBeginWidgetList,
                        pAdvanced_Terrain_Dlg->pEndWidgetList);
                                   
-    FREE(pAdvanced_Terrain_Dlg->pScroll);
-    FREE(pAdvanced_Terrain_Dlg);
+    FC_FREE(pAdvanced_Terrain_Dlg->pScroll);
+    FC_FREE(pAdvanced_Terrain_Dlg);
   }
 }
 
@@ -1228,9 +1227,9 @@
   h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
   is_unit_move_blocked = TRUE;
     
-  pAdvanced_Terrain_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pAdvanced_Terrain_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
-  pCont = MALLOC(sizeof(struct CONTAINER));
+  pCont = fc_calloc(1, sizeof(struct CONTAINER));
   pCont->id0 = ptile->x;
   pCont->id1 = ptile->y;
   
@@ -1758,7 +1757,7 @@
     is_unit_move_blocked = FALSE;
     popdown_window_group_dialog(pCaravan_Dlg->pBeginWidgetList,
                                pCaravan_Dlg->pEndWidgetList);
-    FREE(pCaravan_Dlg);
+    FC_FREE(pCaravan_Dlg);
     flush_dirty();
   }
 }
@@ -1783,11 +1782,11 @@
     return;
   }
   
-  pCont = MALLOC(sizeof(struct CONTAINER));
+  pCont = fc_calloc(1, sizeof(struct CONTAINER));
   pCont->id0 = pUnit->id;
   pCont->id1 = pDestcity->id;
   
-  pCaravan_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pCaravan_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
   is_unit_move_blocked = TRUE;
   h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
       
@@ -2083,11 +2082,11 @@
     return -1;
   }
     
-  pCont = MALLOC(sizeof(struct CONTAINER));
+  pCont = fc_calloc(1, sizeof(struct CONTAINER));
   pCont->id0 = pVcity->id;
   pCont->id1 = id;/* spy id */
   
-  pDiplomat_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pDiplomat_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
       
   pStr = create_str16_from_char(_("Select Advance to Steal"), adj_font(12));
   pStr->style |= TTF_STYLE_BOLD;
@@ -2343,8 +2342,8 @@
     is_unit_move_blocked = FALSE;
     popdown_window_group_dialog(pDiplomat_Dlg->pBeginWidgetList,
                                pDiplomat_Dlg->pEndWidgetList);
-    FREE(pDiplomat_Dlg->pScroll);
-    FREE(pDiplomat_Dlg);
+    FC_FREE(pDiplomat_Dlg->pScroll);
+    FC_FREE(pDiplomat_Dlg);
     queue_flush();
   }
 }
@@ -2370,7 +2369,7 @@
   pCity = tile_get_city(ptile);
   spy = unit_flag(pUnit, F_SPY);
   
-  pDiplomat_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pDiplomat_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
   h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
     
@@ -2635,9 +2634,9 @@
   is_unit_move_blocked = TRUE;
   h = WINDOW_TILE_HIGH + 3 + FRAME_WH;
     
-  pAdvanced_Terrain_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pAdvanced_Terrain_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
-  pCont = MALLOC(sizeof(struct CONTAINER));
+  pCont = fc_calloc(1, sizeof(struct CONTAINER));
   pCont->id0 = pCity->id;
   pCont->id1 = pUnit->id;/* spy id */
     
@@ -2882,7 +2881,7 @@
     is_unit_move_blocked = FALSE;
     popdown_window_group_dialog(pIncite_Dlg->pBeginWidgetList,
                                pIncite_Dlg->pEndWidgetList);
-    FREE(pIncite_Dlg);
+    FC_FREE(pIncite_Dlg);
     flush_dirty();
   }
 }
@@ -2912,7 +2911,7 @@
   }
     
   is_unit_move_blocked = TRUE;
-  pIncite_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pIncite_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
   
   h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
       
@@ -3108,7 +3107,7 @@
     is_unit_move_blocked = FALSE;
     popdown_window_group_dialog(pBribe_Dlg->pBeginWidgetList,
                                pBribe_Dlg->pEndWidgetList);
-    FREE(pBribe_Dlg);
+    FC_FREE(pBribe_Dlg);
     flush_dirty();
   }
 }
@@ -3140,7 +3139,7 @@
   }
   
   is_unit_move_blocked = TRUE;
-  pBribe_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pBribe_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
   
   h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
       
@@ -3305,7 +3304,7 @@
     is_unit_move_blocked = FALSE;
     popdown_window_group_dialog(pPillage_Dlg->pBeginWidgetList,
                                pPillage_Dlg->pEndWidgetList);
-    FREE(pPillage_Dlg);
+    FC_FREE(pPillage_Dlg);
     flush_dirty();
   }
 }
@@ -3327,7 +3326,7 @@
   }
   
   is_unit_move_blocked = TRUE;
-  pPillage_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pPillage_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
   
   h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
       
@@ -3426,7 +3425,7 @@
     is_unit_move_blocked = FALSE;
     popdown_window_group_dialog(pConnect_Dlg->pBeginWidgetList,
                                pConnect_Dlg->pEndWidgetList);
-    FREE(pConnect_Dlg);
+    FC_FREE(pConnect_Dlg);
   }
 }
 
@@ -3476,7 +3475,7 @@
   if(pRevolutionDlg) {
     popdown_window_group_dialog(pRevolutionDlg->pBeginWidgetList,
                              pRevolutionDlg->pEndWidgetList);
-    FREE(pRevolutionDlg);
+    FC_FREE(pRevolutionDlg);
     enable_and_redraw_revolution_button();
   }
 }
@@ -3500,7 +3499,7 @@
     return;
   }
   
-  pRevolutionDlg = MALLOC(sizeof(struct SMALL_DLG));
+  pRevolutionDlg = fc_calloc(1, sizeof(struct SMALL_DLG));
     
   /* create ok button */
   pOK_Button =
@@ -3647,7 +3646,7 @@
   dsend_packet_nation_select_req(&aconnection, races_player->player_no, 
pSetup->nation,
                                 pSetup->leader_sex, pStr,
                                 pSetup->nation_city_style);
-  FREE(pStr);
+  FC_FREE(pStr);
 
   popdown_races_dialog();  
   flush_dirty();
@@ -3699,8 +3698,8 @@
   copy_chars_to_string16(pSetup->pName_Edit->string16,
                                leaders[pSetup->selected_leader].name);
   
-  FREE(pLeaderName);
-  pLeaderName = MALLOC(strlen(leaders[pSetup->selected_leader].name) + 1);
+  FC_FREE(pLeaderName);
+  pLeaderName = fc_calloc(1, strlen(leaders[pSetup->selected_leader].name) + 
1);
   mystrlcpy(pLeaderName, leaders[pSetup->selected_leader].name,
                        strlen(leaders[pSetup->selected_leader].name) + 1);
   
@@ -3752,8 +3751,8 @@
   copy_chars_to_string16(pSetup->pName_Edit->string16,
                                leaders[pSetup->selected_leader].name);
   
-  FREE(pLeaderName);
-  pLeaderName = MALLOC(strlen(leaders[pSetup->selected_leader].name) + 1);
+  FC_FREE(pLeaderName);
+  pLeaderName = fc_calloc(1, strlen(leaders[pSetup->selected_leader].name) + 
1);
   mystrlcpy(pLeaderName, leaders[pSetup->selected_leader].name,
                        strlen(leaders[pSetup->selected_leader].name) + 1);
   
@@ -3834,7 +3833,7 @@
   if (pHelpDlg) {
     popdown_window_group_dialog(pHelpDlg->pBeginWidgetList,
                        pHelpDlg->pEndWidgetList);
-    FREE(pHelpDlg);
+    FC_FREE(pHelpDlg);
     if (pWidget) {
       flush_dirty();
     }
@@ -3886,7 +3885,7 @@
   
     if (!pHelpDlg) {
     
-      pHelpDlg = MALLOC(sizeof(struct SMALL_DLG));
+      pHelpDlg = fc_calloc(1, sizeof(struct SMALL_DLG));
     
       pStr = create_str16_from_char("Nation's Legend", adj_font(12));
       pStr->style |= TTF_STYLE_BOLD;
@@ -3975,7 +3974,7 @@
   char *name = convert_to_chars(pEdit->string16->text);
 
   if (name) {
-    FREE(name);
+    FC_FREE(name);
   } else {
     /* empty input -> restore previous content */
     copy_chars_to_string16(pEdit->string16, pLeaderName);
@@ -4033,8 +4032,8 @@
   copy_chars_to_string16(pSetup->pName_Edit->string16,
                                leaders[pSetup->selected_leader].name);
   
-  FREE(pLeaderName);
-  pLeaderName = MALLOC(strlen(leaders[pSetup->selected_leader].name) + 1);
+  FC_FREE(pLeaderName);
+  pLeaderName = fc_calloc(1, strlen(leaders[pSetup->selected_leader].name) + 
1);
   mystrlcpy(pLeaderName, leaders[pSetup->selected_leader].name,
                        strlen(leaders[pSetup->selected_leader].name) + 1);
   
@@ -4096,7 +4095,7 @@
   
   races_player = pplayer;
   
-  pNationDlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pNationDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
   /* create window widget */
   pStr = create_str16_from_char(_("What nation will you be?"), adj_font(12));
@@ -4105,7 +4104,7 @@
   pWindow = create_window(NULL, pStr, w, h, WF_FREE_DATA);
   pWindow->action = nations_dialog_callback;
   set_wstate(pWindow, FC_WS_NORMAL);
-  pSetup = MALLOC(sizeof(struct NAT));
+  pSetup = fc_calloc(1, sizeof(struct NAT));
   pWindow->data.ptr = (void *)pSetup;
     
   pNationDlg->pEndWidgetList = pWindow;
@@ -4424,10 +4423,10 @@
 
     cancel_help_dlg_callback(NULL);
     
-    FREE(pLeaderName);
+    FC_FREE(pLeaderName);
     
-    FREE(pNationDlg->pScroll);
-    FREE(pNationDlg);
+    FC_FREE(pNationDlg->pScroll);
+    FC_FREE(pNationDlg);
   }
 }
 
Index: client/gui-sdl/diplodlg.c
===================================================================
--- client/gui-sdl/diplodlg.c   (Revision 11444)
+++ client/gui-sdl/diplodlg.c   (Arbeitskopie)
@@ -38,7 +38,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "mapview.h"
@@ -181,7 +180,7 @@
      pBuf->string16->style |= SF_CENTER_RIGHT;  
   }
 
-  pBuf->data.cont = MALLOC(sizeof(struct CONTAINER));
+  pBuf->data.cont = fc_calloc(1, sizeof(struct CONTAINER));
   pBuf->data.cont->id0 = giver;
   pBuf->data.cont->id1 = (int)type;
   pBuf->data.cont->value = value;
@@ -456,8 +455,8 @@
                                struct player *pPlayer1,
                                struct GUI *pMainWindow, bool L_R)
 {
-  struct ADVANCED_DLG *pDlg = MALLOC(sizeof(struct ADVANCED_DLG));
-  struct CONTAINER *pCont = MALLOC(sizeof(struct CONTAINER));
+  struct ADVANCED_DLG *pDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
+  struct CONTAINER *pCont = fc_calloc(1, sizeof(struct CONTAINER));
   int hh, ww = 0, width, height, count = 0, scroll_w = 0;
   char cBuf[128];
   struct GUI *pBuf = NULL, *pWindow;
@@ -700,7 +699,7 @@
     struct city **city_list_ptrs;
 
     if (n > 0) {
-      city_list_ptrs = MALLOC(sizeof(struct city *) * n);
+      city_list_ptrs = fc_calloc(1, sizeof(struct city *) * n);
       city_list_iterate(pPlayer0->cities, pCity) {
         if (!is_capital(pCity)) {
          city_list_ptrs[i] = pCity;
@@ -742,7 +741,7 @@
        count++;      
       }
       
-      FREE(city_list_ptrs);
+      FC_FREE(city_list_ptrs);
     }
   } /* Cities */
   
@@ -806,7 +805,7 @@
   if(!pClauses_Dlg) {
     struct player *pPlayer0 = &game.players[game.info.player_idx];
     struct player *pPlayer1 = &game.players[counterpart];
-    struct CONTAINER *pCont = MALLOC(sizeof(struct CONTAINER));
+    struct CONTAINER *pCont = fc_calloc(1, sizeof(struct CONTAINER));
     int hh, ww = 0;
     char cBuf[128];
     struct GUI *pBuf = NULL, *pWindow;
@@ -814,7 +813,7 @@
     SDL_Rect dst;
     SDL_Color color = {255,255,255,255};
     
-    pClauses_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+    pClauses_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
     
     /*if(game.player_idx != pPlayer0->player_no) {
       pPlayer0 = pPlayer1;
@@ -851,7 +850,7 @@
                (WF_ICON_ABOVE_TEXT|WF_FREE_PRIVATE_DATA|WF_FREE_THEME|
                                                WF_DRAW_THEME_TRANSPARENT));
                                                
-    pBuf->private_data.cbox = MALLOC(sizeof(struct CHECKBOX));
+    pBuf->private_data.cbox = fc_calloc(1, sizeof(struct CHECKBOX));
     pBuf->private_data.cbox->state = FALSE;
     pBuf->private_data.cbox->pTRUE_Theme = pTheme->OK_PACT_Icon;
     pBuf->private_data.cbox->pFALSE_Theme = pTheme->CANCEL_PACT_Icon;
@@ -867,7 +866,7 @@
                pWindow->dst, pStr,
                (WF_ICON_ABOVE_TEXT|WF_FREE_PRIVATE_DATA|WF_FREE_THEME|
                                                WF_DRAW_THEME_TRANSPARENT));
-    pBuf->private_data.cbox = MALLOC(sizeof(struct CHECKBOX));
+    pBuf->private_data.cbox = fc_calloc(1, sizeof(struct CHECKBOX));
     pBuf->private_data.cbox->state = FALSE;
     pBuf->private_data.cbox->pTRUE_Theme = pTheme->OK_PACT_Icon;
     pBuf->private_data.cbox->pFALSE_Theme = pTheme->CANCEL_PACT_Icon;
@@ -973,19 +972,19 @@
     lock_buffer(pClauses_Dlg->pEndWidgetList->dst);
     popdown_window_group_dialog(pOffers->pBeginWidgetList,
                              pOffers->pEndWidgetList);
-    FREE(pOffers->pScroll);
-    FREE(pOffers);
+    FC_FREE(pOffers->pScroll);
+    FC_FREE(pOffers);
     
     popdown_window_group_dialog(pWants->pBeginWidgetList,
                              pWants->pEndWidgetList);
-    FREE(pWants->pScroll);
-    FREE(pWants);
+    FC_FREE(pWants->pScroll);
+    FC_FREE(pWants);
     
     unlock_buffer();
     popdown_window_group_dialog(pClauses_Dlg->pBeginWidgetList,
                              pClauses_Dlg->pEndWidgetList);
-    FREE(pClauses_Dlg->pScroll);
-    FREE(pClauses_Dlg);
+    FC_FREE(pClauses_Dlg->pScroll);
+    FC_FREE(pClauses_Dlg);
   }
 }
 
@@ -1008,7 +1007,7 @@
   if (pSDip_Dlg) {
     popdown_window_group_dialog(pSDip_Dlg->pBeginWidgetList,
                              pSDip_Dlg->pEndWidgetList);
-    FREE(pSDip_Dlg);
+    FC_FREE(pSDip_Dlg);
   }
 }
 
@@ -1074,7 +1073,7 @@
     return;
   }
   
-  pSDip_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pSDip_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
       
     
   my_snprintf(cBuf, sizeof(cBuf),
@@ -1205,7 +1204,7 @@
       return;
     }
   
-    pSDip_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+    pSDip_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
           
     my_snprintf(cBuf, sizeof(cBuf),  _("Foreign Minister"));
     hh = WINDOW_TILE_HIGH + adj_size(2);
Index: client/gui-sdl/mapctrl.c
===================================================================
--- client/gui-sdl/mapctrl.c    (Revision 11444)
+++ client/gui-sdl/mapctrl.c    (Arbeitskopie)
@@ -48,7 +48,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
@@ -513,7 +512,7 @@
   if (pScall_MiniMap_Dlg) {
     popdown_window_group_dialog(pScall_MiniMap_Dlg->pBeginWidgetList,
                                pScall_MiniMap_Dlg->pEndWidgetList);
-    FREE(pScall_MiniMap_Dlg);
+    FC_FREE(pScall_MiniMap_Dlg);
     if (pWidget) {
       flush_dirty();
     }
@@ -637,7 +636,7 @@
   w = MAX(w, pText2->w + adj_size(30));
   FREESTRING16(pStr);
   
-  pScall_MiniMap_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pScall_MiniMap_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
     
   /* create window */
   pStr = create_str16_from_char(_("Scale Minimap"), adj_font(12));
@@ -800,7 +799,7 @@
   if(pScall_UnitInfo_Dlg) {
     popdown_window_group_dialog(pScall_UnitInfo_Dlg->pBeginWidgetList,
                                pScall_UnitInfo_Dlg->pEndWidgetList);
-    FREE(pScall_UnitInfo_Dlg);
+    FC_FREE(pScall_UnitInfo_Dlg);
     if(pWidget) {
       flush_dirty();
     }
@@ -901,7 +900,7 @@
   h += MAX(adj_size(20), pText2->h + adj_size(4));
   FREESTRING16(pStr);
   
-  pScall_UnitInfo_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pScall_UnitInfo_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
     
   /* create window */
   pStr = create_str16_from_char(_("Scale Unit Info"), adj_font(12));
@@ -1426,7 +1425,7 @@
   SDL_Surface *pIcon_theme = NULL;
                    
   /* =================== Units Window ======================= */
-  pUnitInfo_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pUnitInfo_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
       
   pWidget = create_window(Main.gui, create_string16(NULL, 0, 12),
                        UNITS_W, UNITS_H, WF_DRAW_THEME_TRANSPARENT);
@@ -2322,7 +2321,7 @@
          convert_to_chars(pNewCity_Dlg->pBeginWidgetList->string16->text);
 
   if (input) {
-    FREE(input);
+    FC_FREE(input);
   } else {
     /* empty input -> restore previous content */
     copy_chars_to_string16(pEdit->string16, pSuggestedCityName);
@@ -2343,13 +2342,13 @@
   
   dsend_packet_unit_build_city(&aconnection, pOk_Button->data.unit->id,
                               input);
-  FREE(input);
+  FC_FREE(input);
 
   popdown_window_group_dialog(pNewCity_Dlg->pBeginWidgetList,
                              pNewCity_Dlg->pEndWidgetList);
-  FREE(pNewCity_Dlg);
+  FC_FREE(pNewCity_Dlg);
   
-  FREE(pSuggestedCityName);
+  FC_FREE(pSuggestedCityName);
   
   flush_dirty();
   return -1;
@@ -2362,9 +2361,9 @@
 {
   popdown_window_group_dialog(pNewCity_Dlg->pBeginWidgetList,
                              pNewCity_Dlg->pEndWidgetList);
-  FREE(pNewCity_Dlg);
+  FC_FREE(pNewCity_Dlg);
   
-  FREE(pSuggestedCityName);  
+  FC_FREE(pSuggestedCityName);  
   
   flush_dirty();
   return -1;
@@ -2399,10 +2398,10 @@
     return;
   }
 
-  pSuggestedCityName = MALLOC(strlen(pSuggestname) + 1);
+  pSuggestedCityName = fc_calloc(1, strlen(pSuggestname) + 1);
   mystrlcpy(pSuggestedCityName, pSuggestname, strlen(pSuggestname) + 1);
   
-  pNewCity_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pNewCity_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
     
   /* create ok button */
   pOK_Button =
@@ -2519,7 +2518,7 @@
   if(pNewCity_Dlg) {
     popdown_window_group_dialog(pNewCity_Dlg->pBeginWidgetList,
                              pNewCity_Dlg->pEndWidgetList);
-    FREE(pNewCity_Dlg);
+    FC_FREE(pNewCity_Dlg);
     flush_dirty();
   }
 }
Index: client/gui-sdl/inteldlg.c
===================================================================
--- client/gui-sdl/inteldlg.c   (Revision 11444)
+++ client/gui-sdl/inteldlg.c   (Arbeitskopie)
@@ -28,7 +28,6 @@
 #include "graphics.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
@@ -120,11 +119,11 @@
 
 static struct intel_dialog *create_intel_dialog(struct player *pPlayer) {
 
-  struct intel_dialog *pdialog = MALLOC(sizeof(struct intel_dialog));
+  struct intel_dialog *pdialog = fc_calloc(1, sizeof(struct intel_dialog));
 
   pdialog->pplayer = pPlayer;
   
-  pdialog->pdialog = MALLOC(sizeof(struct ADVANCED_DLG));
+  pdialog->pdialog = fc_calloc(1, sizeof(struct ADVANCED_DLG));
       
   pdialog->pos_x = 0;
   pdialog->pos_y = 0;
@@ -166,9 +165,9 @@
       
     dialog_list_unlink(dialog_list, pdialog);
       
-    FREE(pdialog->pdialog->pScroll);
-    FREE(pdialog->pdialog);  
-    FREE(pdialog);
+    FC_FREE(pdialog->pdialog->pScroll);
+    FC_FREE(pdialog->pdialog);  
+    FC_FREE(pdialog);
   }
 }
 
Index: client/gui-sdl/finddlg.c
===================================================================
--- client/gui-sdl/finddlg.c    (Revision 11444)
+++ client/gui-sdl/finddlg.c    (Arbeitskopie)
@@ -30,7 +30,6 @@
 #include "graphics.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "mapctrl.h"
@@ -83,8 +82,8 @@
   if (pFind_City_Dlg) {
     popdown_window_group_dialog(pFind_City_Dlg->pBeginWidgetList,
                        pFind_City_Dlg->pEndWidgetList);
-    FREE(pFind_City_Dlg->pScroll);
-    FREE(pFind_City_Dlg);
+    FC_FREE(pFind_City_Dlg->pScroll);
+    FC_FREE(pFind_City_Dlg);
     enable_and_redraw_find_city_button();
   }
 }
@@ -118,7 +117,7 @@
   
   original = canvas_pos_to_tile(Main.map->w/2, Main.map->h/2);
   
-  pFind_City_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pFind_City_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
   pStr = create_str16_from_char(_("Find City") , adj_font(12));
   pStr->style |= TTF_STYLE_BOLD;
@@ -139,7 +138,7 @@
   pBuf->action = exit_find_city_dlg_callback;
   set_wstate(pBuf, FC_WS_NORMAL);
   pBuf->key = SDLK_ESCAPE;
-  pBuf->data.cont = MALLOC(sizeof(struct CONTAINER));
+  pBuf->data.cont = fc_calloc(1, sizeof(struct CONTAINER));
   pBuf->data.cont->id0 = original->x;
   pBuf->data.cont->id1 = original->y;
 
Index: client/gui-sdl/helpdlg.c
===================================================================
--- client/gui-sdl/helpdlg.c    (Revision 11444)
+++ client/gui-sdl/helpdlg.c    (Arbeitskopie)
@@ -33,7 +33,6 @@
 #include "graphics.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
@@ -98,8 +97,8 @@
   {
     popdown_window_group_dialog(pHelpDlg->pBeginWidgetList,
                                           pHelpDlg->pEndWidgetList);
-    FREE(pHelpDlg->pScroll);
-    FREE(pHelpDlg);
+    FC_FREE(pHelpDlg->pScroll);
+    FC_FREE(pHelpDlg);
     current_help_dlg = HELP_LAST;
   }
 }
@@ -183,8 +182,8 @@
     
     current_help_dlg = HELP_IMPROVEMENT;
     created = TRUE;
-    pHelpDlg = MALLOC(sizeof(struct ADVANCED_DLG));
-    pStore = MALLOC(sizeof(struct UNITS_BUTTONS));
+    pHelpDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
+    pStore = fc_calloc(1, sizeof(struct UNITS_BUTTONS));
     
     pStr = create_str16_from_char(_("Help : Improvement"), adj_font(12));
     pStr->style |= TTF_STYLE_BOLD;
@@ -538,8 +537,8 @@
     
     current_help_dlg = HELP_UNIT;
     created = TRUE;
-    pHelpDlg = MALLOC(sizeof(struct ADVANCED_DLG));
-    pStore = MALLOC(sizeof(struct UNITS_BUTTONS));
+    pHelpDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
+    pStore = fc_calloc(1, sizeof(struct UNITS_BUTTONS));
     
     pStr = create_str16_from_char(_("Help : Units"), adj_font(12));
     pStr->style |= TTF_STYLE_BOLD;
@@ -1833,8 +1832,8 @@
   {
     created = TRUE;
     current_help_dlg = HELP_TECH;
-    pHelpDlg = MALLOC(sizeof(struct ADVANCED_DLG));
-    pStore = MALLOC(sizeof(struct TECHS_BUTTONS));
+    pHelpDlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
+    pStore = fc_calloc(1, sizeof(struct TECHS_BUTTONS));
       
     memset(pStore, 0, sizeof(struct TECHS_BUTTONS));
   
Index: client/gui-sdl/plrdlg.c
===================================================================
--- client/gui-sdl/plrdlg.c     (Revision 11444)
+++ client/gui-sdl/plrdlg.c     (Arbeitskopie)
@@ -30,7 +30,6 @@
 #include "graphics.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
@@ -329,7 +328,7 @@
     return;
   }
     
-  pPlayers_Dlg = MALLOC(sizeof(struct SMALL_DLG));
+  pPlayers_Dlg = fc_calloc(1, sizeof(struct SMALL_DLG));
   
   pStr = create_str16_from_char(_("Players"), adj_font(12));
   pStr->style |= TTF_STYLE_BOLD;
@@ -541,7 +540,7 @@
   if (pPlayers_Dlg) {
     popdown_window_group_dialog(pPlayers_Dlg->pBeginWidgetList,
                        pPlayers_Dlg->pEndWidgetList);
-    FREE(pPlayers_Dlg);
+    FC_FREE(pPlayers_Dlg);
   }
 }
 
@@ -610,7 +609,7 @@
      
   h = WINDOW_TILE_HIGH + adj_size(3) + FRAME_WH;
       
-  pShort_Players_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pShort_Players_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
   pStr = create_str16_from_char(_("Nations") , adj_font(12));
   pStr->style |= TTF_STYLE_BOLD;
@@ -807,7 +806,7 @@
   if (pShort_Players_Dlg) {
     popdown_window_group_dialog(pShort_Players_Dlg->pBeginWidgetList,
                        pShort_Players_Dlg->pEndWidgetList);
-    FREE(pShort_Players_Dlg->pScroll);
-    FREE(pShort_Players_Dlg);
+    FC_FREE(pShort_Players_Dlg->pScroll);
+    FC_FREE(pShort_Players_Dlg);
   }
 }
Index: client/gui-sdl/chatline.c
===================================================================
--- client/gui-sdl/chatline.c   (Revision 11444)
+++ client/gui-sdl/chatline.c   (Arbeitskopie)
@@ -42,7 +42,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "mapview.h"
 #include "messagewin.h"
@@ -85,7 +84,7 @@
     send_chat(theinput);
 
     append_output_window(theinput);
-    FREE(theinput);
+    FC_FREE(theinput);
   }
   
   return -1;
@@ -136,7 +135,7 @@
     
     n += 1;
     n *= 2;
-    pUniStr = MALLOC(n);
+    pUniStr = fc_calloc(1, n);
     convertcopy_to_utf16(pUniStr, n, astring);
     add_to_chat_list(pUniStr, n);
   } else {
@@ -265,7 +264,7 @@
       /*real_append_output_window(theinput);*/
     }
     
-    FREE(pWidget->string16->text);
+    FC_FREE(pWidget->string16->text);
     pWidget->string16->n_alloc = 0;
   }
   return -1;
@@ -323,11 +322,11 @@
                                pConnDlg->pUsers_Dlg->pScroll->pScrollBar;
         pConnDlg->pUsers_Dlg->pScroll->count = 0;
       } else {
-        pConnDlg->pUsers_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+        pConnDlg->pUsers_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
         pConnDlg->pUsers_Dlg->pEndWidgetList = pConnDlg->pBeginWidgetList;
         pConnDlg->pUsers_Dlg->pBeginWidgetList = pConnDlg->pBeginWidgetList;
       
-        pConnDlg->pUsers_Dlg->pScroll = MALLOC(sizeof(struct ScrollBar));
+        pConnDlg->pUsers_Dlg->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
         pConnDlg->pUsers_Dlg->pScroll->count = 0;
         create_vertical_scrollbar(pConnDlg->pUsers_Dlg, 1,
                                        pConnDlg->active, TRUE, TRUE);  
@@ -405,7 +404,7 @@
   
   popdown_meswin_dialog();
   
-  pConnDlg = MALLOC(sizeof(struct CONNLIST));
+  pConnDlg = fc_calloc(1, sizeof(struct CONNLIST));
     
   pWindow = create_window(NULL, NULL, 10, 10, 0);
   pWindow->action = conn_dlg_callback;
@@ -457,7 +456,7 @@
     
   /* -------------------------------- */
   
-  pConnDlg->pChat_Dlg = MALLOC(sizeof(struct ADVANCED_DLG));
+  pConnDlg->pChat_Dlg = fc_calloc(1, sizeof(struct ADVANCED_DLG));
     
   n = conn_list_size(game.est_connections);
   
@@ -488,7 +487,7 @@
   pConnDlg->pChat_Dlg->pBeginActiveWidgetList = pBuf;
   pConnDlg->pChat_Dlg->pEndActiveWidgetList = pBuf;
   
-  pConnDlg->pChat_Dlg->pScroll = MALLOC(sizeof(struct ScrollBar));
+  pConnDlg->pChat_Dlg->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
   pConnDlg->pChat_Dlg->pScroll->count = 1;
   
   n = (pWindow->size.h - adj_size(44)) / pBuf->size.h;
@@ -590,16 +589,16 @@
     popdown_window_group_dialog(pConnDlg->pBeginWidgetList,
                                        pConnDlg->pEndWidgetList);
     if (pConnDlg->pUsers_Dlg) {
-      FREE(pConnDlg->pUsers_Dlg->pScroll);
-      FREE(pConnDlg->pUsers_Dlg);
+      FC_FREE(pConnDlg->pUsers_Dlg->pScroll);
+      FC_FREE(pConnDlg->pUsers_Dlg);
     }
     
     if (pConnDlg->pChat_Dlg) {
-      FREE(pConnDlg->pChat_Dlg->pScroll);
-      FREE(pConnDlg->pChat_Dlg);
+      FC_FREE(pConnDlg->pChat_Dlg->pScroll);
+      FC_FREE(pConnDlg->pChat_Dlg);
     }
     
-    FREE(pConnDlg);
+    FC_FREE(pConnDlg);
     return TRUE;
   }
   
Index: client/gui-sdl/gui_mem.h
===================================================================
--- client/gui-sdl/gui_mem.h    (Revision 11444)
+++ client/gui-sdl/gui_mem.h    (Arbeitskopie)
@@ -1,42 +0,0 @@
-/********************************************************************** 
- Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-***********************************************************************/
-
-/**********************************************************************
-                          gui_mem.h  -  description
-                             -------------------
-    begin                : Thu Apr 20 2000
-    copyright            : (C) 2002 by Rafał Bursig
-    email                : Rafał Bursig <bursig@xxxxxxxxx>
- **********************************************************************/
-
-#ifndef FC__GUI_MEM_H
-#define FC__GUI_MEM_H
-
-#include "mem.h"
-
-/* free with a check */
-#define FREE(ptr) do { if (ptr) free(ptr); ptr = NULL; } while(0)
-
-/* malloc with check and clear */
-#define MALLOC(size) fc_real_calloc( 1, (size), \
-                                       "malloc", __LINE__, __FILE__)
-
-/* fc_calloc in gui-sdl style */
-#define CALLOC(count , size)   fc_real_calloc((count), (size), \
-                                       "calloc", __LINE__, __FILE__)
-
-/* fc_realloc in gui-sdl style */
-#define REALLOC(ptr, size) fc_real_realloc((ptr), (size), "realloc", \
-                                          __LINE__, __FILE__)
-
-#endif
Index: client/gui-sdl/gui_zoom.c
===================================================================
--- client/gui-sdl/gui_zoom.c   (Revision 11444)
+++ client/gui-sdl/gui_zoom.c   (Arbeitskopie)
@@ -58,7 +58,6 @@
 
 /* gui-sdl */
 #include "graphics.h"
-#include "gui_mem.h"
 
 #include "gui_zoom.h"
 
@@ -175,11 +174,11 @@
   /*
    * Allocate memory for row increments 
    */
-  if ((sax = (Uint32 *) MALLOC((dst->w + 1) * sizeof(Uint32))) == NULL) {
+  if ((sax = (Uint32 *) fc_calloc(1, (dst->w + 1) * sizeof(Uint32))) == NULL) {
                return (-1);
   }
-  if ((say = (Uint32 *) MALLOC((dst->h + 1) * sizeof(Uint32))) == NULL) {
-    FREE(sax);
+  if ((say = (Uint32 *) fc_calloc(1, (dst->h + 1) * sizeof(Uint32))) == NULL) {
+    FC_FREE(sax);
     return (-1);
   }
 
@@ -285,8 +284,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
 
   return (0);
 }
@@ -306,11 +305,11 @@
   /*
    * Allocate memory for row increments 
    */
-  if ((sax = (Uint32 *) MALLOC((dst->w + 1) * sizeof(Uint32))) == NULL) {
+  if ((sax = (Uint32 *) fc_calloc(1, (dst->w + 1) * sizeof(Uint32))) == NULL) {
     return (-1);
   }
-  if ((say = (Uint32 *) MALLOC((dst->h + 1) * sizeof(Uint32))) == NULL) {
-    FREE(sax);
+  if ((say = (Uint32 *) fc_calloc(1, (dst->h + 1) * sizeof(Uint32))) == NULL) {
+    FC_FREE(sax);
     return (-1);
   }
 
@@ -431,8 +430,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
 
   return (0);
 }
@@ -452,11 +451,11 @@
   /*
    * Allocate memory for row increments 
    */
-  if ((sax = (Uint32 *) MALLOC((dst->w + 1) * sizeof(Uint32))) == NULL) {
+  if ((sax = (Uint32 *) fc_calloc(1, (dst->w + 1) * sizeof(Uint32))) == NULL) {
     return (-1);
   }
-  if ((say = (Uint32 *) MALLOC((dst->h + 1) * sizeof(Uint32))) == NULL) {
-    FREE(sax);
+  if ((say = (Uint32 *) fc_calloc(1, (dst->h + 1) * sizeof(Uint32))) == NULL) {
+    FC_FREE(sax);
     return (-1);
   }
 
@@ -618,8 +617,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
   
   return (0);
 }
@@ -639,11 +638,11 @@
   /*
    * Allocate memory for row increments 
    */
-  if ((sax = (Uint32 *) MALLOC((dst->w + 1) * sizeof(Uint32))) == NULL) {
+  if ((sax = (Uint32 *) fc_calloc(1, (dst->w + 1) * sizeof(Uint32))) == NULL) {
     return (-1);
   }
-  if ((say = (Uint32 *) MALLOC((dst->h + 1) * sizeof(Uint32))) == NULL) {
-    FREE(sax);
+  if ((say = (Uint32 *) fc_calloc(1, (dst->h + 1) * sizeof(Uint32))) == NULL) {
+    FC_FREE(sax);
     return (-1);
   }
 
@@ -805,8 +804,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
   
   return (0);
 }
@@ -836,8 +835,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_8bit_row_increments(src, dst, sax, say);
 
@@ -941,8 +940,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
   
   return 0;
 }
@@ -966,8 +965,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_8bit_row_increments(src, dst, sax, say);
 
@@ -1071,8 +1070,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
 
   return 0;
 }
@@ -1094,8 +1093,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_8bit_row_increments(src, dst, sax, say);
 
@@ -1193,8 +1192,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
 
   return 0;
 }
@@ -1219,8 +1218,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_8bit_row_increments(src, dst, sax, say);
 
@@ -1329,8 +1328,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
 
   return 0;
 }
@@ -1356,8 +1355,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_8bit_row_increments(src, dst, sax, say);
 
@@ -1450,8 +1449,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
   
   return 0;
 }
@@ -1476,8 +1475,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_8bit_row_increments(src, dst, sax, say);
 
@@ -1587,8 +1586,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
   
   return 0;
 }
@@ -1614,8 +1613,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_8bit_row_increments(src, dst, sax, say);
 
@@ -1708,8 +1707,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
   
   return 0;
 }
@@ -1760,8 +1759,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_8bit_row_increments(src, dst, sax, say);
 
@@ -1885,8 +1884,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
 
   return 0;
 }
@@ -1907,8 +1906,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_16bit_row_increments(src, dst, sax, say);
 
@@ -1962,8 +1961,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
     
   return 0;
 }
@@ -1983,8 +1982,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_16bit_row_increments(src, dst, sax, say);
 
@@ -2042,8 +2041,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
 
   return 0;
 }
@@ -2063,8 +2062,8 @@
   /*
    * Allocate memory for row increments 
    */
-  sax = MALLOC((dst->w + 1) * sizeof(Uint32));
-  say = MALLOC((dst->h + 1) * sizeof(Uint32));
+  sax = fc_calloc(1, (dst->w + 1) * sizeof(Uint32));
+  say = fc_calloc(1, (dst->h + 1) * sizeof(Uint32));
 
   precalculate_16bit_row_increments(src, dst, sax, say);
 
@@ -2118,8 +2117,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
 
   return 0;
 }
@@ -2145,13 +2144,13 @@
   /*
    * Allocate memory for row increments 
    */
-  if ((sax = (Uint32 *) MALLOC(dst->w * sizeof(Uint32))) == NULL) {
+  if ((sax = (Uint32 *) fc_calloc(1, dst->w * sizeof(Uint32))) == NULL) {
     return (-1);
   }
 
-  if ((say = (Uint32 *) MALLOC(dst->h * sizeof(Uint32))) == NULL) {
+  if ((say = (Uint32 *) fc_calloc(1, dst->h * sizeof(Uint32))) == NULL) {
     if (sax != NULL) {
-      FREE(sax);
+      FC_FREE(sax);
     }
     return -1;
   }
@@ -2239,8 +2238,8 @@
   /*
    * Remove temp arrays 
    */
-  FREE(sax);
-  FREE(say);
+  FC_FREE(sax);
+  FC_FREE(say);
 
   return 0;
 }
Index: client/gui-sdl/spaceshipdlg.c
===================================================================
--- client/gui-sdl/spaceshipdlg.c       (Revision 11444)
+++ client/gui-sdl/spaceshipdlg.c       (Arbeitskopie)
@@ -30,7 +30,6 @@
 #include "graphics.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "mapview.h"
@@ -132,7 +131,7 @@
     char cBuf[128];
     int w = 0, h = 0;
   
-    pSpaceShp = MALLOC(sizeof(struct SMALL_DLG));
+    pSpaceShp = fc_calloc(1, sizeof(struct SMALL_DLG));
     
     my_snprintf(cBuf, sizeof(cBuf), _("%s's SpaceShip"),
                                    get_nation_name(pPlayer->nation));
@@ -227,7 +226,7 @@
     popdown_window_group_dialog(pSpaceShp->pBeginWidgetList,
                                            pSpaceShp->pEndWidgetList);
     dialog_list_unlink(dialog_list, pSpaceShp);
-    FREE(pSpaceShp);
+    FC_FREE(pSpaceShp);
   }
   
 }
Index: client/gui-sdl/wldlg.c
===================================================================
--- client/gui-sdl/wldlg.c      (Revision 11444)
+++ client/gui-sdl/wldlg.c      (Arbeitskopie)
@@ -44,7 +44,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
@@ -103,21 +102,21 @@
   if(pEditor) {
     popdown_window_group_dialog(pEditor->pBeginWidgetList,
                                            pEditor->pEndWidgetList);
-    FREE(pEditor->pTargets->pScroll);
-    FREE(pEditor->pWork->pScroll);
+    FC_FREE(pEditor->pTargets->pScroll);
+    FC_FREE(pEditor->pWork->pScroll);
     if(pEditor->pGlobal) {
-      FREE(pEditor->pGlobal->pScroll);
-      FREE(pEditor->pGlobal);
+      FC_FREE(pEditor->pGlobal->pScroll);
+      FC_FREE(pEditor->pGlobal);
     }
-    FREE(pEditor->pTargets);
-    FREE(pEditor->pWork);
-    FREE(pEditor->pCopy_WorkList);
+    FC_FREE(pEditor->pTargets);
+    FC_FREE(pEditor->pWork);
+    FC_FREE(pEditor->pCopy_WorkList);
         
     if(city_dialog_is_open(pEditor->pCity)) {
       enable_city_dlg_widgets();
     }
   
-    FREE(pEditor);
+    FC_FREE(pEditor);
     flush_dirty();
   }
   return -1;
@@ -176,16 +175,16 @@
   /* popdown dlg */
   popdown_window_group_dialog(pEditor->pBeginWidgetList,
                                            pEditor->pEndWidgetList);
-  FREE(pEditor->pTargets->pScroll);
-  FREE(pEditor->pWork->pScroll);
+  FC_FREE(pEditor->pTargets->pScroll);
+  FC_FREE(pEditor->pWork->pScroll);
   if(pEditor->pGlobal) {
-    FREE(pEditor->pGlobal->pScroll);
-    FREE(pEditor->pGlobal);
+    FC_FREE(pEditor->pGlobal->pScroll);
+    FC_FREE(pEditor->pGlobal);
   }
-  FREE(pEditor->pTargets);
-  FREE(pEditor->pWork);
-  FREE(pEditor->pCopy_WorkList);
-  FREE(pEditor);
+  FC_FREE(pEditor->pTargets);
+  FC_FREE(pEditor->pWork);
+  FC_FREE(pEditor->pCopy_WorkList);
+  FC_FREE(pEditor);
   
   if(city_dialog_is_open(pCity)) {
     enable_city_dlg_widgets();
@@ -206,7 +205,7 @@
   if(pWidget->string16->text) {
     char *pText = convert_to_chars(pWidget->string16->text);
     my_snprintf(pEditor->pCopy_WorkList->name, MAX_LEN_NAME, "%s", pText);
-    FREE(pText);
+    FC_FREE(pText);
   } else {
     /* empty input -> restore previous content */
     copy_chars_to_string16(pWidget->string16, pEditor->pCopy_WorkList->name);
@@ -269,7 +268,7 @@
   set_wstate(pBuf, FC_WS_NORMAL);
   pBuf->action = worklist_editor_item_callback;
         
-  pBuf->data.ptr = MALLOC(sizeof(int));
+  pBuf->data.ptr = fc_calloc(1, sizeof(int));
   *((int *)pBuf->data.ptr) = worklist_length(pEditor->pCopy_WorkList) - 1;
     
   pBuf->ID = MAX_ID - cid_encode(prod);
@@ -482,7 +481,7 @@
     change_production(pEditor->pCopy_WorkList->entries[0]);
     worklist_advance(pEditor->pCopy_WorkList);
     del_widget_from_vertical_scroll_widget_list(pEditor->pWork, pItem);
-    FREE(pBuf->data.ptr);
+    FC_FREE(pBuf->data.ptr);
     if(pBuf != pEditor->pWork->pBeginActiveWidgetList) {
       do{
         pBuf = pBuf->prev;
@@ -710,7 +709,7 @@
       set_wstate(pBuf, FC_WS_NORMAL);
       pBuf->action = worklist_editor_item_callback;
       pBuf->size.w = adj_size(126);  
-      pBuf->data.ptr = MALLOC(sizeof(int));
+      pBuf->data.ptr = fc_calloc(1, sizeof(int));
       *((int *)pBuf->data.ptr) = firstfree;
         
       add_widget_to_vertical_scroll_widget_list(pEditor->pWork,
@@ -808,7 +807,7 @@
         set_wstate(pBuf, FC_WS_NORMAL);
         pBuf->action = worklist_editor_item_callback;
         pBuf->size.w = adj_size(126);  
-        pBuf->data.ptr = MALLOC(sizeof(int));
+        pBuf->data.ptr = fc_calloc(1, sizeof(int));
         *((int *)pBuf->data.ptr) = count;
         
         add_widget_to_vertical_scroll_widget_list(pEditor->pWork,
@@ -1041,11 +1040,11 @@
   
   assert(pWorkList != NULL);
   
-  pEditor = MALLOC(sizeof(struct EDITOR));
+  pEditor = fc_calloc(1, sizeof(struct EDITOR));
   
   pEditor->pCity = pCity;
   pEditor->pOrginal_WorkList = pWorkList;
-  pEditor->pCopy_WorkList = MALLOC(sizeof(struct worklist));
+  pEditor->pCopy_WorkList = fc_calloc(1, sizeof(struct worklist));
   copy_worklist(pEditor->pCopy_WorkList, pWorkList);
   
   if(pCity) {
@@ -1176,8 +1175,8 @@
      will have this field NULL
   */
   
-  pEditor->pWork = MALLOC(sizeof(struct ADVANCED_DLG));
-  pEditor->pWork->pScroll = MALLOC(sizeof(struct ScrollBar));
+  pEditor->pWork = fc_calloc(1, sizeof(struct ADVANCED_DLG));
+  pEditor->pWork->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
   pEditor->pWork->pScroll->count = 0;
   pEditor->pWork->pScroll->active = MAX_LEN_WORKLIST;
   pEditor->pWork->pScroll->step = 1;
@@ -1224,7 +1223,7 @@
     set_wstate(pBuf, FC_WS_NORMAL);
     pBuf->action = worklist_editor_item_callback;
         
-    pBuf->data.ptr = MALLOC(sizeof(int));
+    pBuf->data.ptr = fc_calloc(1, sizeof(int));
     *((int *)pBuf->data.ptr) = count;
     
     add_to_gui_list(MAX_ID - cid_encode(prod), pBuf);
@@ -1298,7 +1297,7 @@
       }
     }
     if(count) {
-      pEditor->pGlobal = MALLOC(sizeof(struct ADVANCED_DLG));
+      pEditor->pGlobal = fc_calloc(1, sizeof(struct ADVANCED_DLG));
       pEditor->pGlobal->pEndWidgetList = pLast->prev;
       pEditor->pGlobal->pEndActiveWidgetList = pLast->prev;
       pEditor->pGlobal->pBeginWidgetList = pBuf;
@@ -1306,7 +1305,7 @@
     
       if(count > 6) {
         pEditor->pGlobal->pActiveWidgetList = pLast->prev;
-        pEditor->pGlobal->pScroll = MALLOC(sizeof(struct ScrollBar));
+        pEditor->pGlobal->pScroll = fc_calloc(1, sizeof(struct ScrollBar));
         pEditor->pGlobal->pScroll->count = count;
         pEditor->pGlobal->pScroll->active = 4;
         pEditor->pGlobal->pScroll->step = 1;
@@ -1572,7 +1571,7 @@
     }
   } unit_type_iterate_end;
   
-  pEditor->pTargets = MALLOC(sizeof(struct ADVANCED_DLG));
+  pEditor->pTargets = fc_calloc(1, sizeof(struct ADVANCED_DLG));
   
   pEditor->pTargets->pEndWidgetList = pLast->prev;
   pEditor->pTargets->pBeginWidgetList = pBuf;
@@ -1749,14 +1748,14 @@
     if(pEditor) {
     popdown_window_group_dialog(pEditor->pBeginWidgetList,
                                            pEditor->pEndWidgetList);
-    FREE(pEditor->pTargets->pScroll);
-    FREE(pEditor->pWork->pScroll);
-    FREE(pEditor->pGlobal->pScroll);
-    FREE(pEditor->pGlobal);
-    FREE(pEditor->pTargets);
-    FREE(pEditor->pWork);
-    FREE(pEditor->pCopy_WorkList);
-    FREE(pEditor);
+    FC_FREE(pEditor->pTargets->pScroll);
+    FC_FREE(pEditor->pWork->pScroll);
+    FC_FREE(pEditor->pGlobal->pScroll);
+    FC_FREE(pEditor->pGlobal);
+    FC_FREE(pEditor->pTargets);
+    FC_FREE(pEditor->pWork);
+    FC_FREE(pEditor->pCopy_WorkList);
+    FC_FREE(pEditor);
   }
 
 }
Index: client/gui-sdl/gui_string.c
===================================================================
--- client/gui-sdl/gui_string.c (Revision 11444)
+++ client/gui-sdl/gui_string.c (Arbeitskopie)
@@ -35,7 +35,6 @@
 #include "graphics.h"
 #include "gui_iconv.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "unistring.h"
 
 #include "gui_string.h"
@@ -126,14 +125,14 @@
       while (UniTexts[count]) {
         if (TTF_SizeUNICODE(pString16->font, UniTexts[count], &ww, &hh) < 0) {
           do {
-           FREE(UniTexts[count]);
+           FC_FREE(UniTexts[count]);
             count++;
          } while(UniTexts[count]);
          die("TTF_SizeUNICODE return ERROR !");
         }
         w = MAX(w, ww);
         h += hh;
-        FREE(UniTexts[count]);
+        FC_FREE(UniTexts[count]);
         count++;
       }
     } else {  
@@ -158,12 +157,12 @@
 /**************************************************************************
   Create string16 struct with ptsize font.
   Font will be loaded or aliased with existing font of that size.
-  pInTextString must be allocated in memory (MALLOC/CALLOC)
+  pInTextString must be allocated in memory (MALLOC/fc_calloc)
 **************************************************************************/
 SDL_String16 * create_string16(Uint16 *pInTextString,
                                        size_t n_alloc, Uint16 ptsize)
 {
-  SDL_String16 *str = MALLOC(sizeof(SDL_String16));
+  SDL_String16 *str = fc_calloc(1, sizeof(SDL_String16));
 
   if (!ptsize) {
     str->ptsize = DEFAULT_PTSIZE;
@@ -173,7 +172,7 @@
   
   if ((str->font = load_font(str->ptsize)) == NULL) {
     freelog(LOG_ERROR, _("Error in create_string16: Aborting ..."));
-    FREE(str);
+    FC_FREE(str);
     return str;
   }
 
@@ -188,7 +187,7 @@
   str->fgcol.unused = 0xff;
   str->render = 2;             /* oh... alpha :) */
 
-  /* pInTextString must be allocated in memory (MALLOC/CALLOC) */
+  /* pInTextString must be allocated in memory (MALLOC/fc_calloc) */
   str->text = pInTextString;
   str->n_alloc = n_alloc;
   
@@ -212,7 +211,7 @@
     /* allocated more if this is only a small increase on before: */
     size_t n1 = (3 * pString->n_alloc) / 2;
     pString->n_alloc = (n > n1) ? n : n1;
-    pString->text = REALLOC(pString->text, pString->n_alloc);
+    pString->text = fc_realloc(pString->text, pString->n_alloc);
   }
   
   convertcopy_to_utf16(pString->text, pString->n_alloc, pCharString);
@@ -323,7 +322,7 @@
     count++;
   }
 
-  pTmp = CALLOC(count, sizeof(SDL_Surface *));
+  pTmp = fc_calloc(count, sizeof(SDL_Surface *));
 
   for (i = 0; i < count; i++) {
     pString->text = UniTexts[i];
@@ -388,11 +387,11 @@
 
   /* Free Memmory */
   for (i = 0; i < count; i++) {
-    FREE(UniTexts[i]);
+    FC_FREE(UniTexts[i]);
     SDL_FreeSurface(pTmp[i]);
   }
   
-  FREE(pTmp);
+  FC_FREE(pTmp);
 
   return pText;
 }
@@ -645,7 +644,7 @@
   /* add new font to list */
   if (Sizeof_Font_TAB == 0) {
     Sizeof_Font_TAB++;
-    Font_TAB_TMP = MALLOC(sizeof(struct TTF_Font_Chain));
+    Font_TAB_TMP = fc_calloc(1, sizeof(struct TTF_Font_Chain));
     Font_TAB = Font_TAB_TMP;
   } else {
     /* Go to end of chain */
@@ -654,13 +653,14 @@
       Font_TAB_TMP = Font_TAB_TMP->next;
 
     Sizeof_Font_TAB++;
-    Font_TAB_TMP->next = MALLOC(sizeof(struct TTF_Font_Chain));
+    Font_TAB_TMP->next = fc_calloc(1, sizeof(struct TTF_Font_Chain));
     Font_TAB_TMP = Font_TAB_TMP->next;
   }
 
   Font_TAB_TMP->ptsize = ptsize;
   Font_TAB_TMP->count = 1;
   Font_TAB_TMP->font = font_tmp;
+  Font_TAB_TMP->next = NULL;
 
   return font_tmp;
 }
@@ -711,14 +711,14 @@
   }
   Font_TAB_TMP->next = NULL;
   Sizeof_Font_TAB--;
-  FREE(Font_TAB_TMP);
+  FC_FREE(Font_TAB_TMP);
 }
 
 void free_font_system(void)
 {
   struct TTF_Font_Chain *Font_TAB_TMP;
     
-  FREE(pFont_with_FullPath);
+  FC_FREE(pFont_with_FullPath);
   while(Font_TAB) {
     if (Font_TAB->next) {
       Font_TAB_TMP = Font_TAB;
@@ -726,12 +726,12 @@
       if(Font_TAB_TMP->font) {
        TTF_CloseFont(Font_TAB_TMP->font);
       }
-      FREE(Font_TAB_TMP);
+      FC_FREE(Font_TAB_TMP);
     } else {
       if(Font_TAB->font) {
        TTF_CloseFont(Font_TAB->font);
       }
-      FREE(Font_TAB);
+      FC_FREE(Font_TAB);
     }
   }
   
Index: client/gui-sdl/gui_string.h
===================================================================
--- client/gui-sdl/gui_string.h (Revision 11444)
+++ client/gui-sdl/gui_string.h (Arbeitskopie)
@@ -85,7 +85,7 @@
 #define FREESTRING16( pString16 )              \
 do {                                           \
        if (pString16) {                        \
-               FREE(pString16->text);          \
+               FC_FREE(pString16->text);               \
                unload_font(pString16->ptsize); \
                free(pString16);                \
                pString16 = NULL;               \
Index: client/gui-sdl/connectdlg.c
===================================================================
--- client/gui-sdl/connectdlg.c (Revision 11444)
+++ client/gui-sdl/connectdlg.c (Arbeitskopie)
@@ -43,7 +43,6 @@
 #include "gui_iconv.h"
 #include "gui_id.h"
 #include "gui_main.h"
-#include "gui_mem.h"
 #include "gui_stuff.h"
 #include "gui_tilespec.h"
 #include "gui_zoom.h"
@@ -268,7 +267,7 @@
     return -1;
   }
   
-  pMeta_Severs = MALLOC(sizeof(struct ADVANCED_DLG));
+  pMeta_Severs = fc_calloc(1, sizeof(struct ADVANCED_DLG));
     
   pWindow = create_window(pDest, NULL, adj_size(10), adj_size(10), 0);
   pWindow->action = meta_severs_window_callback;
@@ -436,7 +435,7 @@
   
   if (tmp) {  
     sz_strlcpy(user_name, tmp);
-    FREE(tmp);
+    FC_FREE(tmp);
   } else {
     /* empty input -> restore previous content */
     copy_chars_to_string16(pWidget->string16, user_name);
@@ -457,7 +456,7 @@
   
   if (tmp) {
     sz_strlcpy(server_host, tmp);
-    FREE(tmp);
+    FC_FREE(tmp);
   } else {
     /* empty input -> restore previous content */
     copy_chars_to_string16(pWidget->string16, server_host);
@@ -479,7 +478,7 @@
   
   if (tmp) {
     sscanf(tmp, "%d", &server_port);
-    FREE(tmp);
+    FC_FREE(tmp);
   } else {
     /* empty input -> restore previous content */
     my_snprintf(pCharPort, sizeof(pCharPort), "%d", server_port);
@@ -525,8 +524,8 @@
   queue_flush();
   close_connection_dialog();
   
-  pStartMenu = MALLOC(sizeof(struct SMALL_DLG));
-  area = MALLOC(sizeof(SDL_Rect)); 
+  pStartMenu = fc_calloc(1, sizeof(struct SMALL_DLG));
+  area = fc_calloc(1, sizeof(SDL_Rect)); 
     
   /* -------------------------- */
 
@@ -690,7 +689,7 @@
   char *tmp = convert_to_chars(pWidget->string16->text);
   if(tmp) {
     my_snprintf(password, MAX_LEN_NAME, "%s", tmp);
-    FREE(tmp);
+    FC_FREE(tmp);
   }
   return -1;
 }
@@ -743,8 +742,8 @@
   queue_flush();
   close_connection_dialog();
   
-  pStartMenu = MALLOC(sizeof(struct SMALL_DLG));
-  area = MALLOC(sizeof(SDL_Rect)); 
+  pStartMenu = fc_calloc(1, sizeof(struct SMALL_DLG));
+  area = fc_calloc(1, sizeof(SDL_Rect)); 
     
   /* -------------------------- */
 
@@ -756,7 +755,7 @@
   /* ====================== INIT =============================== */
   change_ptsize16(pStr, adj_font(16));
   pStr->fgcol = color_black;
-  FREE(pStr->text);
+  FC_FREE(pStr->text);
   
   pBuf = create_edit(NULL, pDest, pStr, adj_size(210),
                (WF_PASSWD_EDIT|WF_DRAW_THEME_TRANSPARENT|WF_FREE_DATA));
@@ -848,7 +847,7 @@
   
   if(tmp) {
     my_snprintf(password, MAX_LEN_NAME, "%s", tmp);
-    FREE(tmp);
+    FC_FREE(tmp);
     set_wstate(pWidget->prev, FC_WS_NORMAL);
     redraw_edit(pWidget->prev);
     flush_rect(pWidget->prev->size);
@@ -871,8 +870,8 @@
     memset(password, 0, MAX_LEN_NAME);
     password[0] = '\0';
     
-    FREE(pWidget->next->string16->text);/* first edit */
-    FREE(pWidget->string16->text); /* secound edit */
+    FC_FREE(pWidget->next->string16->text);/* first edit */
+    FC_FREE(pWidget->string16->text); /* secound edit */
     
     set_wstate(pWidget, FC_WS_DISABLED);
     
@@ -908,8 +907,8 @@
   queue_flush();
   close_connection_dialog();
   
-  pStartMenu = MALLOC(sizeof(struct SMALL_DLG));
-  area = MALLOC(sizeof(SDL_Rect)); 
+  pStartMenu = fc_calloc(1, sizeof(struct SMALL_DLG));
+  area = fc_calloc(1, sizeof(SDL_Rect)); 
     
   /* -------------------------- */
 
@@ -922,7 +921,7 @@
   change_ptsize16(pStr, adj_font(16));
   pStr->fgcol = color_black;
   
-  FREE(pStr->text);
+  FC_FREE(pStr->text);
   pStr->n_alloc = 0;
   
   pBuf = create_edit(NULL, pDest, pStr, adj_size(210),
@@ -1052,13 +1051,13 @@
   
     del_group_of_widgets_from_gui_list(pStartMenu->pBeginWidgetList,
                                                pStartMenu->pEndWidgetList);
-    FREE(pStartMenu);
+    FC_FREE(pStartMenu);
   }
   if(pMeta_Severs) {
     popdown_window_group_dialog(pMeta_Severs->pBeginWidgetList,
                                  pMeta_Severs->pEndWidgetList);
-    FREE(pMeta_Severs->pScroll);
-    FREE(pMeta_Severs);
+    FC_FREE(pMeta_Severs->pScroll);
+    FC_FREE(pMeta_Severs);
     if(pServer_list) {
       server_scan_finish(pServer_scan);
       pServer_scan = NULL;
@@ -1117,7 +1116,7 @@
   }
   
   /* create dialog */
-  pStartMenu = MALLOC(sizeof(struct SMALL_DLG));
+  pStartMenu = fc_calloc(1, sizeof(struct SMALL_DLG));
     
   /* Start New Game */
   pWidget =
@@ -1227,7 +1226,7 @@
        (pFirst->dst->w - w) - adj_size(20), (pFirst->dst->h - (h * count)) - 
adj_size(20),
                w, h, pWidget, pFirst);
                
-  pArea = MALLOC(sizeof(SDL_Rect));
+  pArea = fc_calloc(1, sizeof(SDL_Rect));
   
   pArea->x = pFirst->size.x - FRAME_WH;
   pArea->y = pFirst->size.y - FRAME_WH;
Index: client/gui-sdl/gui_iconv.c
===================================================================
--- client/gui-sdl/gui_iconv.c  (Revision 11444)
+++ client/gui-sdl/gui_iconv.c  (Arbeitskopie)
@@ -47,8 +47,10 @@
 #define ICONV_CONST    const
 #endif /* ICONV_CONST */
 
+/* utility */
+#include "mem.h"
+
 /* gui-sdl */
-#include "gui_mem.h"
 #include "unistring.h"
 
 #include "gui_iconv.h"
@@ -97,7 +99,7 @@
   if (!pResult) {
     /* From 8 bit code to UTF-16 (16 bit code) */
     ulength = length * 2;
-    pResult = MALLOC(ulength);
+    pResult = fc_calloc(1, ulength);
   }
 
   iconv(cd, NULL, NULL, NULL, NULL);   /* return to the initial state */
@@ -121,7 +123,7 @@
          iconv_close(cd);
          errno = saved_errno;
          if(!pToUniString) {
-           FREE(pResult);
+           FC_FREE(pResult);
          }
          return pToUniString;
        }
@@ -135,7 +137,7 @@
        iconv_close(cd);
        errno = saved_errno;
        if(!pToUniString) {
-         FREE(pResult);
+         FC_FREE(pResult);
        }
        return pToUniString;
       }
@@ -188,7 +190,7 @@
   } else {
     /* From 16 bit code to 8 bit code */
     length = ulength / 2;
-    pResult = MALLOC(length);
+    pResult = fc_calloc(1, length);
   }
   
   iconv(cd, NULL, NULL, NULL, NULL);   /* return to the initial state */
@@ -212,7 +214,7 @@
          iconv_close(cd);
          errno = saved_errno;
          if(!pToString) {
-           FREE(pResult);
+           FC_FREE(pResult);
          }
          return pToString;
        }
@@ -226,7 +228,7 @@
        iconv_close(cd);
        errno = saved_errno;
        if(!pToString) {
-         FREE(pResult);
+         FC_FREE(pResult);
        }
        return pToString;
       }
Index: client/gui-sdl/Makefile.am
===================================================================
--- client/gui-sdl/Makefile.am  (Revision 11444)
+++ client/gui-sdl/Makefile.am  (Arbeitskopie)
@@ -55,7 +55,6 @@
        gui_id.h        \
        gui_main.c      \
        gui_main.h      \
-       gui_mem.h       \
        gui_string.c    \
        gui_string.h    \
        gui_stuff.c     \

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#3372) Clutter: gui_mem "hacks" in sdl client, Christian Prochaska <=