im.pidgin.pidgin: 1d1807f89ba6b7779bdc61d5ae8910a68883fe3c

datallah at pidgin.im datallah at pidgin.im
Thu Oct 18 21:45:38 EDT 2007


-----------------------------------------------------------------
Revision: 1d1807f89ba6b7779bdc61d5ae8910a68883fe3c
Ancestor: 5b7828dc1104f008a8d07ab8374a7f3501f4c104
Author: datallah at pidgin.im
Date: 2007-10-19T01:38:35
Branch: im.pidgin.pidgin

Modified 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

ChangeLog: 

Cleanup some unnecessary NULL checks in g_strdup()/g_free().

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/contact.c	bc31e45a4a1876962789396c86e8720da33704fc
+++ libpurple/protocols/msn/contact.c	4f595cf9412dd6d120d2ddabe2d9c58ce0d79721
@@ -92,71 +92,46 @@ msn_callback_state_set_who(MsnCallbackSt
 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);
 }
 
 
============================================================
--- libpurple/protocols/msn/group.c	7eb03c38b8dfce560a2bd259a56c4231068f665c
+++ libpurple/protocols/msn/group.c	e2b2f4ed3c8f13fd0643deab78579994610e4d03
@@ -58,6 +58,7 @@ msn_group_set_id(MsnGroup *group, const 
 	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 @@ msn_group_set_name(MsnGroup *group, cons
 	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);
 }
 
============================================================
--- libpurple/protocols/msn/msg.c	550615fd5684bc982bf640bc153a63c104082213
+++ libpurple/protocols/msn/msg.c	91cab16e2f23c0fd8832a52d41a3c5bc4ad613dc
@@ -60,18 +60,11 @@ msn_message_destroy(MsnMessage *msg)
 	purple_debug_info("msn", "message destroy (%p)\n", msg);
 #endif
 
-	if (msg->remote_user != NULL)
-		g_free(msg->remote_user);
+	g_free(msg->remote_user);
+	g_free(msg->body);
+	g_free(msg->content_type);
+	g_free(msg->charset);
 
-	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_hash_table_destroy(msg->attr_table);
 	g_list_free(msg->attr_list);
 
@@ -556,10 +549,8 @@ msn_message_set_content_type(MsnMessage 
 {
 	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 @@ msn_message_set_charset(MsnMessage *msg,
 {
 	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 *
============================================================
--- libpurple/protocols/msn/nexus.c	4a2d80e504e329b1ee2a6970825380c97c22b262
+++ libpurple/protocols/msn/nexus.c	6a3ba3fc9d40a4982817c48e63f2ae063055502e
@@ -190,13 +190,10 @@ nexus_login_read_cb(MsnSoapConn *soapcon
 	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);
============================================================
--- libpurple/protocols/msn/object.c	38449587c1dcf0341a9781cab58011c3221914d9
+++ libpurple/protocols/msn/object.c	06186238c88f043e2f3f2079f79677ce6533ad10
@@ -154,10 +154,8 @@ msn_object_set_creator(MsnObject *obj, c
 {
 	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 @@ msn_object_set_location(MsnObject *obj, 
 {
 	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 @@ msn_object_set_friendly(MsnObject *obj, 
 {
 	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 @@ msn_object_set_sha1d(MsnObject *obj, con
 {
 	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 @@ msn_object_set_sha1c(MsnObject *obj, con
 {
 	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 *
============================================================
--- libpurple/protocols/msn/page.c	74dfbb4800b451c0627a953fe23526e39f47fc30
+++ libpurple/protocols/msn/page.c	cc244355a3c715228e6c8974481591a55960ec81
@@ -74,9 +74,7 @@ msn_page_set_body(MsnPage *page, const c
 	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);
 }
 
============================================================
--- libpurple/protocols/msn/switchboard.c	91a914d5b9777ae516f73208a90fbe33a0751638
+++ libpurple/protocols/msn/switchboard.c	445ad20b38f8d022331249a0f3939530b91183e3
@@ -152,9 +152,7 @@ msn_switchboard_set_session_id(MsnSwitch
 	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);
 }
 
============================================================
--- libpurple/protocols/msn/user.c	e60aa8f4487d61998df6a15818cb9b5fd708cebe
+++ libpurple/protocols/msn/user.c	c4eb039e8077a4d9248a8992861d7bd4795aa561
@@ -391,10 +391,8 @@ msn_user_set_home_phone(MsnUser *user, c
 {
 	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 @@ msn_user_set_work_phone(MsnUser *user, c
 {
 	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 @@ msn_user_set_mobile_phone(MsnUser *user,
 {
 	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


More information about the Commits mailing list