[evolution-patches] Address book: memory leak fixes



Hi,

Attached patch fixes memory leaks in address book cache handling.

Please review.

Thanks,
Sushma.

Index: addressbook/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/ChangeLog,v
retrieving revision 1.264
diff -u -p -r1.264 ChangeLog
--- addressbook/ChangeLog	27 Apr 2005 10:19:40 -0000	1.264
+++ addressbook/ChangeLog	2 May 2005 10:27:49 -0000
@@ -1,3 +1,11 @@
+2005-05-02  Sushma Rai  <rsushma novell com>
+
+	* libedata-book/e-book-backend-cache.c 
+	(e_book_backend_cache_get_contacts): Freeing list of cache objects and
+	sexp.
+	(e_book_backend_cache_search): Freeing list of contacts matching the 
+	query.
+
 2005-04-27  Sushma Rai  <rsushma novell com>
 
 	* libebook/e-book.c (e_book_response_add_contact): Setting the status
Index: addressbook/libedata-book/e-book-backend-cache.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libedata-book/e-book-backend-cache.c,v
retrieving revision 1.3
diff -u -p -r1.3 e-book-backend-cache.c
--- addressbook/libedata-book/e-book-backend-cache.c	10 Jan 2005 11:52:03 -0000	1.3
+++ addressbook/libedata-book/e-book-backend-cache.c	2 May 2005 10:28:10 -0000
@@ -332,6 +332,7 @@ e_book_backend_cache_get_contacts (EBook
 	EContact *contact;
         EBookBackendSExp *sexp = NULL;
 	const char *uid;
+
 	g_return_val_if_fail (E_IS_BOOK_BACKEND_CACHE (cache), NULL);
 	if (query) {
 		sexp = e_book_backend_sexp_new (query);
@@ -341,8 +342,7 @@ e_book_backend_cache_get_contacts (EBook
        
 
         l = e_file_cache_get_objects (E_FILE_CACHE (cache));
-        if (!l)
-                return NULL;
+
         for ( ; l != NULL; l = g_slist_next (l)) {
                 vcard_str = l->data;
                 if (vcard_str && !strncmp (vcard_str, "BEGIN:VCARD", 11)) {
@@ -353,6 +353,10 @@ e_book_backend_cache_get_contacts (EBook
                 }
                 
         }
+	if (l)
+		g_slist_free (l);
+	if (sexp)
+		g_object_unref (sexp);
 
         return list;
 }
@@ -367,12 +371,13 @@ e_book_backend_cache_search (EBookBacken
 	ptr_array = g_ptr_array_new ();
 	
 	temp = matching_contacts;
-	for (; matching_contacts != NULL; matching_contacts = g_list_next (matching_contacts))
+	for (; matching_contacts != NULL; matching_contacts = g_list_next (matching_contacts)) {
 		g_ptr_array_add (ptr_array, e_contact_get (matching_contacts->data, E_CONTACT_UID));
-		
-	return ptr_array;
+		g_object_unref (matching_contacts->data);
+	}
+	g_list_free (temp);
 	
-
+	return ptr_array;
 }
 
 gboolean 


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