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 /epan/dissectors/packet-pres.c | |
parent | 7b33634cc562ba0ee75536b7dde4268a20d89bee (diff) | |
download | wireshark-3243b6f964c96f0137fc3fffd66a74dd9f7910fd.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
Reviewed-on: https://code.wireshark.org/review/9136
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-pres.c')
-rw-r--r-- | epan/dissectors/packet-pres.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/epan/dissectors/packet-pres.c b/epan/dissectors/packet-pres.c index a089d0bebb..9af2549f49 100644 --- a/epan/dissectors/packet-pres.c +++ b/epan/dissectors/packet-pres.c @@ -249,16 +249,18 @@ pres_ctx_oid_equal(gconstpointer k1, gconstpointer k2) static void pres_init(void) { - if( pres_ctx_oid_table ){ - g_hash_table_destroy(pres_ctx_oid_table); - pres_ctx_oid_table = NULL; - } pres_ctx_oid_table = g_hash_table_new(pres_ctx_oid_hash, pres_ctx_oid_equal); } static void +pres_cleanup(void) +{ + g_hash_table_destroy(pres_ctx_oid_table); +} + +static void register_ctx_id_and_oid(packet_info *pinfo _U_, guint32 idx, const char *oid) { pres_ctx_oid_t *pco, *tmppco; @@ -1358,7 +1360,7 @@ static int dissect_UD_type_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_ /*--- End of included file: packet-pres-fn.c ---*/ -#line 223 "../../asn1/pres/packet-pres-template.c" +#line 225 "../../asn1/pres/packet-pres-template.c" /* @@ -1842,7 +1844,7 @@ void proto_register_pres(void) { NULL, HFILL }}, /*--- End of included file: packet-pres-hfarr.c ---*/ -#line 394 "../../asn1/pres/packet-pres-template.c" +#line 396 "../../asn1/pres/packet-pres-template.c" }; /* List of subtrees */ @@ -1889,7 +1891,7 @@ void proto_register_pres(void) { &ett_pres_UD_type, /*--- End of included file: packet-pres-ettarr.c ---*/ -#line 400 "../../asn1/pres/packet-pres-template.c" +#line 402 "../../asn1/pres/packet-pres-template.c" }; static ei_register_info ei[] = { @@ -1934,6 +1936,7 @@ void proto_register_pres(void) { expert_pres = expert_register_protocol(proto_pres); expert_register_field_array(expert_pres, ei, array_length(ei)); register_init_routine(pres_init); + register_cleanup_routine(pres_cleanup); pres_module = prefs_register_protocol(proto_pres, NULL); |