[evolution-patches] Patch for some memory leaks e-d-s/servers/groupwise



Hi,

The attached patch fixes dome memory leaks in the eds/servers/groupwise

I have made the changes in e_gw_container.[ch]

Thanks,

Vivek Jain

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.132
diff -u -p -r1.132 ChangeLog
--- ChangeLog	7 Apr 2005 15:49:59 -0000	1.132
+++ ChangeLog	22 Apr 2005 07:26:01 -0000
@@ -1,3 +1,14 @@
+2005-04-22 Vivek Jain <jvivek novell com>
+	
+	* e-gw-cotainer.[ch]: 	
+	(e_gw_conainer_get_modified)
+	(e_gw_container_get_owner):
+	chaned the type of "modified" and "owner" to char *	
+	* e-gw-container.c :(e_gw_container_dispose) moved the code that frees
+	to finalize
+	(e_gw_container_finalize) :freeing the members of priv
+	added a function free_node to free each of the node of user_list
+
 2005-04-07  Parthasarathi Susarla <sparthasarathi novell com>
 	
 	* e-gw-connection.c: (e_gw_connection_get_quick_messages):
Index: e-gw-container.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-container.h,v
retrieving revision 1.9
diff -u -p -r1.9 e-gw-container.h
--- e-gw-container.h	20 Jan 2005 07:01:37 -0000	1.9
+++ e-gw-container.h	22 Apr 2005 07:26:01 -0000
@@ -87,8 +87,8 @@ void          e_gw_container_set_is_writ
 gboolean     e_gw_container_get_is_frequent_contacts (EGwContainer *container);
 void         e_gw_container_set_is_frequent_contacts (EGwContainer *container, gboolean is_frequent_contacts);
 gboolean    e_gw_container_is_root (EGwContainer *container) ;
-const char *  e_gw_container_get_owner(EGwContainer *container);
-const char *  e_gw_container_get_modified(EGwContainer *container);
+char *  e_gw_container_get_owner(EGwContainer *container);
+char *  e_gw_container_get_modified(EGwContainer *container);
 int           e_gw_container_get_sequence(EGwContainer *container);
 gboolean      e_gw_container_get_is_shared_by_me(EGwContainer *container);
 gboolean      e_gw_container_get_is_shared_to_me(EGwContainer *container);
Index: e-gw-container.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-container.c,v
retrieving revision 1.14
diff -u -p -r1.14 e-gw-container.c
--- e-gw-container.c	17 Mar 2005 05:12:32 -0000	1.14
+++ e-gw-container.c	22 Apr 2005 07:26:03 -0000
@@ -37,7 +37,7 @@ struct _EGwContainerPrivate {
 	int sequence;
 	char *owner;	
 	GList *user_list;	
-	const char *modified;
+	char *modified;
 	EGwContainerType type ;
 	gboolean is_root ;
 	gboolean is_writable;
@@ -50,15 +50,36 @@ struct _EGwContainerPrivate {
 static GObjectClass *parent_class = NULL;
 
 static void e_gw_container_set_sequence (EGwContainer *container, int sequence);
-static void e_gw_container_set_modified (EGwContainer *container, const char *modified);
-static void e_gw_container_set_owner(EGwContainer *container, const char *owner);
+static void e_gw_container_set_modified (EGwContainer *container, char *modified);
+static void e_gw_container_set_owner(EGwContainer *container, char *owner);
 static void e_gw_container_set_is_shared_by_me (EGwContainer *container, gboolean is_shared_by_me);
 static void e_gw_container_set_is_shared_to_me (EGwContainer *container, gboolean is_shared_to_me);
 
 static void
+free_node(EShUsers *user)
+{
+	if(user){
+		g_free(user->email);
+		user->email = NULL;
+	}
+	return ;
+}
+
+static void
 e_gw_container_dispose (GObject *object)
 {
 	EGwContainer *container = (EGwContainer *) object;
+
+	g_return_if_fail (E_IS_GW_CONTAINER (container));
+
+	if (parent_class->dispose)
+		(* parent_class->dispose) (object);
+}
+
+static void
+e_gw_container_finalize (GObject *object)
+{
+	EGwContainer *container = (EGwContainer *) object;
 	EGwContainerPrivate *priv;
 
 	g_return_if_fail (E_IS_GW_CONTAINER (container));
@@ -74,26 +95,32 @@ e_gw_container_dispose (GObject *object)
 			g_free (priv->id);
 			priv->id = NULL;
 		}
-	}
 
-	if (parent_class->dispose)
-		(* parent_class->dispose) (object);
-}
+		if (priv->parent) {
+			g_free (priv->parent);
+			priv->parent = NULL;
+		}
 
-static void
-e_gw_container_finalize (GObject *object)
-{
-	EGwContainer *container = (EGwContainer *) object;
-	EGwContainerPrivate *priv;
+		if (priv->owner) {
+			g_free (priv->owner);
+			priv->owner = NULL;
+		}
 
-	g_return_if_fail (E_IS_GW_CONTAINER (container));
+		if (priv->modified) {
+			g_free (priv->modified);
+			priv->modified = NULL;
+		}
+
+		if(priv->user_list) {
+			g_list_foreach (priv->user_list,(GFunc) free_node, NULL);
+			g_list_free (priv->user_list);
+			priv->user_list = NULL;
+		}
 
-	priv = container->priv;
-	if (priv) {
 		g_free (priv);
 		container->priv = NULL;
 	}
-
+	
 	if (parent_class->finalize)
 		(* parent_class->finalize) (object);
 }
@@ -399,16 +426,16 @@ e_gw_container_set_sequence (EGwContaine
 	container->priv->sequence = sequence;
 }
 
-const char *
+char *
 e_gw_container_get_modified (EGwContainer *container)
 {
 	g_return_val_if_fail (E_IS_GW_CONTAINER (container), NULL);
 
-	return (const char *) container->priv->modified;
+	return (char *) container->priv->modified;
 }
 
 static void
-e_gw_container_set_modified (EGwContainer *container, const char *modified)
+e_gw_container_set_modified (EGwContainer *container, char *modified)
 {
 	EGwContainerPrivate *priv;
 
@@ -423,7 +450,7 @@ e_gw_container_set_modified (EGwContaine
 }
 
 static void 
-e_gw_container_set_owner(EGwContainer *container, const char *owner)
+e_gw_container_set_owner(EGwContainer *container, char *owner)
 {
 	EGwContainerPrivate *priv;
 	
@@ -436,12 +463,12 @@ e_gw_container_set_owner(EGwContainer *c
 	container->priv->owner = g_strdup (owner);
 }
 
-const char *
+char *
 e_gw_container_get_owner (EGwContainer *container)
 {
 	g_return_val_if_fail (E_GW_CONTAINER (container), NULL);
 	
-	return (const char *) container->priv->owner;
+	return (char *) container->priv->owner;
 }
 
 int


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