diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 70dde558a..4bd088c41 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -36,7 +36,6 @@ typedef union { const struct sdp_attr_helper *attr_helper; str_q *q; - GHashTable **htp; str_case_ht *sct; str_case_value_ht *svt; void **generic; @@ -615,10 +614,10 @@ static void call_ng_flags_str_pair_ht(sdp_ng_flags *out, str *s, helper_arg arg) free(s_copy); return; } - GHashTable **ht = arg.htp; - if (!*ht) - *ht = g_hash_table_new_full(str_case_hash, str_case_equal, free, free); - g_hash_table_replace(*ht, str_dup(&token), s_copy); + str_case_value_ht *ht = arg.svt; + if (!t_hash_table_is_set(*ht)) + *ht = str_case_value_ht_new(); + t_hash_table_replace(*ht, str_dup(&token), s_copy); } static void call_ng_flags_item_pair_ht(sdp_ng_flags *out, bencode_item_t *it, helper_arg arg) { @@ -640,10 +639,10 @@ static void call_ng_flags_item_pair_ht(sdp_ng_flags *out, bencode_item_t *it, he str * s_copy_from = str_dup_escape(&from); str * s_copy_to = str_dup_escape(&to); - GHashTable **ht = arg.htp; - if (!*ht) - *ht = g_hash_table_new_full(str_case_hash, str_case_equal, free, free); - g_hash_table_replace(*ht, s_copy_from, s_copy_to); + str_case_value_ht *ht = arg.svt; + if (!t_hash_table_is_set(*ht)) + *ht = str_case_value_ht_new(); + t_hash_table_replace(*ht, s_copy_from, s_copy_to); } INLINE void ng_sdp_attr_manipulations(sdp_ng_flags *flags, bencode_item_t *value) { @@ -657,7 +656,6 @@ INLINE void ng_sdp_attr_manipulations(sdp_ng_flags *flags, bencode_item_t *value { bencode_item_t *command_action = it->sibling ? it->sibling : NULL; str media_type; - GHashTable ** ht = NULL; if (!command_action) /* if no action, makes no sense to continue */ continue; @@ -688,9 +686,8 @@ INLINE void ng_sdp_attr_manipulations(sdp_ng_flags *flags, bencode_item_t *value switch (__csh_lookup(&command_type)) { case CSH_LOOKUP("substitute"): - ht = &sm->subst_commands; - - call_ng_flags_list(NULL, command_value, call_ng_flags_str_pair_ht, call_ng_flags_item_pair_ht, ht); + call_ng_flags_list(NULL, command_value, call_ng_flags_str_pair_ht, call_ng_flags_item_pair_ht, + &sm->subst_commands); break; case CSH_LOOKUP("add"): @@ -699,9 +696,7 @@ INLINE void ng_sdp_attr_manipulations(sdp_ng_flags *flags, bencode_item_t *value /* CMD_REM commands */ case CSH_LOOKUP("remove"): - ht = &sm->rem_commands; - - call_ng_flags_str_list(NULL, command_value, call_ng_flags_str_ht, ht); + call_ng_flags_str_list(NULL, command_value, call_ng_flags_str_ht, &sm->rem_commands); break; default: @@ -1857,10 +1852,8 @@ static void ng_sdp_attr_manipulations_free(struct sdp_manipulations * array[__MT if (!sdp_manipulations) continue; - if (sdp_manipulations->rem_commands) - g_hash_table_destroy(sdp_manipulations->rem_commands); - if (sdp_manipulations->subst_commands) - g_hash_table_destroy(sdp_manipulations->subst_commands); + str_case_ht_destroy_ptr(&sdp_manipulations->rem_commands); + str_case_value_ht_destroy_ptr(&sdp_manipulations->subst_commands); t_queue_clear_full(&sdp_manipulations->add_commands, str_free); g_slice_free1(sizeof(*sdp_manipulations), sdp_manipulations); diff --git a/daemon/sdp.c b/daemon/sdp.c index abd95f60b..4c46e70e6 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -328,8 +328,8 @@ static bool sdp_manipulate_remove(struct sdp_manipulations * sdp_manipulations, if (!attr_name || !attr_name->len) return false; - GHashTable * ht = sdp_manipulations->rem_commands; - if (ht && g_hash_table_lookup(ht, attr_name)) + str_case_ht ht = sdp_manipulations->rem_commands; + if (t_hash_table_is_set(ht) && t_hash_table_lookup(ht, attr_name)) return true; return false; } @@ -365,9 +365,9 @@ static str *sdp_manipulations_subst(struct sdp_manipulations * sdp_manipulations if (!sdp_manipulations) return NULL; - GHashTable * ht = sdp_manipulations->subst_commands; + str_case_value_ht ht = sdp_manipulations->subst_commands; - str * cmd_subst_value = ht ? g_hash_table_lookup(ht, attr_name) : NULL; + str * cmd_subst_value = t_hash_table_is_set(ht) ? t_hash_table_lookup(ht, attr_name) : NULL; return cmd_subst_value; } diff --git a/include/sdp.h b/include/sdp.h index d5944e786..8b46760f5 100644 --- a/include/sdp.h +++ b/include/sdp.h @@ -13,8 +13,8 @@ */ struct sdp_manipulations { str_q add_commands; - GHashTable * rem_commands; - GHashTable * subst_commands; + str_case_ht rem_commands; + str_case_value_ht subst_commands; }; struct ice_candidate;