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-dcerpc-nt.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-dcerpc-nt.c')
-rw-r--r-- | epan/dissectors/packet-dcerpc-nt.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/epan/dissectors/packet-dcerpc-nt.c b/epan/dissectors/packet-dcerpc-nt.c index d1a060b0a8..6726204b9a 100644 --- a/epan/dissectors/packet-dcerpc-nt.c +++ b/epan/dissectors/packet-dcerpc-nt.c @@ -526,7 +526,7 @@ typedef struct { pol_value *list; /* List of policy handle entries */ } pol_hash_value; -static GHashTable *pol_hash = NULL; +static wmem_map_t *pol_hash = NULL; /* Hash function */ @@ -572,7 +572,7 @@ static pol_value *find_pol_handle(e_ctx_hnd *policy_hnd, guint32 frame, pol_value *pol; memcpy(&key.policy_hnd, policy_hnd, sizeof(key.policy_hnd)); - if ((*valuep = (pol_hash_value *)g_hash_table_lookup(pol_hash, &key))) { + if ((*valuep = (pol_hash_value *)wmem_map_lookup(pol_hash, &key))) { /* * Look for the first value such that both: * @@ -625,7 +625,7 @@ static void add_pol_handle(e_ctx_hnd *policy_hnd, guint32 frame, pol->next = NULL; key = (pol_hash_key *)wmem_alloc(wmem_file_scope(), sizeof(pol_hash_key)); memcpy(&key->policy_hnd, policy_hnd, sizeof(key->policy_hnd)); - g_hash_table_insert(pol_hash, key, value); + wmem_map_insert(pol_hash, key, value); } else { /* * Put the new value in the hash value's policy handle @@ -867,18 +867,6 @@ gboolean dcerpc_fetch_polhnd_data(e_ctx_hnd *policy_hnd, return pol != NULL; } -/* Initialise policy handle hash */ - -static void init_pol_hash(void) -{ - pol_hash = g_hash_table_new(pol_hash_fn, pol_hash_compare); -} - -static void cleanup_pol_hash(void) -{ - g_hash_table_destroy(pol_hash); -} - /* Dissect a NT status code */ int @@ -2021,8 +2009,8 @@ void dcerpc_smb_init(int proto_dcerpc) /* Initialise policy handle hash */ expert_dcerpc_nt = expert_register_protocol(proto_dcerpc); expert_register_field_array(expert_dcerpc_nt, ei, array_length(ei)); - register_init_routine(&init_pol_hash); - register_cleanup_routine(&cleanup_pol_hash); + + pol_hash = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(), pol_hash_fn, pol_hash_compare); } /* |