diff src/gtkconv.c @ 14035:8bda65b88e49

[gaim-migrate @ 16638] A bunch of small changes. Mostly remove "if not null" checks before calling g_free, g_list_free, g_slist_free and g_strdup. Also use g_list_foreach() to call g_free to free strings in an array. And some whitespace changes here and there. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 05 Aug 2006 08:27:39 +0000
parents d856c2ec93ca
children 7f276f375789
line wrap: on
line diff
--- a/src/gtkconv.c	Sat Aug 05 05:42:28 2006 +0000
+++ b/src/gtkconv.c	Sat Aug 05 08:27:39 2006 +0000
@@ -193,15 +193,9 @@
 static gint
 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv)
 {
-	GList *list = g_list_copy(gtkconv->convs), *l;
-
-	l = list;
-	while (l) {
-		GaimConversation *conv = l->data;
-		gaim_conversation_destroy(conv);
-		l = l->next;
-	}
-
+	GList *list = g_list_copy(gtkconv->convs);
+
+	g_list_foreach(list, (GFunc)gaim_conversation_destroy, NULL);
 	g_list_free(list);
 
 	return TRUE;
@@ -489,8 +483,7 @@
 			case GAIM_CMD_STATUS_FAILED:
 				gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."),
 						GAIM_MESSAGE_NO_LOG, time(NULL));
-				if(error)
-					g_free(error);
+				g_free(error);
 				return TRUE;
 			case GAIM_CMD_STATUS_WRONG_TYPE:
 				if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM)
@@ -771,8 +764,8 @@
 			}
 		}
 
-		if (username != NULL) g_free(username);
-		if (protocol != NULL) g_free(protocol);
+		g_free(username);
+		g_free(protocol);
 
 		gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
 	}
@@ -1426,7 +1419,7 @@
 		gaim_conv_chat_ignore(chat, name);
 
 	cbuddy = gaim_conv_chat_cb_new(name, alias, flags);
-	
+
 	add_chat_buddy_common(conv, cbuddy, NULL);
 	g_free(name);
 	g_free(alias);
@@ -1525,7 +1518,7 @@
 
 	who = g_object_get_data(G_OBJECT(w), "user_data");
 	mark = get_mark_for_user(gtkconv, who);
-	
+
 	if (mark != NULL)
 		gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0);
 	else
@@ -3214,8 +3207,7 @@
 	GaimBlistNode *gnode,*cnode,*bnode;
 	static GList *tmp = NULL;
 
-	if (tmp)
-		g_list_free(tmp);
+	g_list_free(tmp);
 
 	tmp = g_list_append(NULL, "");
 
@@ -4261,8 +4253,8 @@
 			}
 		}
 
-		if (username != NULL) g_free(username);
-		if (protocol != NULL) g_free(protocol);
+		g_free(username);
+		g_free(protocol);
 
 		gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t);
 	}
@@ -4868,8 +4860,7 @@
 			}
 		}
 
-		if(alias_escaped)
-			g_free(alias_escaped);
+		g_free(alias_escaped);
 
 		/* Are we in a chat where we can tell which users are buddies? */
 		if  (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) &&
@@ -5070,7 +5061,7 @@
 	g_return_if_fail(new_alias != NULL);
 
 	cbuddy = gaim_conv_chat_cb_new(new_name, new_alias, flags);
-	
+
 	add_chat_buddy_common(conv, cbuddy, old_name);
 }
 
@@ -5177,7 +5168,7 @@
 	flags = gaim_conv_chat_user_get_flags(chat, user);
 
 	cbuddy = gaim_conv_chat_cb_new(user, alias, flags);
-	
+
 	add_chat_buddy_common(conv, cbuddy, NULL);
 	g_free(alias);
 }