Changeset 9e83b15
- Timestamp:
- 2018-07-03T05:58:47Z (6 years ago)
- Branches:
- master
- Children:
- c17d0af
- Parents:
- 49ab3cb
- git-author:
- dequis <dx@…> (03-07-18 05:27:59)
- git-committer:
- dequis <dx@…> (03-07-18 05:58:47)
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/misc.c
r49ab3cb r9e83b15 774 774 } 775 775 } 776 777 /* copied from irssi's misc.c, by timo sirainen */ 778 int b_istr_equal(gconstpointer v, gconstpointer v2) 779 { 780 return g_ascii_strcasecmp((const char *) v, (const char *) v2) == 0; 781 } 782 783 /* copied from irssi's misc.c, by lemonboy */ 784 guint b_istr_hash(gconstpointer v) 785 { 786 const signed char *p; 787 guint32 h = 5381; 788 789 for (p = v; *p != '\0'; p++) { 790 h = (h << 5) + h + g_ascii_toupper(*p); 791 } 792 793 return h; 794 } -
lib/misc.h
r49ab3cb r9e83b15 151 151 G_MODULE_EXPORT char *str_pad_and_truncate(const char *string, long char_len, const char *ellipsis); 152 152 153 G_MODULE_EXPORT int b_istr_equal(gconstpointer v, gconstpointer v2); 154 G_MODULE_EXPORT guint b_istr_hash(gconstpointer v); 155 153 156 #endif -
protocols/bee_user.c
r49ab3cb r9e83b15 42 42 bee->users = g_slist_prepend(bee->users, bu); 43 43 44 if (ic->bee_users) { 45 g_hash_table_insert(ic->bee_users, bu->handle, bu); 46 } 44 47 if (bee->ui->user_new) { 45 48 bee->ui->user_new(bee, bu); … … 67 70 bu->ic->acc->prpl->buddy_data_free(bu); 68 71 } 69 72 if (bu->ic->bee_users) { 73 g_hash_table_remove(bu->ic->bee_users, bu->handle); 74 } 70 75 bee->users = g_slist_remove(bee->users, bu); 71 76 … … 80 85 } 81 86 82 bee_user_t *bee_user_by_handle (bee_t *bee, struct im_connection *ic, const char *handle)87 bee_user_t *bee_user_by_handle_slow(bee_t *bee, struct im_connection *ic, const char *handle) 83 88 { 84 89 GSList *l; … … 93 98 94 99 return NULL; 100 } 101 102 bee_user_t *bee_user_by_handle(bee_t *bee, struct im_connection *ic, const char *handle) 103 { 104 if (!ic->bee_users) { 105 return bee_user_by_handle_slow(bee, ic, handle); 106 } 107 108 return g_hash_table_lookup(ic->bee_users, handle); 95 109 } 96 110 -
protocols/nogaim.c
r49ab3cb r9e83b15 298 298 { 299 299 struct im_connection *ic; 300 GHashFunc fn_hash = NULL; 301 GEqualFunc fn_equal = NULL; 300 302 301 303 ic = g_new0(struct im_connection, 1); … … 304 306 ic->acc = acc; 305 307 acc->ic = ic; 308 309 /* figure out if we have hashing functions compatible with handle_cmp */ 310 if (acc->prpl->handle_cmp == g_ascii_strcasecmp) { 311 fn_hash = b_istr_hash; 312 fn_equal = b_istr_equal; 313 } else if (acc->prpl->handle_cmp == g_strcmp0 || acc->prpl->handle_cmp == strcmp) { 314 fn_hash = g_str_hash; 315 fn_equal = g_str_equal; 316 } 317 318 /* only create the hash table if we found them */ 319 if (fn_hash && fn_equal) { 320 ic->bee_users = g_hash_table_new_full(fn_hash, fn_equal, NULL, NULL); 321 } 306 322 307 323 connections = g_slist_append(connections, ic); … … 320 336 break; 321 337 } 338 } 339 340 if (ic->bee_users) { 341 g_hash_table_destroy(ic->bee_users); 322 342 } 323 343 -
protocols/nogaim.h
r49ab3cb r9e83b15 97 97 GSList *groupchats; 98 98 GSList *chatlist; 99 GHashTable *bee_users; 99 100 }; 100 101
Note: See TracChangeset
for help on using the changeset viewer.