diff options
-rw-r--r-- | epan/dissectors/packet-6lowpan.c | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-beep.c | 14 | ||||
-rw-r--r-- | epan/dissectors/packet-dcerpc.c | 28 | ||||
-rw-r--r-- | epan/dissectors/packet-dcm.c | 42 | ||||
-rw-r--r-- | epan/dissectors/packet-epl.c | 7 | ||||
-rw-r--r-- | epan/dissectors/packet-ieee802154.c | 17 | ||||
-rw-r--r-- | epan/dissectors/packet-ipsec.c | 27 | ||||
-rw-r--r-- | epan/dissectors/packet-isakmp.c | 41 | ||||
-rw-r--r-- | epan/dissectors/packet-mac-lte.c | 64 | ||||
-rw-r--r-- | epan/dissectors/packet-opensafety.c | 11 | ||||
-rw-r--r-- | epan/dissectors/packet-sigcomp.c | 22 | ||||
-rw-r--r-- | epan/dissectors/packet-sip.c | 33 | ||||
-rw-r--r-- | epan/dissectors/packet-umts_mac.c | 14 |
13 files changed, 152 insertions, 176 deletions
diff --git a/epan/dissectors/packet-6lowpan.c b/epan/dissectors/packet-6lowpan.c index feb8407ccb..566e2b1be1 100644 --- a/epan/dissectors/packet-6lowpan.c +++ b/epan/dissectors/packet-6lowpan.c @@ -473,6 +473,7 @@ struct lowpan_nhdr { /* Dissector prototypes */ static void proto_init_6lowpan (void); +static void proto_cleanup_6lowpan(void); static void prefs_6lowpan_apply (void); static int dissect_6lowpan (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data); static tvbuff_t * dissect_6lowpan_ipv6 (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); @@ -2805,6 +2806,7 @@ proto_register_6lowpan(void) /* Register the dissector init function */ register_init_routine(proto_init_6lowpan); + register_cleanup_routine(proto_cleanup_6lowpan); /* Initialize the context preferences. */ memset((gchar*)lowpan_context_prefs, 0, sizeof(lowpan_context_prefs)); @@ -2854,6 +2856,12 @@ proto_init_6lowpan(void) prefs_6lowpan_apply(); } /* proto_init_6lowpan */ +static void +proto_cleanup_6lowpan(void) +{ + reassembly_table_destroy(&lowpan_reassembly_table); +} + /*FUNCTION:------------------------------------------------------ * NAME * prefs_6lowpan_apply diff --git a/epan/dissectors/packet-beep.c b/epan/dissectors/packet-beep.c index 29223d3c96..e0422a7123 100644 --- a/epan/dissectors/packet-beep.c +++ b/epan/dissectors/packet-beep.c @@ -193,16 +193,15 @@ beep_hash(gconstpointer v) static void beep_init_protocol(void) { -#if defined(DEBUG_BEEP_HASH) - fprintf(stderr, "Initializing BEEP hashtable area\n"); -#endif - - if (beep_request_hash) - g_hash_table_destroy(beep_request_hash); - beep_request_hash = g_hash_table_new(beep_hash, beep_equal); } +static void +beep_cleanup_protocol(void) +{ + g_hash_table_destroy(beep_request_hash); +} + /* dissect the more flag, and return a value of: * 1 -> more @@ -989,6 +988,7 @@ proto_register_beep(void) expert_beep = expert_register_protocol(proto_beep); expert_register_field_array(expert_beep, ei, array_length(ei)); register_init_routine(&beep_init_protocol); + register_cleanup_routine(&beep_cleanup_protocol); /* Register our configuration options for BEEP, particularly our port */ diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c index 46bca0bfce..695aa4484b 100644 --- a/epan/dissectors/packet-dcerpc.c +++ b/epan/dissectors/packet-dcerpc.c @@ -6097,33 +6097,26 @@ static void dcerpc_init_protocol(void) { /* structures and data for BIND */ - if (dcerpc_binds) { - g_hash_table_destroy(dcerpc_binds); - dcerpc_binds = NULL; - } - if (!dcerpc_binds) { - dcerpc_binds = g_hash_table_new(dcerpc_bind_hash, dcerpc_bind_equal); - } + dcerpc_binds = g_hash_table_new(dcerpc_bind_hash, dcerpc_bind_equal); /* structures and data for CALL */ - if (dcerpc_cn_calls) { - g_hash_table_destroy(dcerpc_cn_calls); - } dcerpc_cn_calls = g_hash_table_new(dcerpc_cn_call_hash, dcerpc_cn_call_equal); - if (dcerpc_dg_calls) { - g_hash_table_destroy(dcerpc_dg_calls); - } dcerpc_dg_calls = g_hash_table_new(dcerpc_dg_call_hash, dcerpc_dg_call_equal); /* structure and data for MATCHED */ - if (dcerpc_matched) { - g_hash_table_destroy(dcerpc_matched); - } dcerpc_matched = g_hash_table_new(dcerpc_matched_hash, dcerpc_matched_equal); - decode_dcerpc_inject_bindings(); } +static void +dcerpc_cleanup_protocol(void) +{ + g_hash_table_destroy(dcerpc_binds); + g_hash_table_destroy(dcerpc_cn_calls); + g_hash_table_destroy(dcerpc_dg_calls); + g_hash_table_destroy(dcerpc_matched); +} + void proto_register_dcerpc(void) { @@ -6521,6 +6514,7 @@ proto_register_dcerpc(void) expert_register_field_array(expert_dcerpc, ei, array_length(ei)); register_init_routine(dcerpc_init_protocol); + register_cleanup_routine(dcerpc_cleanup_protocol); dcerpc_module = prefs_register_protocol(proto_dcerpc, NULL); prefs_register_bool_preference(dcerpc_module, "desegment_dcerpc", diff --git a/epan/dissectors/packet-dcm.c b/epan/dissectors/packet-dcm.c index 999b9031fe..73b0b5ae3c 100644 --- a/epan/dissectors/packet-dcm.c +++ b/epan/dissectors/packet-dcm.c @@ -3957,36 +3957,30 @@ static void dcm_set_syntax (dcm_state_pctx_t *pctx, gchar *xfer_uid static void dcm_export_create_object (packet_info *pinfo, dcm_state_assoc_t *assoc, dcm_state_pdv_t *pdv); static void - dcm_init(void) { guint i; + /* Create three hash tables for quick lookups */ /* Add UID objects to hash table */ - if (dcm_uid_table == NULL) { - dcm_uid_table = g_hash_table_new(g_str_hash, g_str_equal); - for (i = 0; i < array_length(dcm_uid_data); i++) { - g_hash_table_insert(dcm_uid_table, (gpointer) dcm_uid_data[i].value, - (gpointer) &dcm_uid_data[i]); - } + dcm_uid_table = g_hash_table_new(g_str_hash, g_str_equal); + for (i = 0; i < array_length(dcm_uid_data); i++) { + g_hash_table_insert(dcm_uid_table, (gpointer) dcm_uid_data[i].value, + (gpointer) &dcm_uid_data[i]); } /* Add Tag objects to hash table */ - if (dcm_tag_table == NULL) { - dcm_tag_table = g_hash_table_new(NULL, NULL); - for (i = 0; i < array_length(dcm_tag_data); i++) { - g_hash_table_insert(dcm_tag_table, GUINT_TO_POINTER(dcm_tag_data[i].tag), - (gpointer) &dcm_tag_data[i]); - } + dcm_tag_table = g_hash_table_new(NULL, NULL); + for (i = 0; i < array_length(dcm_tag_data); i++) { + g_hash_table_insert(dcm_tag_table, GUINT_TO_POINTER(dcm_tag_data[i].tag), + (gpointer) &dcm_tag_data[i]); } /* Add Status Values to hash table */ - if (dcm_status_table == NULL) { - dcm_status_table = g_hash_table_new(NULL, NULL); - for (i = 0; i < array_length(dcm_status_data); i++) { - g_hash_table_insert(dcm_status_table, GUINT_TO_POINTER((guint32)dcm_status_data[i].value), - (gpointer)&dcm_status_data[i]); - } + dcm_status_table = g_hash_table_new(NULL, NULL); + for (i = 0; i < array_length(dcm_status_data); i++) { + g_hash_table_insert(dcm_status_table, GUINT_TO_POINTER((guint32)dcm_status_data[i].value), + (gpointer)&dcm_status_data[i]); } /* Register processing of fragmented DICOM PDVs */ @@ -3994,6 +3988,15 @@ dcm_init(void) &addresses_reassembly_table_functions); } +static void +dcm_cleanup(void) +{ + reassembly_table_destroy(&dcm_pdv_reassembly_table); + g_hash_table_destroy(dcm_uid_table); + g_hash_table_destroy(dcm_tag_table); + g_hash_table_destroy(dcm_status_table); +} + static dcm_state_t * dcm_state_new(void) { @@ -7340,6 +7343,7 @@ proto_register_dcm(void) dicom_eo_tap = register_tap("dicom_eo"); /* DICOM Export Object tap */ register_init_routine(&dcm_init); + register_cleanup_routine(&dcm_cleanup); } void diff --git a/epan/dissectors/packet-epl.c b/epan/dissectors/packet-epl.c index 7d2c772090..821d42b65d 100644 --- a/epan/dissectors/packet-epl.c +++ b/epan/dissectors/packet-epl.c @@ -1651,6 +1651,12 @@ setup_dissector(void) reassembly_table_init(&epl_reassembly_table, &addresses_reassembly_table_functions); } +static void +cleanup_dissector(void) +{ + reassembly_table_destroy(&epl_reassembly_table); +} + /* preference whether or not display the SoC flags in info column */ gboolean show_soc_flags = FALSE; @@ -4320,6 +4326,7 @@ proto_reg_handoff_epl(void) /* register frame init routine */ register_init_routine( setup_dissector ); + register_cleanup_routine( cleanup_dissector ); } /* diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c index 944d6e6589..f115d4c18c 100644 --- a/epan/dissectors/packet-ieee802154.c +++ b/epan/dissectors/packet-ieee802154.c @@ -2381,22 +2381,22 @@ proto_init_ieee802154(void) { guint i; - /* Destroy hash tables, if they exist. */ - if (ieee802154_map.short_table) - g_hash_table_destroy(ieee802154_map.short_table); - if (ieee802154_map.long_table) - g_hash_table_destroy(ieee802154_map.long_table); - - /* Create the hash tables. */ ieee802154_map.short_table = g_hash_table_new(ieee802154_short_addr_hash, ieee802154_short_addr_equal); ieee802154_map.long_table = g_hash_table_new(ieee802154_long_addr_hash, ieee802154_long_addr_equal); - /* Re-load the hash table from the static address UAT. */ + /* Reload the hash table from the static address UAT. */ for (i=0; (i<num_static_addrs) && (static_addrs); i++) { ieee802154_addr_update(&ieee802154_map,(guint16)static_addrs[i].addr16, (guint16)static_addrs[i].pan, pntoh64(static_addrs[i].eui64), ieee802154_user, IEEE802154_USER_MAPPING); } /* for */ } /* proto_init_ieee802154 */ +static void +proto_cleanup_ieee802154(void) +{ + g_hash_table_destroy(ieee802154_map.short_table); + g_hash_table_destroy(ieee802154_map.long_table); +} + /* Returns the prompt string for the Decode-As dialog. */ static void ieee802154_da_prompt(packet_info *pinfo _U_, gchar* result) { @@ -2765,6 +2765,7 @@ void proto_register_ieee802154(void) /* Register the init routine. */ register_init_routine(proto_init_ieee802154); + register_cleanup_routine(proto_cleanup_ieee802154); /* Register Protocol name and description. */ proto_ieee802154 = proto_register_protocol("IEEE 802.15.4 Low-Rate Wireless PAN", "IEEE 802.15.4", diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c index b7cfac4bea..72a3a9628f 100644 --- a/epan/dissectors/packet-ipsec.c +++ b/epan/dissectors/packet-ipsec.c @@ -2307,6 +2307,12 @@ dissect_ipcomp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) static void ipsec_init_protocol(void) { + esp_sequence_analysis_hash = g_hash_table_new(word_hash_func, word_equal); + esp_sequence_analysis_report_hash = g_hash_table_new(word_hash_func, word_equal); +} + +static void ipsec_cleanup_protocol(void) +{ #ifdef HAVE_LIBGCRYPT /* Free any SA records added by other dissectors */ guint n; @@ -2315,25 +2321,13 @@ static void ipsec_init_protocol(void) } /* Free overall block of records */ - if (extra_esp_sa_records.num_records > 0) { - g_free(extra_esp_sa_records.records); - extra_esp_sa_records.records = NULL; - } + g_free(extra_esp_sa_records.records); + extra_esp_sa_records.records = NULL; extra_esp_sa_records.num_records = 0; - - /* Destroy any existing hashes. */ - if (esp_sequence_analysis_hash) { - g_hash_table_destroy(esp_sequence_analysis_hash); - } - if (esp_sequence_analysis_report_hash) { - g_hash_table_destroy(esp_sequence_analysis_report_hash); - } #endif - /* Now create them over */ - esp_sequence_analysis_hash = g_hash_table_new(word_hash_func, word_equal); - esp_sequence_analysis_report_hash = g_hash_table_new(word_hash_func, word_equal); - + g_hash_table_destroy(esp_sequence_analysis_hash); + g_hash_table_destroy(esp_sequence_analysis_report_hash); } void @@ -2543,6 +2537,7 @@ proto_register_ipsec(void) #endif register_init_routine(&ipsec_init_protocol); + register_cleanup_routine(&ipsec_cleanup_protocol); register_dissector("esp", dissect_esp, proto_esp); register_dissector("ah", dissect_ah, proto_ah); diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c index 4689cbf816..8e1202468b 100644 --- a/epan/dissectors/packet-isakmp.c +++ b/epan/dissectors/packet-isakmp.c @@ -5152,15 +5152,20 @@ static gint ikev2_key_equal_func(gconstpointer k1, gconstpointer k2) { #endif /* HAVE_LIBGCRYPT */ #ifdef HAVE_LIBGCRYPT -static gboolean -free_cookie(gpointer key_arg, gpointer value, gpointer user_data _U_) +static void +free_cookie_key(gpointer key_arg) { guint8 *ic_key = (guint8 *)key_arg; - decrypt_data_t *decr = (decrypt_data_t *)value; g_slice_free1(COOKIE_SIZE, ic_key); +} + +static void +free_cookie_value(gpointer value) +{ + decrypt_data_t *decr = (decrypt_data_t *)value; + g_slice_free1(sizeof(decrypt_data_t), decr); - return TRUE; } #endif @@ -5177,11 +5182,8 @@ isakmp_init_protocol(void) { &addresses_reassembly_table_functions); #ifdef HAVE_LIBGCRYPT - if (isakmp_hash) { - g_hash_table_foreach_remove(isakmp_hash, free_cookie, NULL); - g_hash_table_destroy(isakmp_hash); - } - isakmp_hash = g_hash_table_new(isakmp_hash_func, isakmp_equal_func); + isakmp_hash = g_hash_table_new_full(isakmp_hash_func, isakmp_equal_func, + free_cookie_key, free_cookie_value); for (i = 0; i < num_ikev1_uat_data; i++) { ic_key = (guint8 *)g_slice_alloc(COOKIE_SIZE); @@ -5194,23 +5196,25 @@ isakmp_init_protocol(void) { g_hash_table_insert(isakmp_hash, ic_key, decr); } - - if (ikev2_key_hash) { - g_hash_table_destroy(ikev2_key_hash); - } - ikev2_key_hash = g_hash_table_new(ikev2_key_hash_func, ikev2_key_equal_func); for (i = 0; i < num_ikev2_uat_data; i++) { g_hash_table_insert(ikev2_key_hash, &(ikev2_uat_data[i].key), &(ikev2_uat_data[i])); } - - if (defrag_next_payload_hash) { - g_hash_table_destroy(defrag_next_payload_hash); - } defrag_next_payload_hash = g_hash_table_new(g_direct_hash, g_direct_equal); #endif /* HAVE_LIBGCRYPT */ } +static void +isakmp_cleanup_protocol(void) { + reassembly_table_destroy(&isakmp_cisco_reassembly_table); + reassembly_table_destroy(&isakmp_ike2_reassembly_table); +#ifdef HAVE_LIBGCRYPT + g_hash_table_destroy(isakmp_hash); + g_hash_table_destroy(ikev2_key_hash); + g_hash_table_destroy(defrag_next_payload_hash); +#endif /* HAVE_LIBGCRYPT */ +} + #ifdef HAVE_LIBGCRYPT static void isakmp_prefs_apply_cb(void) { @@ -6455,6 +6459,7 @@ proto_register_isakmp(void) expert_isakmp = expert_register_protocol(proto_isakmp); expert_register_field_array(expert_isakmp, ei, array_length(ei)); register_init_routine(&isakmp_init_protocol); + register_cleanup_routine(&isakmp_cleanup_protocol); new_register_dissector("isakmp", dissect_isakmp, proto_isakmp); diff --git a/epan/dissectors/packet-mac-lte.c b/epan/dissectors/packet-mac-lte.c index 91872691d0..cecf827fb1 100644 --- a/epan/dissectors/packet-mac-lte.c +++ b/epan/dissectors/packet-mac-lte.c @@ -5965,76 +5965,45 @@ int dissect_mac_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d * file is loaded or re-loaded in wireshark */ static void mac_lte_init_protocol(void) { - /* Destroy any existing tables. */ - if (mac_lte_msg3_hash) { - g_hash_table_destroy(mac_lte_msg3_hash); - } - if (mac_lte_cr_result_hash) { - g_hash_table_destroy(mac_lte_cr_result_hash); - } - - if (mac_lte_dl_harq_hash) { - g_hash_table_destroy(mac_lte_dl_harq_hash); - } - if (mac_lte_dl_harq_result_hash) { - g_hash_table_destroy(mac_lte_dl_harq_result_hash); - } - if (mac_lte_ul_harq_hash) { - g_hash_table_destroy(mac_lte_ul_harq_hash); - } - if (mac_lte_ul_harq_result_hash) { - g_hash_table_destroy(mac_lte_ul_harq_result_hash); - } - if (mac_lte_ue_sr_state) { - g_hash_table_destroy(mac_lte_ue_sr_state); - } - if (mac_lte_sr_request_hash) { - g_hash_table_destroy(mac_lte_sr_request_hash); - } - if (mac_lte_tti_info_result_hash) { - g_hash_table_destroy(mac_lte_tti_info_result_hash); - } - if (mac_lte_ue_channels_hash) { - g_hash_table_destroy(mac_lte_ue_channels_hash); - } - if (mac_lte_ue_parameters) { - g_hash_table_destroy(mac_lte_ue_parameters); - } - if (mac_lte_drx_frame_result) { - g_hash_table_destroy(mac_lte_drx_frame_result); - } - /* Reset structs */ memset(&UL_tti_info, 0, sizeof(UL_tti_info)); UL_tti_info.subframe = 0xff; /* Invalid value */ memset(&DL_tti_info, 0, sizeof(DL_tti_info)); DL_tti_info.subframe = 0xff; /* Invalid value */ - /* Now create them over */ mac_lte_msg3_hash = g_hash_table_new(g_direct_hash, g_direct_equal); mac_lte_cr_result_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_dl_harq_hash = g_hash_table_new(g_direct_hash, g_direct_equal); mac_lte_dl_harq_result_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_ul_harq_hash = g_hash_table_new(g_direct_hash, g_direct_equal); mac_lte_ul_harq_result_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_ue_sr_state = g_hash_table_new(g_direct_hash, g_direct_equal); mac_lte_sr_request_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_tti_info_result_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_ue_channels_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_ue_parameters = g_hash_table_new(g_direct_hash, g_direct_equal); - mac_lte_drx_frame_result = g_hash_table_new(mac_lte_framenum_instance_hash_func, mac_lte_framenum_instance_hash_equal); /* Forget this setting */ s_rapid_ranges_configured = FALSE; } +static void mac_lte_cleanup_protocol(void) +{ + g_hash_table_destroy(mac_lte_msg3_hash); + g_hash_table_destroy(mac_lte_cr_result_hash); + g_hash_table_destroy(mac_lte_dl_harq_hash); + g_hash_table_destroy(mac_lte_dl_harq_result_hash); + g_hash_table_destroy(mac_lte_ul_harq_hash); + g_hash_table_destroy(mac_lte_ul_harq_result_hash); + g_hash_table_destroy(mac_lte_ue_sr_state); + g_hash_table_destroy(mac_lte_sr_request_hash); + g_hash_table_destroy(mac_lte_tti_info_result_hash); + g_hash_table_destroy(mac_lte_ue_channels_hash); + g_hash_table_destroy(mac_lte_ue_parameters); + g_hash_table_destroy(mac_lte_drx_frame_result); +} + /* Callback used as part of configuring a channel mapping using UAT */ static void* lcid_drb_mapping_copy_cb(void* dest, const void* orig, size_t len _U_) { @@ -7636,6 +7605,7 @@ void proto_register_mac_lte(void) &global_mac_lte_show_BSR_median); register_init_routine(&mac_lte_init_protocol); + register_cleanup_routine(&mac_lte_cleanup_protocol); } void proto_reg_handoff_mac_lte(void) diff --git a/epan/dissectors/packet-opensafety.c b/epan/dissectors/packet-opensafety.c index 1a7b60cce7..f24ffc4dc6 100644 --- a/epan/dissectors/packet-opensafety.c +++ b/epan/dissectors/packet-opensafety.c @@ -292,12 +292,16 @@ reset_dissector(void) static void setup_dissector(void) { - if ( local_scm_udid != NULL ) - local_scm_udid = NULL; - reassembly_table_init(&os_reassembly_table, &addresses_reassembly_table_functions); } +static void +cleanup_dissector(void) +{ + local_scm_udid = NULL; + reassembly_table_destroy(&os_reassembly_table); +} + void proto_register_opensafety(void); void proto_reg_handoff_opensafety(void); @@ -2832,6 +2836,7 @@ proto_reg_handoff_opensafety(void) apply_prefs(); register_init_routine ( setup_dissector ); + register_cleanup_routine ( cleanup_dissector ); /* registering frame end routine, to prevent a malformed dissection preventing * further dissector calls (see bug #6950) */ diff --git a/epan/dissectors/packet-sigcomp.c b/epan/dissectors/packet-sigcomp.c index eaec708592..b122b208cb 100644 --- a/epan/dissectors/packet-sigcomp.c +++ b/epan/dissectors/packet-sigcomp.c @@ -865,16 +865,8 @@ static GHashTable *state_buffer_table=NULL; static void sigcomp_init_udvm(void) { - gchar *partial_state_str; guint8 *sip_sdp_buff, *presence_buff; - - /* Destroy any existing memory chunks / hashes. */ - if (state_buffer_table) { - g_hash_table_destroy(state_buffer_table); - } - - state_buffer_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, /* key_destroy_func */ @@ -885,10 +877,6 @@ sigcomp_init_udvm(void) { sip_sdp_buff = (guint8 *)g_malloc(SIP_SDP_STATE_LENGTH + 8); partial_state_str = bytes_to_str(NULL, sip_sdp_state_identifier, 6); - - /* - * Debug g_warning("Sigcomp init: Storing partial state =%s",partial_state_str); - */ memset(sip_sdp_buff, 0, 8); sip_sdp_buff[0] = SIP_SDP_STATE_LENGTH >> 8; sip_sdp_buff[1] = SIP_SDP_STATE_LENGTH & 0xff; @@ -896,10 +884,6 @@ sigcomp_init_udvm(void) { g_hash_table_insert(state_buffer_table, g_strdup(partial_state_str), sip_sdp_buff); wmem_free(NULL, partial_state_str); - /* Debug - * g_warning("g_hash_table_insert = 0x%x",sip_sdp_buff); - * g_warning("g_hash_table_insert = 0x%x",sip_sdp_buff); - */ presence_buff = (guint8 *)g_malloc(PRESENCE_STATE_LENGTH + 8); @@ -914,6 +898,11 @@ sigcomp_init_udvm(void) { wmem_free(NULL, partial_state_str); } +static void +sigcomp_cleanup_udvm(void) { + g_hash_table_destroy(state_buffer_table); +} + static int udvm_state_access(tvbuff_t *tvb, proto_tree *tree,guint8 *buff,guint16 p_id_start, guint16 p_id_length, guint16 state_begin, guint16 *state_length, guint16 *state_address, guint16 *state_instruction, @@ -6676,6 +6665,7 @@ proto_register_sigcomp(void) &udvm_print_detail_level, udvm_detail_vals, FALSE); register_init_routine(&sigcomp_init_udvm); + register_cleanup_routine(&sigcomp_cleanup_udvm); diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c index 532c8443db..d843ebdb86 100644 --- a/epan/dissectors/packet-sip.c +++ b/epan/dissectors/packet-sip.c @@ -1017,27 +1017,23 @@ sip_init_protocol(void) { guint i; gchar *value_copy; - - /* Destroy any existing hashes. */ - if (sip_hash) - g_hash_table_destroy(sip_hash); - - /* Now create them again */ sip_hash = g_hash_table_new(g_str_hash , sip_equal); - /* Create a hashtable with the SIP headers; it will be used to find the related hf entry (POS_x). - * This is faster than the previously used for loop. - * There is no g_hash_table_destroy as the lifetime is the same as the lifetime of Wireshark. - */ - if(!sip_headers_hash){ - sip_headers_hash = g_hash_table_new(g_str_hash , g_str_equal); - for (i = 1; i < array_length(sip_headers); i++){ - value_copy = g_strdup (sip_headers[i].name); - /* Store (and compare) the string in lower case) */ - ascii_strdown_inplace(value_copy); - g_hash_table_insert(sip_headers_hash, (gpointer)value_copy, GINT_TO_POINTER(i)); - } + + /* Hash table for quick lookup of SIP headers names to hf entry (POS_x) */ + sip_headers_hash = g_hash_table_new(g_str_hash , g_str_equal); + for (i = 1; i < array_length(sip_headers); i++){ + value_copy = wmem_strdup(wmem_file_scope(), sip_headers[i].name); + ascii_strdown_inplace(value_copy); + g_hash_table_insert(sip_headers_hash, (gpointer)value_copy, GINT_TO_POINTER(i)); } } + +static void +sip_cleanup_protocol(void) +{ + g_hash_table_destroy(sip_hash); + g_hash_table_destroy(sip_headers_hash); +} /* Call the export PDU tap with relevant data */ static void export_sip_pdu(packet_info *pinfo, tvbuff_t *tvb) @@ -6094,6 +6090,7 @@ void proto_register_sip(void) prefs_register_obsolete_preference(sip_module, "tcp.port"); register_init_routine(&sip_init_protocol); + register_cleanup_routine(&sip_cleanup_protocol); heur_subdissector_list = register_heur_dissector_list("sip"); /* Register for tapping */ sip_tap = register_tap("sip"); diff --git a/epan/dissectors/packet-umts_mac.c b/epan/dissectors/packet-umts_mac.c index d9b4afc534..ea338601f6 100644 --- a/epan/dissectors/packet-umts_mac.c +++ b/epan/dissectors/packet-umts_mac.c @@ -1273,15 +1273,8 @@ static void mac_is_sdus_hash_destroy(gpointer data) static void mac_init(void) { - if (mac_is_sdus != NULL) { - g_hash_table_destroy(mac_is_sdus); - } - if (mac_is_fragments != NULL) { - g_hash_table_destroy(mac_is_fragments); - } mac_is_sdus = g_hash_table_new_full(mac_is_channel_hash, mac_is_channel_equal, NULL, mac_is_sdus_hash_destroy); mac_is_fragments = g_hash_table_new_full(mac_is_channel_hash, mac_is_channel_equal, NULL, NULL); - if (global_mac_tsn_size == MAC_TSN_6BITS) { MAX_TSN = 64; mac_tsn_size = 6; @@ -1291,6 +1284,12 @@ static void mac_init(void) } } +static void mac_cleanup(void) +{ + g_hash_table_destroy(mac_is_sdus); + g_hash_table_destroy(mac_is_fragments); +} + void proto_register_umts_mac(void) { @@ -1471,6 +1470,7 @@ proto_register_umts_mac(void) register_dissector("mac.fdd.hsdsch", dissect_mac_fdd_hsdsch, proto_umts_mac); register_init_routine(mac_init); + register_cleanup_routine(mac_cleanup); /* Preferences */ mac_module = prefs_register_protocol(proto_umts_mac, NULL); |