pidgin: 385542a8: I don't see any reason to copy then free...

markdoliner at pidgin.im markdoliner at pidgin.im
Mon Mar 7 01:45:42 EST 2011


----------------------------------------------------------------------
Revision: 385542a8270ac30d2121b533494264a28cd04423
Parent:   6118d1117f31a7fc8db4bd5431af400a7b46ff17
Author:   markdoliner at pidgin.im
Date:     03/07/11 01:42:57
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/385542a8270ac30d2121b533494264a28cd04423

Changelog: 

I don't see any reason to copy then free this variable.  Also let's call
it username to be consistent with the rest of our code

Changes against parent 6118d1117f31a7fc8db4bd5431af400a7b46ff17

  patched  libpurple/protocols/jabber/jabber.c

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jabber.c	ad50987594a75a4e32625b8192cb0ab9412e310a
+++ libpurple/protocols/jabber/jabber.c	fa87ad671cebe79ae7b403e233e9cf75d9dc2530
@@ -924,25 +924,24 @@ jabber_stream_new(PurpleAccount *account
 	PurpleConnection *gc = purple_account_get_connection(account);
 	JabberStream *js;
 	PurplePresence *presence;
-	gchar *user;
+	const gchar *username;
 	gchar *slash;
 
 	js = gc->proto_data = g_new0(JabberStream, 1);
 	js->gc = gc;
 	js->fd = -1;
 
-	user = g_strdup(purple_account_get_username(account));
+	username = purple_account_get_username(account);
 	/* jabber_id_new doesn't accept "user at domain/" as valid */
-	slash = strchr(user, '/');
+	slash = strchr(username, '/');
 	if (slash && *(slash + 1) == '\0')
 		*slash = '\0';
-	js->user = jabber_id_new(user);
+	js->user = jabber_id_new(username);
 
 	if (!js->user) {
 		purple_connection_error_reason(gc,
 			PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
 			_("Invalid XMPP ID"));
-		g_free(user);
 		/* Destroying the connection will free the JabberStream */
 		return NULL;
 	}
@@ -951,7 +950,6 @@ jabber_stream_new(PurpleAccount *account
 		purple_connection_error_reason(gc,
 			PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
 			_("Invalid XMPP ID. Username portion must be set."));
-		g_free(user);
 		/* Destroying the connection will free the JabberStream */
 		return NULL;
 	}
@@ -960,7 +958,6 @@ jabber_stream_new(PurpleAccount *account
 		purple_connection_error_reason(gc,
 			PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
 			_("Invalid XMPP ID. Domain must be set."));
-		g_free(user);
 		/* Destroying the connection will free the JabberStream */
 		return NULL;
 	}
@@ -971,10 +968,9 @@ jabber_stream_new(PurpleAccount *account
 	/* This is overridden during binding, but we need it here
 	 * in case the server only does legacy non-sasl auth!.
 	 */
-	purple_connection_set_display_name(gc, user);
+	purple_connection_set_display_name(gc, username);
 
-	js->user_jb = jabber_buddy_find(js, user, TRUE);
-	g_free(user);
+	js->user_jb = jabber_buddy_find(js, username, TRUE);
 	if (!js->user_jb) {
 		/* This basically *can't* fail, but for good measure... */
 		purple_connection_error_reason(gc,


More information about the Commits mailing list