diff options
author | Michael Mann <mmann78@netscape.net> | 2017-02-01 23:13:42 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-02-02 13:46:03 +0000 |
commit | 577d21e35c1ca19e245014ea2b65d09709c9cca3 (patch) | |
tree | 91d63807f33f05a4970b9fe769dbec7040b904e0 /epan/dissectors/packet-fcfcs.c | |
parent | 36892d8a4ca2f6019dc00b0f2540097499da2e11 (diff) |
GHashtable -> wmem_map conversions
Many of the register_init_routine/register_cleanup_routine functions
are for initializing and cleaning up a GHashtable.
wmem_map_new_autoreset can do that automatically, so convert many
of the simple cases.
Change-Id: I93e1f435845fd5a5e5286487e9f0092fae052f3e
Reviewed-on: https://code.wireshark.org/review/19912
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-fcfcs.c')
-rw-r--r-- | epan/dissectors/packet-fcfcs.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/epan/dissectors/packet-fcfcs.c b/epan/dissectors/packet-fcfcs.c index 68d2292694..53b6620dff 100644 --- a/epan/dissectors/packet-fcfcs.c +++ b/epan/dissectors/packet-fcfcs.c @@ -97,7 +97,7 @@ typedef struct _fcfcs_conv_data { guint32 opcode; } fcfcs_conv_data_t; -static GHashTable *fcfcs_req_hash = NULL; +static wmem_map_t *fcfcs_req_hash = NULL; /* * Hash Functions @@ -122,21 +122,6 @@ fcfcs_hash (gconstpointer v) return val; } -/* - * Protocol initialization - */ -static void -fcfcs_init_protocol(void) -{ - fcfcs_req_hash = g_hash_table_new(fcfcs_hash, fcfcs_equal); -} - -static void -fcfcs_cleanup_protocol(void) -{ - g_hash_table_destroy(fcfcs_req_hash); -} - /* Code to actually dissect the packets */ static void dissect_fcfcs_giel (tvbuff_t *tvb, proto_tree *tree, gboolean isreq) @@ -738,7 +723,7 @@ dissect_fcfcs (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) ckey.conv_idx = conversation->conv_index; - cdata = (fcfcs_conv_data_t *)g_hash_table_lookup (fcfcs_req_hash, + cdata = (fcfcs_conv_data_t *)wmem_map_lookup (fcfcs_req_hash, &ckey); if (cdata) { /* Since we never free the memory used by an exchange, this maybe a @@ -754,7 +739,7 @@ dissect_fcfcs (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) cdata = wmem_new(wmem_file_scope(), fcfcs_conv_data_t); cdata->opcode = opcode; - g_hash_table_insert (fcfcs_req_hash, req_key, cdata); + wmem_map_insert (fcfcs_req_hash, req_key, cdata); } col_add_str (pinfo->cinfo, COL_INFO, val_to_str (opcode, fc_fcs_opcode_abbrev_val, "0x%x")); @@ -778,7 +763,7 @@ dissect_fcfcs (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data) else { ckey.conv_idx = conversation->conv_index; - cdata = (fcfcs_conv_data_t *)g_hash_table_lookup (fcfcs_req_hash, + cdata = (fcfcs_conv_data_t *)wmem_map_lookup (fcfcs_req_hash, &ckey); if (cdata != NULL) { @@ -1042,8 +1027,7 @@ proto_register_fcfcs (void) expert_fcfcs = expert_register_protocol(proto_fcfcs); expert_register_field_array(expert_fcfcs, ei, array_length(ei)); - register_init_routine (&fcfcs_init_protocol); - register_cleanup_routine (&fcfcs_cleanup_protocol); + fcfcs_req_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), fcfcs_hash, fcfcs_equal); } void |