diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-06-27 15:33:42 -0700 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2015-07-04 00:17:14 +0000 |
commit | 3243b6f964c96f0137fc3fffd66a74dd9f7910fd (patch) | |
tree | cb4c47ada88b45cd7f6b1835cd412d1d60b746c2 /asn1/tcap | |
parent | 7b33634cc562ba0ee75536b7dde4268a20d89bee (diff) |
asn1: split off cleanup routines
General approach:
1. Split allocation (e.g. g_hash_table_new) from deallocation
(g_hash_table_destroy) into functions named "init" and "cleanup".
2. Remove guards that test whether the hash tables are set as
init is always called before cleanup.
3. Remove setting hash tables to NULL after destruction.
4. Copy register_init_routine function call and change init to cleanup.
5. Add cleanup function that calls reassembly_table_destroy if there
is a reassembly_table_init function.
Some templates were modified as follows:
- snmp: split renew into init+cleanup, but keep renew for the uat_new
callback.
- ldap,ros: Rename init to cleanup as there was no initialization.
- camel: remove init function from header, make it static. Remove debug
print.
- tcap: remove unused ssn_range assignment.
Files in epan/ were regenerated using cmake && make asn1
Change-Id: Idac16ebf0ec304e0c8becaab5d32904e56eb69b9
Reviewed-on: https://code.wireshark.org/review/9136
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'asn1/tcap')
-rw-r--r-- | asn1/tcap/packet-tcap-template.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/asn1/tcap/packet-tcap-template.c b/asn1/tcap/packet-tcap-template.c index b1a7dd7f80..83e5b6a991 100644 --- a/asn1/tcap/packet-tcap-template.c +++ b/asn1/tcap/packet-tcap-template.c @@ -2071,6 +2071,7 @@ proto_reg_handoff_tcap(void) } static void init_tcap(void); +static void cleanup_tcap(void); void proto_register_tcap(void) @@ -2187,7 +2188,6 @@ proto_register_tcap(void) /* Set default SSNs */ range_convert_str(&global_ssn_range, "", MAX_SSN); - ssn_range = range_empty(); prefs_register_range_preference(tcap_module, "ssn", "SCCP SSNs", "SCCP (and SUA) SSNs to decode as TCAP", @@ -2222,6 +2222,7 @@ proto_register_tcap(void) tcap_handle = create_dissector_handle(dissect_tcap, proto_tcap); register_init_routine(&init_tcap); + register_cleanup_routine(&cleanup_tcap); } @@ -2242,16 +2243,17 @@ static void range_add_callback(guint32 ssn) static void init_tcap(void) { - if (ssn_range) { - range_foreach(ssn_range, range_delete_callback); - g_free(ssn_range); - } - ssn_range = range_copy(global_ssn_range); range_foreach(ssn_range, range_add_callback); tcapsrt_init_routine(); } +static void cleanup_tcap(void) +{ + range_foreach(ssn_range, range_delete_callback); + g_free(ssn_range); +} + static int dissect_tcap_param(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset) { |