changeset 22318:d1bcb54920f8

Fix a leak, and correct the docs.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 25 Feb 2008 03:07:03 +0000
parents 2ab289f312d0
children d30bee8d6bdf
files libpurple/smiley.c libpurple/smiley.h pidgin/gtksmiley.c
diffstat 3 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/smiley.c	Mon Feb 25 02:43:06 2008 +0000
+++ b/libpurple/smiley.c	Mon Feb 25 03:07:03 2008 +0000
@@ -730,12 +730,9 @@
 
 static void add_smiley_to_list(gpointer key, gpointer value, gpointer user_data)
 {
-	GList** preturninglist = (GList**)user_data;
-	GList *returninglist = *preturninglist;
+	GList** returninglist = (GList**)user_data;
 
-	returninglist = g_list_append(returninglist, value);
-
-	*preturninglist = returninglist;
+	*returninglist = g_list_append(*returninglist, value);
 }
 
 GList *
--- a/libpurple/smiley.h	Mon Feb 25 02:43:06 2008 +0000
+++ b/libpurple/smiley.h	Mon Feb 25 03:07:03 2008 +0000
@@ -210,9 +210,9 @@
 /*@{*/
 
 /**
- * Returns a list of all custom smileys.
+ * Returns a list of all custom smileys. The caller should free the list.
  *
- * @constreturn A list of all custom smileys.
+ * @return A list of all custom smileys.
  */
 GList *
 purple_smileys_get_all(void);
--- a/pidgin/gtksmiley.c	Mon Feb 25 02:43:06 2008 +0000
+++ b/pidgin/gtksmiley.c	Mon Feb 25 03:07:03 2008 +0000
@@ -80,6 +80,7 @@
 	purple_debug_info("gtksmiley", "adding %s to gtk_smileys\n", gtksmiley->smile);
 }
 
+/* Perhaps this should be in gtkimhtml.c instead. -- sad */
 static GtkIMHtmlSmiley *smiley_purple_to_gtkimhtml(PurpleSmiley *smiley)
 {
 	GtkIMHtmlSmiley *gtksmiley;
@@ -141,16 +142,16 @@
 
 void pidgin_smileys_init(void)
 {
-	GList *purple_smileys;
+	GList *smileys;
 	PurpleSmiley *smiley;
 
 	if (gtk_smileys != NULL)
 		return;
 
-	purple_smileys = purple_smileys_get_all();
+	smileys = purple_smileys_get_all();
 
-	for (; purple_smileys; purple_smileys = purple_smileys->next) {
-		smiley = (PurpleSmiley*)purple_smileys->data;
+	for (; smileys; smileys = g_list_delete_link(smileys, smileys)) {
+		smiley = (PurpleSmiley*)smileys->data;
 
 		pidgin_smiley_add_to_list(smiley);
 	}
@@ -432,7 +433,8 @@
 
 	gtk_list_store_clear(dialog->model);
 
-	for(list = purple_smileys_get_all(); list != NULL; list = list->next) {
+	for(list = purple_smileys_get_all(); list != NULL;
+			list = g_list_delete_link(list, list)) {
 		emoticon = (PurpleSmiley*)list->data;
 
 		store_smiley_add(emoticon);