diff options
author | Martin Mathieson <martin.r.mathieson@googlemail.com> | 2014-12-12 16:53:05 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-12-13 00:17:23 +0000 |
commit | 5d6eb80c14d786fe781c50c4899b7cdf03131db8 (patch) | |
tree | aef6b60e6cfa913072afb418719ad77d09325962 | |
parent | b0cdee67da31683d691de6556a592624e86a351e (diff) |
Use g_direct_ functions for hash tables where possible
Change-Id: Ie364cbdcf500d7a04e64d7adcdd03bd1926dda86
Reviewed-on: https://code.wireshark.org/review/5736
Reviewed-by: Evan Huus <eapache@gmail.com>
-rw-r--r-- | epan/dissectors/packet-mac-lte.c | 62 | ||||
-rw-r--r-- | epan/dissectors/packet-pdcp-lte.c | 16 |
2 files changed, 13 insertions, 65 deletions
diff --git a/epan/dissectors/packet-mac-lte.c b/epan/dissectors/packet-mac-lte.c index 9b8af4b470..478942bf19 100644 --- a/epan/dissectors/packet-mac-lte.c +++ b/epan/dissectors/packet-mac-lte.c @@ -1155,18 +1155,6 @@ typedef struct Msg3Data { Msg3 frames are first read. */ static GHashTable *mac_lte_msg3_hash = NULL; -/* Hash table functions for mac_lte_msg3_hash. Hash is just the (RNTI) key */ -static gint mac_lte_rnti_hash_equal(gconstpointer v, gconstpointer v2) -{ - return (v == v2); -} - -static guint mac_lte_rnti_hash_func(gconstpointer v) -{ - return GPOINTER_TO_UINT(v); -} - - typedef enum ContentionResolutionStatus { NoMsg3, Msg3Match, @@ -1184,17 +1172,6 @@ typedef struct ContentionResolutionResult { pass and used thereafter */ static GHashTable *mac_lte_cr_result_hash = NULL; -/* Hash table functions for mac_lte_cr_result_hash. Hash is just the (framenum) key */ -static gint mac_lte_framenum_hash_equal(gconstpointer v, gconstpointer v2) -{ - return (v == v2); -} - -static guint mac_lte_framenum_hash_func(gconstpointer v) -{ - return GPOINTER_TO_UINT(v); -} - /**************************************************************************/ @@ -4431,6 +4408,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; break; + /* TODO: treat separately */ case TRUNCATED_BSR_LCID: case SHORT_BSR_LCID: { @@ -5807,23 +5785,23 @@ static void mac_lte_init_protocol(void) DL_tti_info.subframe = 0xff; /* Invalid value */ /* Now create them over */ - mac_lte_msg3_hash = g_hash_table_new(mac_lte_rnti_hash_func, mac_lte_rnti_hash_equal); - mac_lte_cr_result_hash = g_hash_table_new(mac_lte_framenum_hash_func, mac_lte_framenum_hash_equal); + mac_lte_msg3_hash = g_hash_table_new(g_direct_hash, g_direct_equal); + mac_lte_cr_result_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_dl_harq_hash = g_hash_table_new(mac_lte_rnti_hash_func, mac_lte_rnti_hash_equal); - mac_lte_dl_harq_result_hash = g_hash_table_new(mac_lte_framenum_hash_func, mac_lte_framenum_hash_equal); + mac_lte_dl_harq_hash = g_hash_table_new(g_direct_hash, g_direct_equal); + mac_lte_dl_harq_result_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_ul_harq_hash = g_hash_table_new(mac_lte_rnti_hash_func, mac_lte_rnti_hash_equal); - mac_lte_ul_harq_result_hash = g_hash_table_new(mac_lte_framenum_hash_func, mac_lte_framenum_hash_equal); + mac_lte_ul_harq_hash = g_hash_table_new(g_direct_hash, g_direct_equal); + mac_lte_ul_harq_result_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_ue_sr_state = g_hash_table_new(mac_lte_rnti_hash_func, mac_lte_rnti_hash_equal); - mac_lte_sr_request_hash = g_hash_table_new(mac_lte_framenum_hash_func, mac_lte_framenum_hash_equal); + mac_lte_ue_sr_state = g_hash_table_new(g_direct_hash, g_direct_equal); + mac_lte_sr_request_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_tti_info_result_hash = g_hash_table_new(mac_lte_framenum_hash_func, mac_lte_framenum_hash_equal); + mac_lte_tti_info_result_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_ue_channels_hash = g_hash_table_new(mac_lte_rnti_hash_func, mac_lte_rnti_hash_equal); + mac_lte_ue_channels_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_drx_ue_state = g_hash_table_new(mac_lte_rnti_hash_func, mac_lte_rnti_hash_equal); + mac_lte_drx_ue_state = g_hash_table_new(g_direct_hash, g_direct_equal); mac_lte_drx_frame_result = g_hash_table_new(mac_lte_framenum_instance_hash_func, mac_lte_framenum_instance_hash_equal); mac_lte_ue_ext_bsr_sizes_hash = g_hash_table_new(g_direct_hash, g_direct_equal); @@ -7068,28 +7046,12 @@ void proto_register_mac_lte(void) 0, 0x0, NULL, HFILL } }, -#if 0 - { &hf_mac_lte_drx_state_long_cycle_on, - { "Long cycle current on", - "mac-lte.drx-state.long-cycle-on", FT_BOOLEAN, BASE_NONE, - 0, 0x0, NULL, HFILL - } - }, -#endif { &hf_mac_lte_drx_state_short_cycle_offset, { "Short cycle offset", "mac-lte.drx-state.short-cycle-offset", FT_UINT16, BASE_DEC, 0, 0x0, NULL, HFILL } }, -#if 0 - { &hf_mac_lte_drx_state_short_cycle_on, - { "Short cycle current on", - "mac-lte.drx-state.short-cycle-on", FT_BOOLEAN, BASE_NONE, - 0, 0x0, NULL, HFILL - } - }, -#endif { &hf_mac_lte_drx_state_inactivity_remaining, { "Inactivity remaining", "mac-lte.drx-state.inactivity-remaining", FT_UINT16, BASE_DEC, diff --git a/epan/dissectors/packet-pdcp-lte.c b/epan/dissectors/packet-pdcp-lte.c index 294c18c4e0..3e81ae187e 100644 --- a/epan/dissectors/packet-pdcp-lte.c +++ b/epan/dissectors/packet-pdcp-lte.c @@ -480,20 +480,6 @@ typedef struct Maps key -> status */ static GHashTable *pdcp_sequence_analysis_channel_hash = NULL; -/* Equal keys */ -static gint pdcp_channel_equal(gconstpointer v, gconstpointer v2) -{ - /* Key fits in 4 bytes, so just compare pointers! */ - return (v == v2); -} - -/* Compute a hash value for a given key. */ -static guint pdcp_channel_hash_func(gconstpointer v) -{ - /* Just use pointer, as the fields are all in this value */ - return GPOINTER_TO_UINT(v); -} - /* Hash table types & functions for frame reports */ @@ -2263,7 +2249,7 @@ static void pdcp_lte_init_protocol(void) /* Now create them over */ - pdcp_sequence_analysis_channel_hash = g_hash_table_new(pdcp_channel_hash_func, pdcp_channel_equal); + pdcp_sequence_analysis_channel_hash = g_hash_table_new(g_direct_hash, g_direct_equal); pdcp_lte_sequence_analysis_report_hash = g_hash_table_new(pdcp_result_hash_func, pdcp_result_hash_equal); pdcp_security_hash = g_hash_table_new(pdcp_lte_ueid_hash_func, pdcp_lte_ueid_hash_equal); pdcp_security_result_hash = g_hash_table_new(pdcp_lte_ueid_frame_hash_func, pdcp_lte_ueid_frame_hash_equal); |