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/nbap | |
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/nbap')
-rw-r--r-- | asn1/nbap/packet-nbap-template.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/asn1/nbap/packet-nbap-template.c b/asn1/nbap/packet-nbap-template.c index b6a0318cd3..8c34e80269 100644 --- a/asn1/nbap/packet-nbap-template.c +++ b/asn1/nbap/packet-nbap-template.c @@ -419,16 +419,9 @@ static gint nbap_key_cmp(gconstpointer a_ptr, gconstpointer b_ptr, gpointer igno }*/ static void nbap_init(void){ - guint8 i; - /*Cleanup*/ - if(com_context_map){ - g_tree_destroy(com_context_map); - } - if(edch_flow_port_map){ - g_tree_destroy(edch_flow_port_map); - } - /*Initialize*/ - com_context_map = g_tree_new_full(nbap_key_cmp, + guint8 i; + /*Initialize*/ + com_context_map = g_tree_new_full(nbap_key_cmp, NULL, /* data pointer, optional */ NULL, /* function to free the memory allocated for the key used when removing the entry */ g_free); @@ -441,9 +434,16 @@ static void nbap_init(void){ g_free); for (i = 0; i < 15; i++) { - lchId_type_table[i+1] = *lch_contents[i]; - } + lchId_type_table[i+1] = *lch_contents[i]; + } } + +static void nbap_cleanup(void){ + /*Cleanup*/ + g_tree_destroy(com_context_map); + g_tree_destroy(edch_flow_port_map); +} + static int dissect_nbap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) { @@ -532,6 +532,7 @@ void proto_register_nbap(void) nbap_proc_uout_dissector_table = register_dissector_table("nbap.proc.uout", "NBAP-ELEMENTARY-PROCEDURE UnsuccessfulOutcome", FT_STRING, BASE_NONE); register_init_routine(nbap_init); + register_cleanup_routine(nbap_cleanup); } /* |