diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-06-28 16:02:45 -0700 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-07-03 23:35:14 +0000 |
commit | 126e02cd58c08aa234cd8c9e0e0739f961f462d3 (patch) | |
tree | bc095aa1d1b9e575bdcbef49bfe017e0725b64ab /epan/dissectors/packet-afs.c | |
parent | 80f7ee063d371f0de989d51d40c6b4fabfbfb430 (diff) |
Call reassembly_table_destroy and move g_hash_table_destroy
This patch moves g_hash_table_destroy calls from the init routine to
the cleanup routine. Besides that, the conditional check for the hash
table has been removed, assuming that init is always paired with a
cleanup call.
If reassembly_table_init is found, a reassembly_table_destroy call is
prepended to the cleanup function as well.
Comments have been removed from the init function as well as these did
not seem to have additional value ("destroy hash table" is clear from
the context).
The changes were automatically generated using
https://git.lekensteyn.nl/peter/wireshark-notes/diff/one-off/cleanup-rewrite.py?id=4d11f07180d9c115eb14bd860e9a47d82d3d1dcd
Manually edited files (for assignment auditing): dvbci, ositp, sccp,
tcp.
Other files that needed special attention due to the use of
register_postseq_cleanup_routine:
- ipx: keep call, do not add another cleanup routine.
- ncp: remove empty mncp_postseq_cleanup. mncp_hash_lookup is used
even if a frame is visited before (see dissect_ncp_common), hence
the hash table cannot be destroyed here. Do it in cleanup instead.
- ndps: add cleanup routine to kill reassembly table, but do not
destroy the hash table as it is already done in ndps_postseq_cleanup.
Change-Id: I95a72b3df2978b2c13fefff6bd6821442193d0ed
Reviewed-on: https://code.wireshark.org/review/9223
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-afs.c')
-rw-r--r-- | epan/dissectors/packet-afs.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/epan/dissectors/packet-afs.c b/epan/dissectors/packet-afs.c index 9613533774..1e9a5dac12 100644 --- a/epan/dissectors/packet-afs.c +++ b/epan/dissectors/packet-afs.c @@ -1415,17 +1415,18 @@ afs_hash (gconstpointer v) static void afs_init_protocol(void) { - if (afs_request_hash) - g_hash_table_destroy(afs_request_hash); - afs_request_hash = g_hash_table_new(afs_hash, afs_equal); - - /* fragment_table_init(&afs_fragment_table); */ - /* reassembled_table_init(&afs_reassembled_table); */ reassembly_table_init(&afs_reassembly_table, &addresses_reassembly_table_functions); } +static void +afs_cleanup_protocol(void) +{ + reassembly_table_destroy(&afs_reassembly_table); + g_hash_table_destroy(afs_request_hash); +} + /* * Here is a helper routine for adding an AFS acl to the proto tree * This is to be used with FS packets only @@ -3631,6 +3632,7 @@ proto_register_afs(void) proto_register_field_array(proto_afs, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); register_init_routine(&afs_init_protocol); + register_cleanup_routine(&afs_cleanup_protocol); new_register_dissector("afs", dissect_afs, proto_afs); } |