[Xfce4-commits] <xfce4-weather-plugin:master> Fix a bunch of memory leaks.

Harald Judt noreply at xfce.org
Fri Jul 13 16:50:25 CEST 2012


Updating branch refs/heads/master
         to 3293bacf64e190c858d2a321f5022cba8cc3332e (commit)
       from 7c8fbaeb6ac3ed5fbd6b30a834c65bf0ca5799a3 (commit)

commit 3293bacf64e190c858d2a321f5022cba8cc3332e
Author: Harald Judt <h.judt at gmx.at>
Date:   Fri Jul 13 14:22:59 2012 +0200

    Fix a bunch of memory leaks.
    
    Fix some memory leaks related to translations in summary and
    to the creation of current conditions.

 panel-plugin/weather-summary.c |   11 +++++++----
 panel-plugin/weather.c         |    3 +++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
index c33c3b1..960a872 100644
--- a/panel-plugin/weather-summary.c
+++ b/panel-plugin/weather-summary.c
@@ -404,7 +404,7 @@ make_forecast (xfceweather_data *data)
     GdkColor lightbg = {0, 0xeaea, 0xeaea, 0xeaea};
     GdkColor darkbg = {0, 0x6666, 0x6666, 0x6666};
     gint i, weekday, daytime;
-    gchar *dayname, *wind_speed, *value, *rawvalue;
+    gchar *dayname, *wind_speed, *wind_direction, *value, *rawvalue;
     xml_time *fcdata;
     time_t now_t = time(NULL), fcday_t;
     struct tm fcday_tm;
@@ -439,13 +439,14 @@ make_forecast (xfceweather_data *data)
         fcday_t = time_calc_day(fcday_tm, i);
         weekday = localtime(&fcday_t)->tm_wday;
         if (i == 0)
-            dayname = _("Today");
+            dayname = g_strdup_printf(_("Today"));
         else if (i == 1)
-            dayname = _("Tomorrow");
+            dayname = g_strdup_printf(_("Tomorrow"));
         else
             dayname = translate_day(weekday);
 
         ebox = add_forecast_header(dayname, 90.0, &darkbg);
+        g_free(dayname);
 
         gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(ebox),
                                   0, 1, i+1, i+2);
@@ -495,12 +496,14 @@ make_forecast (xfceweather_data *data)
                     g_free(value);
 
                     rawvalue = get_data(fcdata, data->unit_system, WIND_DIRECTION);
+                    wind_direction = translate_wind_direction(rawvalue);
                     wind_speed = get_data(fcdata, data->unit_system, WIND_SPEED);
                     value = g_strdup_printf("%s %s %s",
-                                            translate_wind_direction(rawvalue),
+                                            wind_direction,
                                             wind_speed,
                                             get_unit(fcdata, data->unit_system, WIND_SPEED));
                     g_free(wind_speed);
+                    g_free(wind_direction);
                     g_free(rawvalue);
                     label = gtk_label_new(value);
                     gtk_box_pack_start(GTK_BOX(forecast_box), label, TRUE, TRUE, 0);
diff --git a/panel-plugin/weather.c b/panel-plugin/weather.c
index aac2fdf..e3c8c03 100644
--- a/panel-plugin/weather.c
+++ b/panel-plugin/weather.c
@@ -457,6 +457,9 @@ update_weatherdata (xfceweather_data *data)
       /* update current conditions, icon and labels */
       if (data->weatherdata)
         {
+          if (data->weatherdata->current_conditions)
+              xml_time_free(data->weatherdata->current_conditions);
+
           data->weatherdata->current_conditions = make_current_conditions(data->weatherdata);
           data->last_conditions_update = time(NULL);
           set_icon_current (data);


More information about the Xfce4-commits mailing list