cpw.darkrain42.xmpp.bosh: 601bc627: Use purple_strequal and g_str_equal

paul at darkrain42.org paul at darkrain42.org
Sat Apr 25 16:16:48 EDT 2009


-----------------------------------------------------------------
Revision: 601bc627c9430320848361f0ed81c6c4c6ee53e0
Ancestor: 6a5fd0176673b16978f3d46d80fba057a5ba77a8
Author: paul at darkrain42.org
Date: 2009-04-18T18:17:16
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/601bc627c9430320848361f0ed81c6c4c6ee53e0

Modified files:
        libpurple/protocols/jabber/caps.c

ChangeLog: 

Use purple_strequal and g_str_equal

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/caps.c	c609d353cad94313609a9b2ab7dc36943f08489d
+++ libpurple/protocols/jabber/caps.c	313a4bc913bbaf49f3b806a2bf779195315868a8
@@ -89,9 +89,11 @@ static guint jabber_caps_hash(gconstpoin
 	const JabberCapsKey *key = data;
 	guint nodehash = g_str_hash(key->node);
 	guint verhash  = g_str_hash(key->ver);
-	/* 'hash' was optional in XEP-0115 v1.4 and I think g_str_hash crashes on
-	 * NULL >:O. Okay, maybe I've played too much Zelda, but that looks like
-	 * a Deku Shrub... */
+	/*
+	 * 'hash' was optional in XEP-0115 v1.4 and g_str_hash crashes on NULL >:O.
+	 * Okay, maybe I've played too much Zelda, but that looks like
+	 * a Deku Shrub...
+	 */
 	guint hashhash = (key->hash ? g_str_hash(key->hash) : 0);
 	return nodehash ^ verhash ^ hashhash;
 }
@@ -99,13 +101,10 @@ static gboolean jabber_caps_compare(gcon
 static gboolean jabber_caps_compare(gconstpointer v1, gconstpointer v2) {
 	const JabberCapsKey *name1 = v1;
 	const JabberCapsKey *name2 = v2;
-	/* Again, hash might be NULL and I *know* strcmp will crash on NULL. */
-	gboolean hasheq = ((!name1->hash && !name2->hash) ||
-	        (name1->hash && name2->hash && !strcmp(name1->hash, name2->hash)));
 
-	return strcmp(name1->node, name2->node) == 0 &&
-	       strcmp(name1->ver, name2->ver) == 0 &&
-	       hasheq;
+	return g_str_equal(name1->node, name2->node) &&
+	       g_str_equal(name1->ver, name2->ver) &&
+	       purple_strequal(name1->hash, name2->hash);
 }
 
 void jabber_caps_destroy_key(gpointer data) {


More information about the Commits mailing list