* fix a memleak in the msg edit window
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 29 Jun 2007 17:05:42 +0000 (17:05 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 29 Jun 2007 17:05:42 +0000 (17:05 +0000)
* fix a memleak when registering the update_interval for the alarm daemon

pmo-trunk-r2503

src/maemo/modest-msg-edit-window.c
src/maemo/modest-platform.c

index 2948e9c..32a4e17 100644 (file)
@@ -1090,12 +1090,16 @@ modest_msg_edit_window_free_msg_data (ModestMsgEditWindow *edit_window,
        g_free (data->subject);
        g_free (data->plain_body);
        g_free (data->html_body);
+       g_free (data->account_name);
+       
        if (data->draft_msg != NULL) {
                g_object_unref (data->draft_msg);
                data->draft_msg = NULL;
        }
-       g_free (data->account_name);
 
+       g_list_foreach (data->attachments, (GFunc)g_free, NULL);
+       g_list_free (data->attachments);
+       
        /* TODO: Free data->attachments? */
 
        g_slice_free (MsgData, data);
index 12a4c94..d084d7e 100644 (file)
@@ -936,26 +936,28 @@ gboolean modest_platform_set_update_interval (guint minutes)
        st_time->tm_min += minutes;
        
        /* Set the time in alarm_event_t structure: */
-       alarm_event_t event;
-       memset (&event, 0, sizeof (alarm_event_t));
-       event.alarm_time = mktime (st_time);
+       alarm_event_t *event = g_new0(alarm_event_t, 1);
+       event->alarm_time = mktime (st_time);
 
        /* Specify what should happen when the alarm happens:
         * It should call this D-Bus method: */
         
        /* Note: I am surpised that alarmd can't just use the modest.service file
         * for this. murrayc. */
-       event.dbus_path = g_strdup(PREFIX "/bin/modest");
+       event->dbus_path = g_strdup(PREFIX "/bin/modest");
        
-       event.dbus_interface = g_strdup (MODEST_DBUS_IFACE);
-       event.dbus_service = g_strdup (MODEST_DBUS_SERVICE);
-       event.dbus_name = g_strdup (MODEST_DBUS_METHOD_SEND_RECEIVE);
+       event->dbus_interface = g_strdup (MODEST_DBUS_IFACE);
+       event->dbus_service = g_strdup (MODEST_DBUS_SERVICE);
+       event->dbus_name = g_strdup (MODEST_DBUS_METHOD_SEND_RECEIVE);
 
        /* Otherwise, a dialog will be shown if exect_name or dbus_path is NULL,
        even though we have specified no dialog text: */
-       event.flags = ALARM_EVENT_NO_DIALOG;
+       event->flags = ALARM_EVENT_NO_DIALOG;
        
-       alarm_cookie = alarm_event_add (&event);
+       alarm_cookie = alarm_event_add (event);
+
+       /* now, free it */
+       alarm_event_free (event);
        
        /* Store the alarm ID in GConf, so we can remove it later:
         * This is apparently valid between application instances. */