summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-tcap.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-06-27 15:33:42 -0700
committerPeter Wu <peter@lekensteyn.nl>2015-07-03 23:54:42 +0200
commitef0006ddf357b29c1c0d5dab3948172aabd0209f (patch)
tree4ffb29efb05681082b4e6310ca7f17554ed136d3 /epan/dissectors/packet-tcap.c
parente4490426d7ea252561d96e43f7ed2e164879e562 (diff)
downloadwireshark-ef0006ddf357b29c1c0d5dab3948172aabd0209f.tar.gz
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
Diffstat (limited to 'epan/dissectors/packet-tcap.c')
-rw-r--r--epan/dissectors/packet-tcap.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/epan/dissectors/packet-tcap.c b/epan/dissectors/packet-tcap.c
index 4b43feeea3..854c952782 100644
--- a/epan/dissectors/packet-tcap.c
+++ b/epan/dissectors/packet-tcap.c
@@ -3350,6 +3350,7 @@ proto_reg_handoff_tcap(void)
}
static void init_tcap(void);
+static void cleanup_tcap(void);
void
proto_register_tcap(void)
@@ -3687,7 +3688,7 @@ proto_register_tcap(void)
NULL, HFILL }},
/*--- End of included file: packet-tcap-hfarr.c ---*/
-#line 2143 "../../asn1/tcap/packet-tcap-template.c"
+#line 2144 "../../asn1/tcap/packet-tcap-template.c"
};
/* Setup protocol subtree array */
@@ -3736,7 +3737,7 @@ proto_register_tcap(void)
&ett_tcap_Associate_source_diagnostic,
/*--- End of included file: packet-tcap-ettarr.c ---*/
-#line 2153 "../../asn1/tcap/packet-tcap-template.c"
+#line 2154 "../../asn1/tcap/packet-tcap-template.c"
};
/*static enum_val_t tcap_options[] = {
@@ -3774,7 +3775,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",
@@ -3809,6 +3809,7 @@ proto_register_tcap(void)
tcap_handle = create_dissector_handle(dissect_tcap, proto_tcap);
register_init_routine(&init_tcap);
+ register_cleanup_routine(&cleanup_tcap);
}
@@ -3829,16 +3830,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)
{