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-aoe.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-aoe.c')
-rw-r--r-- | epan/dissectors/packet-aoe.c | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/epan/dissectors/packet-aoe.c b/epan/dissectors/packet-aoe.c index a9d38cb75d..d3b6d92d68 100644 --- a/epan/dissectors/packet-aoe.c +++ b/epan/dissectors/packet-aoe.c @@ -175,8 +175,8 @@ typedef struct ata_info_t { nstime_t req_time; guint8 cmd; } ata_info_t; -static GHashTable *ata_cmd_unmatched = NULL; -static GHashTable *ata_cmd_matched = NULL; +static wmem_map_t *ata_cmd_unmatched = NULL; +static wmem_map_t *ata_cmd_matched = NULL; static guint ata_cmd_hash_matched(gconstpointer k) @@ -232,29 +232,29 @@ dissect_ata_pdu(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, ata_info->cmd=tvb_get_guint8(tvb, offset+3); ata_info->req_time=pinfo->abs_ts; - tmp_ata_info=(ata_info_t *)g_hash_table_lookup(ata_cmd_unmatched, ata_info); + tmp_ata_info=(ata_info_t *)wmem_map_lookup(ata_cmd_unmatched, ata_info); if(tmp_ata_info){ - g_hash_table_remove(ata_cmd_unmatched, tmp_ata_info); + wmem_map_remove(ata_cmd_unmatched, tmp_ata_info); } - g_hash_table_insert(ata_cmd_unmatched, ata_info, ata_info); + wmem_map_insert(ata_cmd_unmatched, ata_info, ata_info); } else { ata_info_t tmp_ata_info; /* first time we see this response so see if we can match it with a request */ tmp_ata_info.tag=tag; tmp_ata_info.conversation=conversation; - ata_info=(ata_info_t *)g_hash_table_lookup(ata_cmd_unmatched, &tmp_ata_info); + ata_info=(ata_info_t *)wmem_map_lookup(ata_cmd_unmatched, &tmp_ata_info); /* woo hoo we could, so no need to store this in unmatched any more, move both request and response to the matched table */ if(ata_info){ ata_info->response_frame=pinfo->num; - g_hash_table_remove(ata_cmd_unmatched, ata_info); - g_hash_table_insert(ata_cmd_matched, GUINT_TO_POINTER(ata_info->request_frame), ata_info); - g_hash_table_insert(ata_cmd_matched, GUINT_TO_POINTER(ata_info->response_frame), ata_info); + wmem_map_remove(ata_cmd_unmatched, ata_info); + wmem_map_insert(ata_cmd_matched, GUINT_TO_POINTER(ata_info->request_frame), ata_info); + wmem_map_insert(ata_cmd_matched, GUINT_TO_POINTER(ata_info->response_frame), ata_info); } } } else { - ata_info=(ata_info_t *)g_hash_table_lookup(ata_cmd_matched, GUINT_TO_POINTER(pinfo->num)); + ata_info=(ata_info_t *)wmem_map_lookup(ata_cmd_matched, GUINT_TO_POINTER(pinfo->num)); } if(ata_info){ @@ -394,20 +394,6 @@ dissect_aoe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da return tvb_captured_length(tvb); } -static void -ata_init(void) -{ - ata_cmd_unmatched=g_hash_table_new(ata_cmd_hash_unmatched, ata_cmd_equal_unmatched); - ata_cmd_matched=g_hash_table_new(ata_cmd_hash_matched, ata_cmd_equal_matched); -} - -static void -ata_cleanup(void) -{ - g_hash_table_destroy(ata_cmd_unmatched); - g_hash_table_destroy(ata_cmd_matched); -} - void proto_register_aoe(void) { @@ -476,8 +462,8 @@ proto_register_aoe(void) aoe_handle = register_dissector("aoe", dissect_aoe, proto_aoe); - register_init_routine(ata_init); - register_cleanup_routine(ata_cleanup); + ata_cmd_unmatched=wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), ata_cmd_hash_unmatched, ata_cmd_equal_unmatched); + ata_cmd_matched=wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), ata_cmd_hash_matched, ata_cmd_equal_matched); } void |