diff options
author | mjentsch <mtthsjntsch@gmail.com> | 2015-10-31 11:50:40 +0300 |
---|---|---|
committer | mjentsch <mtthsjntsch@gmail.com> | 2015-10-31 22:09:31 +0300 |
commit | 81b64d7542298bd4b11f11052ea14ec175687100 (patch) | |
tree | 27d0654cbbb027ad1e5ffb534192152762b8f974 /tgp-blist.c | |
parent | 87278f67422e64c4078947bd90188733493c8a84 (diff) |
Fix "crashes" on name changes
Do not assume that a name for each ID can only be set once anymore.
Remove assertion that names always exist, return 0 instead and propagate
error handling to the calling function.
Diffstat (limited to 'tgp-blist.c')
-rw-r--r-- | tgp-blist.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/tgp-blist.c b/tgp-blist.c index 02acf0d..a8e049a 100644 --- a/tgp-blist.c +++ b/tgp-blist.c @@ -27,16 +27,14 @@ const char *tgp_blist_peer_get_purple_name (struct tgl_state *TLS, tgl_peer_id_t id) { const char *name = g_hash_table_lookup (tg_get_data (TLS)->id_to_purple_name, GINT_TO_POINTER(tgl_get_peer_id (id))); if (! name) { - assert (0); + g_warn_if_reached(); return NULL; } return name; } void tgp_blist_peer_add_purple_name (struct tgl_state *TLS, tgl_peer_id_t id, const char *purple_name) { - assert (g_hash_table_lookup (tg_get_data (TLS)->id_to_purple_name, GINT_TO_POINTER(tgl_get_peer_id (id))) == NULL); - g_hash_table_insert (tg_get_data (TLS)->id_to_purple_name, GINT_TO_POINTER(tgl_get_peer_id (id)), - g_strdup (purple_name)); + g_hash_table_replace (tg_get_data (TLS)->id_to_purple_name, GINT_TO_POINTER(tgl_get_peer_id (id)), g_strdup (purple_name)); } tgl_peer_t *tgp_blist_peer_find (struct tgl_state *TLS, const char *purple_name) { |