changeset 20991:c8f99cb61dc9

Cleanup some unnecessary NULL checks in g_strdup()/g_free().
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 19 Oct 2007 01:38:35 +0000
parents bc731b26335c
children 758d10b409a5
files libpurple/protocols/msn/contact.c libpurple/protocols/msn/group.c libpurple/protocols/msn/msg.c libpurple/protocols/msn/nexus.c libpurple/protocols/msn/object.c libpurple/protocols/msn/page.c libpurple/protocols/msn/switchboard.c libpurple/protocols/msn/user.c
diffstat 8 files changed, 35 insertions(+), 95 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/contact.c	Fri Oct 19 01:28:55 2007 +0000
+++ b/libpurple/protocols/msn/contact.c	Fri Oct 19 01:38:35 2007 +0000
@@ -92,71 +92,46 @@
 void
 msn_callback_state_set_who(MsnCallbackState *state, const gchar *who)
 {
-	gchar *new_str = NULL;
-
 	g_return_if_fail(state != NULL);
 
-	if (who != NULL)
-		new_str = g_strdup(who);
-
 	g_free(state->who);
-	state->who = new_str;
+	state->who = g_strdup(who);
 }
 
 void
 msn_callback_state_set_uid(MsnCallbackState *state, const gchar *uid)
 {
-	gchar *new_str = NULL;
-
 	g_return_if_fail(state != NULL);
 
-	if (uid != NULL)
-		new_str = g_strdup(uid);
-
 	g_free(state->uid);
-	state->uid = new_str;
+	state->uid = g_strdup(uid);
 }
 
 void
 msn_callback_state_set_old_group_name(MsnCallbackState *state, const gchar *old_group_name)
 {
-	gchar *new_str = NULL;
-
 	g_return_if_fail(state != NULL);
 
-	if (old_group_name != NULL)
-		new_str = g_strdup(old_group_name);
-
 	g_free(state->old_group_name);
-	state->old_group_name = new_str;
+	state->old_group_name = g_strdup(old_group_name);
 }
 
 void
 msn_callback_state_set_new_group_name(MsnCallbackState *state, const gchar *new_group_name)
 {
-	gchar *new_str = NULL;
-
 	g_return_if_fail(state != NULL);
 
-	if (new_group_name != NULL)
-		new_str = g_strdup(new_group_name);
-
 	g_free(state->new_group_name);
-	state->new_group_name = new_str;
+	state->new_group_name = g_strdup(new_group_name);
 }
 
 void
 msn_callback_state_set_guid(MsnCallbackState *state, const gchar *guid)
 {
-	gchar *new_str = NULL;
-
 	g_return_if_fail(state != NULL);
 
-	if (guid != NULL)
-		new_str = g_strdup(guid);
-
 	g_free(state->guid);
-	state->guid = new_str;
+	state->guid = g_strdup(guid);
 }
 
 
--- a/libpurple/protocols/msn/group.c	Fri Oct 19 01:28:55 2007 +0000
+++ b/libpurple/protocols/msn/group.c	Fri Oct 19 01:38:35 2007 +0000
@@ -58,6 +58,7 @@
 	g_return_if_fail(group != NULL);
 	g_return_if_fail(id != NULL);
 
+	g_free(group->id);
 	group->id = g_strdup(id);
 }
 
@@ -67,9 +68,7 @@
 	g_return_if_fail(group != NULL);
 	g_return_if_fail(name  != NULL);
 
-	if (group->name != NULL)
-		g_free(group->name);
-
+	g_free(group->name);
 	group->name = g_strdup(name);
 }
 
--- a/libpurple/protocols/msn/msg.c	Fri Oct 19 01:28:55 2007 +0000
+++ b/libpurple/protocols/msn/msg.c	Fri Oct 19 01:38:35 2007 +0000
@@ -60,17 +60,10 @@
 	purple_debug_info("msn", "message destroy (%p)\n", msg);
 #endif
 
-	if (msg->remote_user != NULL)
-		g_free(msg->remote_user);
-
-	if (msg->body != NULL)
-		g_free(msg->body);
-
-	if (msg->content_type != NULL)
-		g_free(msg->content_type);
-
-	if (msg->charset != NULL)
-		g_free(msg->charset);
+	g_free(msg->remote_user);
+	g_free(msg->body);
+	g_free(msg->content_type);
+	g_free(msg->charset);
 
 	g_hash_table_destroy(msg->attr_table);
 	g_list_free(msg->attr_list);
@@ -556,10 +549,8 @@
 {
 	g_return_if_fail(msg != NULL);
 
-	if (msg->content_type != NULL)
-		g_free(msg->content_type);
-
-	msg->content_type = (type != NULL) ? g_strdup(type) : NULL;
+	g_free(msg->content_type);
+	msg->content_type = g_strdup(type);
 }
 
 const char *
@@ -575,10 +566,8 @@
 {
 	g_return_if_fail(msg != NULL);
 
-	if (msg->charset != NULL)
-		g_free(msg->charset);
-
-	msg->charset = (charset != NULL) ? g_strdup(charset) : NULL;
+	g_free(msg->charset);
+	msg->charset = g_strdup(charset);
 }
 
 const char *
--- a/libpurple/protocols/msn/nexus.c	Fri Oct 19 01:28:55 2007 +0000
+++ b/libpurple/protocols/msn/nexus.c	Fri Oct 19 01:38:35 2007 +0000
@@ -190,13 +190,10 @@
 	msn_twn_p = (char *)g_hash_table_lookup(nexus->challenge_data, "p");
 
 	/*setup the t and p parameter for session*/
-	if (session->passport_info.t != NULL){
-			g_free(session->passport_info.t);
-	}
+	g_free(session->passport_info.t);
 	session->passport_info.t = g_strdup(msn_twn_t);
 
-	if (session->passport_info.p != NULL)
-			g_free(session->passport_info.p);
+	g_free(session->passport_info.p);
 	session->passport_info.p = g_strdup(msn_twn_p);
 
 	cert_str = g_strdup_printf("t=%s&p=%s",msn_twn_t,msn_twn_p);
--- a/libpurple/protocols/msn/object.c	Fri Oct 19 01:28:55 2007 +0000
+++ b/libpurple/protocols/msn/object.c	Fri Oct 19 01:38:35 2007 +0000
@@ -154,10 +154,8 @@
 {
 	g_return_if_fail(obj != NULL);
 
-	if (obj->creator != NULL)
-		g_free(obj->creator);
-
-	obj->creator = (creator == NULL ? NULL : g_strdup(creator));
+	g_free(obj->creator);
+	obj->creator = g_strdup(creator);
 }
 
 void
@@ -181,10 +179,8 @@
 {
 	g_return_if_fail(obj != NULL);
 
-	if (obj->location != NULL)
-		g_free(obj->location);
-
-	obj->location = (location == NULL ? NULL : g_strdup(location));
+	g_free(obj->location);
+	obj->location = g_strdup(location);
 }
 
 void
@@ -192,10 +188,8 @@
 {
 	g_return_if_fail(obj != NULL);
 
-	if (obj->friendly != NULL)
-		g_free(obj->friendly);
-
-	obj->friendly = (friendly == NULL ? NULL : g_strdup(friendly));
+	g_free(obj->friendly);
+	obj->friendly = g_strdup(friendly);
 }
 
 void
@@ -203,10 +197,8 @@
 {
 	g_return_if_fail(obj != NULL);
 
-	if (obj->sha1d != NULL)
-		g_free(obj->sha1d);
-
-	obj->sha1d = (sha1d == NULL ? NULL : g_strdup(sha1d));
+	g_free(obj->sha1d);
+	obj->sha1d = g_strdup(sha1d);
 }
 
 void
@@ -214,10 +206,8 @@
 {
 	g_return_if_fail(obj != NULL);
 
-	if (obj->sha1c != NULL)
-		g_free(obj->sha1c);
-
-	obj->sha1c = (sha1c == NULL ? NULL : g_strdup(sha1c));
+	g_free(obj->sha1c);
+	obj->sha1c = g_strdup(sha1c);
 }
 
 const char *
--- a/libpurple/protocols/msn/page.c	Fri Oct 19 01:28:55 2007 +0000
+++ b/libpurple/protocols/msn/page.c	Fri Oct 19 01:38:35 2007 +0000
@@ -74,9 +74,7 @@
 	g_return_if_fail(page != NULL);
 	g_return_if_fail(body != NULL);
 
-	if (page->body != NULL)
-		g_free(page->body);
-
+	g_free(page->body);
 	page->body = g_strdup(body);
 }
 
--- a/libpurple/protocols/msn/switchboard.c	Fri Oct 19 01:28:55 2007 +0000
+++ b/libpurple/protocols/msn/switchboard.c	Fri Oct 19 01:38:35 2007 +0000
@@ -152,9 +152,7 @@
 	g_return_if_fail(swboard != NULL);
 	g_return_if_fail(id != NULL);
 
-	if (swboard->session_id != NULL)
-		g_free(swboard->session_id);
-
+	g_free(swboard->session_id);
 	swboard->session_id = g_strdup(id);
 }
 
--- a/libpurple/protocols/msn/user.c	Fri Oct 19 01:28:55 2007 +0000
+++ b/libpurple/protocols/msn/user.c	Fri Oct 19 01:38:35 2007 +0000
@@ -391,10 +391,8 @@
 {
 	g_return_if_fail(user != NULL);
 
-	if (user->phone.home != NULL)
-		g_free(user->phone.home);
-
-	user->phone.home = (number == NULL ? NULL : g_strdup(number));
+	g_free(user->phone.home);
+	user->phone.home = g_strdup(number);
 }
 
 void
@@ -402,10 +400,8 @@
 {
 	g_return_if_fail(user != NULL);
 
-	if (user->phone.work != NULL)
-		g_free(user->phone.work);
-
-	user->phone.work = (number == NULL ? NULL : g_strdup(number));
+	g_free(user->phone.work);
+	user->phone.work = g_strdup(number);
 }
 
 void
@@ -413,10 +409,8 @@
 {
 	g_return_if_fail(user != NULL);
 
-	if (user->phone.mobile != NULL)
-		g_free(user->phone.mobile);
-
-	user->phone.mobile = (number == NULL ? NULL : g_strdup(number));
+	g_free(user->phone.mobile);
+	user->phone.mobile = g_strdup(number);
 }
 
 void