aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-dnp.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-02-01 23:13:42 -0500
committerMichael Mann <mmann78@netscape.net>2017-02-02 13:46:03 +0000
commit577d21e35c1ca19e245014ea2b65d09709c9cca3 (patch)
tree91d63807f33f05a4970b9fe769dbec7040b904e0 /epan/dissectors/packet-dnp.c
parent36892d8a4ca2f6019dc00b0f2540097499da2e11 (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-dnp.c')
-rw-r--r--epan/dissectors/packet-dnp.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/epan/dissectors/packet-dnp.c b/epan/dissectors/packet-dnp.c
index 48df1f3f40..1705caa9e7 100644
--- a/epan/dissectors/packet-dnp.c
+++ b/epan/dissectors/packet-dnp.c
@@ -1301,7 +1301,7 @@ static expert_field ei_dnp3_buffering_user_data_until_final_frame_is_received =
/* Tables for reassembly of fragments. */
static reassembly_table al_reassembly_table;
-static GHashTable *dl_conversation_table = NULL;
+static wmem_map_t *dl_conversation_table = NULL;
/* Data-Link-Layer Conversation Key Structure */
typedef struct _dl_conversation_key
@@ -3326,7 +3326,7 @@ dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
dl_conversation_key.src = dl_src;
dl_conversation_key.dst = dl_dst;
- conv_data_ptr = (dnp3_conv_t*)g_hash_table_lookup(dl_conversation_table, &dl_conversation_key);
+ conv_data_ptr = (dnp3_conv_t*)wmem_map_lookup(dl_conversation_table, &dl_conversation_key);
if (!pinfo->fd->flags.visited && conv_data_ptr == NULL)
{
@@ -3339,7 +3339,7 @@ dissect_dnp3_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
/*** Increment static global fragment reassembly id ***/
conv_data_ptr->conv_seq_number = seq_number++;
- g_hash_table_insert(dl_conversation_table, new_dl_conversation_key, conv_data_ptr);
+ wmem_map_insert(dl_conversation_table, new_dl_conversation_key, conv_data_ptr);
}
conv_seq_number = conv_data_ptr->conv_seq_number;
@@ -3518,18 +3518,6 @@ dissect_dnp3_udp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
}
-static void
-dnp3_init(void)
-{
- dl_conversation_table = g_hash_table_new(dl_conversation_hash, dl_conversation_equal);
-}
-
-static void
-dnp3_cleanup(void)
-{
- g_hash_table_destroy(dl_conversation_table);
-}
-
/* Register the protocol with Wireshark */
void
@@ -4551,16 +4539,12 @@ proto_register_dnp3(void)
module_t *dnp3_module;
expert_module_t* expert_dnp3;
-/* Register protocol init routine */
- register_init_routine(&dnp3_init);
- register_cleanup_routine(&dnp3_cleanup);
+ dl_conversation_table = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), dl_conversation_hash, dl_conversation_equal);
reassembly_table_register(&al_reassembly_table,
&addresses_reassembly_table_functions);
-
/* Register the protocol name and description */
- proto_dnp3 = proto_register_protocol("Distributed Network Protocol 3.0",
- "DNP 3.0", "dnp3");
+ proto_dnp3 = proto_register_protocol("Distributed Network Protocol 3.0", "DNP 3.0", "dnp3");
/* Register the dissector so it may be used as a User DLT payload protocol */
register_dissector("dnp3.udp", dissect_dnp3_udp, proto_dnp3);