[evolution-data-server/gnome-3-0] Fix few memory leaks



commit f6e5e63fb3c932f0329967210e90172db994a9c0
Author: Milan Crha <mcrha redhat com>
Date:   Mon Apr 18 19:15:17 2011 +0200

    Fix few memory leaks

 addressbook/libedata-book/e-data-book.c    |   14 ++++++++++++++
 calendar/libecal/e-cal-component.c         |    4 ++--
 calendar/libecal/e-cal-util.c              |    5 ++++-
 calendar/libedata-cal/e-data-cal-factory.c |   11 +++++++++++
 4 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/addressbook/libedata-book/e-data-book.c b/addressbook/libedata-book/e-data-book.c
index 5495f1e..ccd109f 100644
--- a/addressbook/libedata-book/e-data-book.c
+++ b/addressbook/libedata-book/e-data-book.c
@@ -893,6 +893,19 @@ e_data_book_dispose (GObject *object)
 }
 
 static void
+data_book_finalize (GObject *object)
+{
+	EDataBook *book = E_DATA_BOOK (object);
+
+	if (book->priv->gdbus_object) {
+		g_object_unref (book->priv->gdbus_object);
+		book->priv->gdbus_object = NULL;
+	}
+
+	G_OBJECT_CLASS (e_data_book_parent_class)->finalize (object);
+}
+
+static void
 e_data_book_class_init (EDataBookClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -900,6 +913,7 @@ e_data_book_class_init (EDataBookClass *klass)
 	g_type_class_add_private (klass, sizeof (EDataBookPrivate));
 
 	object_class->dispose = e_data_book_dispose;
+	object_class->finalize = data_book_finalize;
 
 	if (!op_pool) {
 		op_pool = g_thread_pool_new (operation_thread, NULL, 10, FALSE, NULL);
diff --git a/calendar/libecal/e-cal-component.c b/calendar/libecal/e-cal-component.c
index 92f8f35..21f8f6f 100644
--- a/calendar/libecal/e-cal-component.c
+++ b/calendar/libecal/e-cal-component.c
@@ -308,9 +308,9 @@ free_icalcomponent (ECalComponent *comp, gboolean free)
 	priv->categories = NULL;
 
 	priv->classification = NULL;
-	priv->comment_list = NULL;
+	priv->comment_list = free_slist (priv->comment_list);
 	priv->completed = NULL;
-	priv->contact_list = NULL;
+	priv->contact_list = free_slist (priv->contact_list);
 	priv->created = NULL;
 
 	priv->description_list = free_slist (priv->description_list);
diff --git a/calendar/libecal/e-cal-util.c b/calendar/libecal/e-cal-util.c
index b9fc1ca..1fb404d 100644
--- a/calendar/libecal/e-cal-util.c
+++ b/calendar/libecal/e-cal-util.c
@@ -1209,7 +1209,6 @@ e_cal_util_get_component_occur_times (ECalComponent *comp,
 {
 	struct icalrecurrencetype ir;
 	ECalComponentDateTime dt_start, dt_end;
-	GSList *rrules = NULL, *exrules = NULL, *elem, *rdates = NULL;
 
 	g_return_if_fail (comp != NULL);
 	g_return_if_fail (start != NULL);
@@ -1258,6 +1257,8 @@ e_cal_util_get_component_occur_times (ECalComponent *comp,
 		/* ALARMS, EVENTS: DTEND and reccurences */
 
 		if (e_cal_component_has_recurrences (comp)) {
+			GSList *rrules = NULL, *exrules = NULL, *elem, *rdates = NULL;
+
 			/* Do the RRULEs, EXRULEs and RDATEs*/
 			e_cal_component_get_rrule_property_list (comp, &rrules);
 			e_cal_component_get_exrule_property_list (comp, &exrules);
@@ -1316,6 +1317,8 @@ e_cal_util_get_component_occur_times (ECalComponent *comp,
 				else if (rdate_end > *end)
 					*end = rdate_end;
 			}
+
+			e_cal_component_free_period_list (rdates);
 		}
 
 		/* Get dtend of the component and convert it to UTC */
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index f675940..0b02e42 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -578,6 +578,7 @@ static void
 e_data_cal_factory_finalize (GObject *object)
 {
 	EDataCalFactory *factory = E_DATA_CAL_FACTORY (object);
+	gint ii;
 
 	g_return_if_fail (factory != NULL);
 
@@ -592,6 +593,16 @@ e_data_cal_factory_finalize (GObject *object)
 
 	g_mutex_free (factory->priv->backends_mutex);
 
+	for (ii = 0; ii < E_CAL_SOURCE_TYPE_LAST; ii++) {
+		if (factory->priv->lists[ii]) {
+			g_object_unref (factory->priv->lists[ii]);
+			factory->priv->lists[ii] = NULL;
+		}
+
+		g_slist_free (factory->priv->backends_by_type[ii]);
+		factory->priv->backends_by_type[ii] = NULL;
+	}
+
 	/* Chain up to parent's finalize() method. */
 	G_OBJECT_CLASS (e_data_cal_factory_parent_class)->finalize (object);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]