forked from osmocom/wireshark
Split init of misc dissectors into init/cleanup functions
Convert remaining dissectors to use cleanup routines when possible. (Single-)linked lists require NULL, so do reset their pointers to NULL. Generated with https://git.lekensteyn.nl/peter/wireshark-notes/diff/one-off/cleanup-rewrite.py?id=69af86e6c2cf965ba3d7f9636b647b195f0b7d57 (with AUDIT = ALWAYS_EMIT_CLEANUP_CODE = True) Remaining dissectors which did not need further changes: epan/dissectors/packet-aeron.c epan/dissectors/packet-bootp.c epan/dissectors/packet-brdwlk.c epan/dissectors/packet-drda.c epan/dissectors/packet-etch.c epan/dissectors/packet-fix.c epan/dissectors/packet-fw1.c epan/dissectors/packet-lbm.c epan/dissectors/packet-ldss.c epan/dissectors/packet-simulcrypt.c epan/dissectors/packet-spdy.c epan/dissectors/packet-starteam.c epan/dissectors/packet-udp.c Change-Id: Idcacfea6a5de38d40e67db4cdcd0452ad9f9a6a9 Reviewed-on: https://code.wireshark.org/review/9228 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
7ce77c69ea
commit
ea46cf4f73
|
@ -2172,8 +2172,7 @@ dissect_dcom_PMInterfacePointer(tvbuff_t *tvb, gint offset, packet_info *pinfo,
|
|||
return offset;
|
||||
}
|
||||
|
||||
static void dcom_reinit( void) {
|
||||
|
||||
static void dcom_cleanup(void) {
|
||||
if (dcom_machines != NULL) {
|
||||
GList *machines;
|
||||
|
||||
|
@ -2217,8 +2216,6 @@ static void dcom_reinit( void) {
|
|||
g_list_free(dcom_interfaces);
|
||||
dcom_interfaces = NULL;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2505,7 +2502,7 @@ proto_register_dcom (void)
|
|||
"usually hidden",
|
||||
&dcom_prefs_display_unmarshalling_details);
|
||||
|
||||
register_init_routine(dcom_reinit);
|
||||
register_cleanup_routine(dcom_cleanup);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8609,7 +8609,7 @@ dissect_gtp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
|
|||
}
|
||||
|
||||
static void
|
||||
gtp_reinit(void)
|
||||
gtp_cleanup(void)
|
||||
{
|
||||
gtp_conv_info_t *gtp_info;
|
||||
|
||||
|
@ -9787,7 +9787,7 @@ proto_register_gtp(void)
|
|||
gtp_priv_ext_dissector_table = register_dissector_table("gtp.priv_ext", "GTP PRIVATE EXT", FT_UINT16, BASE_DEC);
|
||||
gtp_cdr_fmt_dissector_table = register_dissector_table("gtp.cdr_fmt", "GTP DATA RECORD TYPE", FT_UINT16, BASE_DEC);
|
||||
|
||||
register_init_routine(gtp_reinit);
|
||||
register_cleanup_routine(gtp_cleanup);
|
||||
gtp_tap = register_tap("gtp");
|
||||
gtpv1_tap = register_tap("gtpv1");
|
||||
|
||||
|
|
|
@ -217,12 +217,16 @@ circuit_chain_lookup(const h223_call_info* call_info, guint32 child_vc)
|
|||
static void
|
||||
circuit_chain_init(void)
|
||||
{
|
||||
if (circuit_chain_hashtable)
|
||||
g_hash_table_destroy(circuit_chain_hashtable);
|
||||
circuit_chain_hashtable = g_hash_table_new(circuit_chain_hash, circuit_chain_equal);
|
||||
circuit_chain_count = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
circuit_chain_destroy(void)
|
||||
{
|
||||
g_hash_table_destroy(circuit_chain_hashtable);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
|
@ -1433,12 +1437,6 @@ dissect_h223_bitswapped(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
static void
|
||||
h223_init_protocol (void)
|
||||
{
|
||||
circuit_chain_init();
|
||||
}
|
||||
|
||||
|
||||
void proto_register_h223 (void)
|
||||
{
|
||||
|
@ -1653,7 +1651,8 @@ void proto_register_h223 (void)
|
|||
|
||||
/* register our init routine to be called at the start of a capture,
|
||||
to clear out our hash tables etc */
|
||||
register_init_routine(&h223_init_protocol);
|
||||
register_init_routine(&circuit_chain_init);
|
||||
register_cleanup_routine(&circuit_chain_destroy);
|
||||
|
||||
h245_set_h223_set_mc_handle( &h223_set_mc );
|
||||
h245_set_h223_add_lc_handle( &h223_add_lc );
|
||||
|
|
|
@ -736,21 +736,6 @@ typedef struct iax_call_data {
|
|||
iax_call_dirdata dirdata[2];
|
||||
} iax_call_data;
|
||||
|
||||
static void iax_init_hash( void )
|
||||
{
|
||||
if (iax_circuit_hashtab)
|
||||
g_hash_table_destroy(iax_circuit_hashtab);
|
||||
iax_circuit_hashtab = g_hash_table_new(iax_circuit_hash, iax_circuit_equal);
|
||||
circuitcount = 0;
|
||||
|
||||
if (iax_fid_table)
|
||||
g_hash_table_destroy(iax_fid_table);
|
||||
iax_fid_table = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||
|
||||
reassembly_table_init(&iax_reassembly_table,
|
||||
&addresses_reassembly_table_functions);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* creates a new CT_IAX2 circuit with a specified circuit id for a call
|
||||
|
@ -2437,7 +2422,21 @@ static void dissect_payload(tvbuff_t *tvb, guint32 offset,
|
|||
static void
|
||||
iax_init_protocol(void)
|
||||
{
|
||||
iax_init_hash();
|
||||
iax_circuit_hashtab = g_hash_table_new(iax_circuit_hash, iax_circuit_equal);
|
||||
circuitcount = 0;
|
||||
|
||||
iax_fid_table = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||
|
||||
reassembly_table_init(&iax_reassembly_table,
|
||||
&addresses_reassembly_table_functions);
|
||||
}
|
||||
|
||||
static void
|
||||
iax_cleanup_protocol(void)
|
||||
{
|
||||
g_hash_table_destroy(iax_circuit_hashtab);
|
||||
g_hash_table_destroy(iax_fid_table);
|
||||
reassembly_table_destroy(&iax_reassembly_table);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3206,6 +3205,7 @@ proto_register_iax2(void)
|
|||
/* register our init routine to be called at the start of a capture,
|
||||
to clear out our hash tables etc */
|
||||
register_init_routine(&iax_init_protocol);
|
||||
register_cleanup_routine(&iax_cleanup_protocol);
|
||||
iax2_tap = register_tap("IAX2");
|
||||
}
|
||||
|
||||
|
|
|
@ -2659,7 +2659,7 @@ static int dissect_atm_oam_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
|
|||
return tvb_captured_length(tvb);
|
||||
}
|
||||
|
||||
static void init_l2tp_dissection(void)
|
||||
static void l2tp_cleanup(void)
|
||||
{
|
||||
GSList *iterator = list_heads;
|
||||
|
||||
|
@ -3029,7 +3029,7 @@ proto_register_l2tp(void)
|
|||
"Shared secret used for control message digest authentication",
|
||||
&shared_secret);
|
||||
|
||||
register_init_routine(init_l2tp_dissection);
|
||||
register_cleanup_routine(l2tp_cleanup);
|
||||
register_decode_as(&l2tp_da);
|
||||
}
|
||||
|
||||
|
|
|
@ -2587,21 +2587,18 @@ header_equal(gconstpointer pointer1, gconstpointer pointer2)
|
|||
static void
|
||||
ntlmssp_init_protocol(void)
|
||||
{
|
||||
/*
|
||||
* Free the decrypted payloads, and then free the list of decrypted
|
||||
* payloads.
|
||||
*/
|
||||
hash_packet = g_hash_table_new(header_hash, header_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
ntlmssp_cleanup_protocol(void)
|
||||
{
|
||||
if (decrypted_payloads != NULL) {
|
||||
g_slist_foreach(decrypted_payloads, free_payload, NULL);
|
||||
g_slist_free(decrypted_payloads);
|
||||
decrypted_payloads = NULL;
|
||||
}
|
||||
|
||||
if (hash_packet != NULL) {
|
||||
g_hash_table_remove_all(hash_packet);
|
||||
} else {
|
||||
hash_packet = g_hash_table_new(header_hash, header_equal);
|
||||
}
|
||||
g_hash_table_destroy(hash_packet);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3267,6 +3264,7 @@ proto_register_ntlmssp(void)
|
|||
expert_ntlmssp = expert_register_protocol(proto_ntlmssp);
|
||||
expert_register_field_array(expert_ntlmssp, ei, array_length(ei));
|
||||
register_init_routine(&ntlmssp_init_protocol);
|
||||
register_cleanup_routine(&ntlmssp_cleanup_protocol);
|
||||
|
||||
ntlmssp_module = prefs_register_protocol(proto_ntlmssp, NULL);
|
||||
|
||||
|
|
|
@ -2630,38 +2630,21 @@ frag_free_msgs(sctp_frag_msg *msg)
|
|||
g_free(msg);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
free_table_entry(gpointer key, gpointer value, gpointer user_data _U_)
|
||||
{
|
||||
sctp_frag_msg *msg = (sctp_frag_msg *)value;
|
||||
frag_key *fkey = (frag_key *)key;
|
||||
|
||||
frag_free_msgs(msg);
|
||||
g_free(fkey);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
frag_table_init(void)
|
||||
{
|
||||
/* destroy an existing hash table and create a new one */
|
||||
if (frag_table) {
|
||||
g_hash_table_foreach_remove(frag_table, free_table_entry, NULL);
|
||||
g_hash_table_destroy(frag_table);
|
||||
frag_table=NULL;
|
||||
}
|
||||
|
||||
frag_table = g_hash_table_new(frag_hash, frag_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
sctp_init(void)
|
||||
{
|
||||
frag_table_init();
|
||||
frag_table = g_hash_table_new_full(frag_hash, frag_equal,
|
||||
(GDestroyNotify)g_free, (GDestroyNotify)frag_free_msgs);
|
||||
num_assocs = 0;
|
||||
assoc_info_list = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
sctp_cleanup(void)
|
||||
{
|
||||
g_hash_table_destroy(frag_table);
|
||||
}
|
||||
|
||||
|
||||
static sctp_frag_msg*
|
||||
find_message(guint16 stream_id, guint16 stream_seq_num)
|
||||
|
@ -4953,6 +4936,7 @@ proto_register_sctp(void)
|
|||
sctp_heur_subdissector_list = register_heur_dissector_list("sctp");
|
||||
|
||||
register_init_routine(sctp_init);
|
||||
register_cleanup_routine(sctp_cleanup);
|
||||
|
||||
dirs_by_ptvtag = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
|
||||
dirs_by_ptaddr = wmem_tree_new_autoreset(wmem_epan_scope(), wmem_file_scope());
|
||||
|
|
|
@ -16885,13 +16885,8 @@ free_hash_tables(gpointer ctarg, gpointer user_data _U_)
|
|||
}
|
||||
|
||||
static void
|
||||
smb_init_protocol(void)
|
||||
smb_cleanup(void)
|
||||
{
|
||||
/*
|
||||
* Free the hash tables attached to the conversation table
|
||||
* structures, and then free the list of conversation table
|
||||
* data structures.
|
||||
*/
|
||||
if (conv_tables) {
|
||||
g_slist_foreach(conv_tables, free_hash_tables, NULL);
|
||||
g_slist_free(conv_tables);
|
||||
|
@ -20489,7 +20484,7 @@ proto_register_smb(void)
|
|||
|
||||
proto_do_register_windows_common(proto_smb);
|
||||
|
||||
register_init_routine(&smb_init_protocol);
|
||||
register_cleanup_routine(&smb_cleanup);
|
||||
smb_module = prefs_register_protocol(proto_smb, NULL);
|
||||
prefs_register_bool_preference(smb_module, "trans_reassembly",
|
||||
"Reassemble SMB Transaction payload",
|
||||
|
|
|
@ -4492,7 +4492,6 @@ umts_fp_init_protocol(void)
|
|||
{
|
||||
guint32 hosta_addr[4];
|
||||
guint32 hostb_addr[4];
|
||||
/*struct e_in6_addr ip6_addr;*/
|
||||
address src_addr, dst_addr;
|
||||
conversation_t *conversation;
|
||||
umts_fp_conversation_info_t *umts_fp_conversation_info;
|
||||
|
|
|
@ -2691,7 +2691,7 @@ static void windowAttributes(tvbuff_t *tvb, int *offsetp, proto_tree *t,
|
|||
ENDBITMASK;
|
||||
}
|
||||
|
||||
static void x11_init_protocol(void)
|
||||
static void x11_cleanup(void)
|
||||
{
|
||||
x11_conv_data_t *state;
|
||||
|
||||
|
@ -5856,7 +5856,7 @@ void proto_register_x11(void)
|
|||
expert_x11 = expert_register_protocol(proto_x11);
|
||||
expert_register_field_array(expert_x11, ei, array_length(ei));
|
||||
|
||||
register_init_routine(x11_init_protocol);
|
||||
register_cleanup_routine(x11_cleanup);
|
||||
|
||||
extension_table = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
error_table = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
|
|
|
@ -1453,10 +1453,6 @@ gp_init_zbee_security(void)
|
|||
guint i;
|
||||
key_record_t key_record;
|
||||
|
||||
if (zbee_gp_keyring) {
|
||||
g_slist_free(zbee_gp_keyring);
|
||||
zbee_gp_keyring = NULL;
|
||||
}
|
||||
for (i = 0; gp_uat_key_records && (i < num_uat_key_records); i++) {
|
||||
key_record.frame_num = 0;
|
||||
key_record.label = g_strdup(gp_uat_key_records[i].label);
|
||||
|
@ -1465,6 +1461,15 @@ gp_init_zbee_security(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gp_cleanup_zbee_security(void)
|
||||
{
|
||||
if (zbee_gp_keyring) {
|
||||
g_slist_free(zbee_gp_keyring);
|
||||
zbee_gp_keyring = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*FUNCTION:------------------------------------------------------
|
||||
* NAME
|
||||
* proto_register_zbee_nwk_gp
|
||||
|
@ -1755,6 +1760,7 @@ proto_register_zbee_nwk_gp(void)
|
|||
"Pre-configured GP Security Keys.", zbee_gp_sec_key_table_uat);
|
||||
|
||||
register_init_routine(gp_init_zbee_security);
|
||||
register_cleanup_routine(gp_cleanup_zbee_security);
|
||||
|
||||
/* Register the Wireshark protocol. */
|
||||
proto_register_field_array(proto_zbee_nwk_gp, hf, array_length(hf));
|
||||
|
|
Loading…
Reference in New Issue