Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/caps.c @ 26743:de9816c970fe
Use purple_strequal and g_str_equal
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 18 Apr 2009 18:17:16 +0000 |
parents | 061df5754d20 |
children | b1f8cebaab17 |
comparison
equal
deleted
inserted
replaced
26742:ff30995af0da | 26743:de9816c970fe |
---|---|
87 | 87 |
88 static guint jabber_caps_hash(gconstpointer data) { | 88 static guint jabber_caps_hash(gconstpointer data) { |
89 const JabberCapsKey *key = data; | 89 const JabberCapsKey *key = data; |
90 guint nodehash = g_str_hash(key->node); | 90 guint nodehash = g_str_hash(key->node); |
91 guint verhash = g_str_hash(key->ver); | 91 guint verhash = g_str_hash(key->ver); |
92 /* 'hash' was optional in XEP-0115 v1.4 and I think g_str_hash crashes on | 92 /* |
93 * NULL >:O. Okay, maybe I've played too much Zelda, but that looks like | 93 * 'hash' was optional in XEP-0115 v1.4 and g_str_hash crashes on NULL >:O. |
94 * a Deku Shrub... */ | 94 * Okay, maybe I've played too much Zelda, but that looks like |
95 * a Deku Shrub... | |
96 */ | |
95 guint hashhash = (key->hash ? g_str_hash(key->hash) : 0); | 97 guint hashhash = (key->hash ? g_str_hash(key->hash) : 0); |
96 return nodehash ^ verhash ^ hashhash; | 98 return nodehash ^ verhash ^ hashhash; |
97 } | 99 } |
98 | 100 |
99 static gboolean jabber_caps_compare(gconstpointer v1, gconstpointer v2) { | 101 static gboolean jabber_caps_compare(gconstpointer v1, gconstpointer v2) { |
100 const JabberCapsKey *name1 = v1; | 102 const JabberCapsKey *name1 = v1; |
101 const JabberCapsKey *name2 = v2; | 103 const JabberCapsKey *name2 = v2; |
102 /* Again, hash might be NULL and I *know* strcmp will crash on NULL. */ | 104 |
103 gboolean hasheq = ((!name1->hash && !name2->hash) || | 105 return g_str_equal(name1->node, name2->node) && |
104 (name1->hash && name2->hash && !strcmp(name1->hash, name2->hash))); | 106 g_str_equal(name1->ver, name2->ver) && |
105 | 107 purple_strequal(name1->hash, name2->hash); |
106 return strcmp(name1->node, name2->node) == 0 && | |
107 strcmp(name1->ver, name2->ver) == 0 && | |
108 hasheq; | |
109 } | 108 } |
110 | 109 |
111 void jabber_caps_destroy_key(gpointer data) { | 110 void jabber_caps_destroy_key(gpointer data) { |
112 JabberCapsKey *key = data; | 111 JabberCapsKey *key = data; |
113 g_free(key->node); | 112 g_free(key->node); |