Create the dissector hash table in only one place, and specify that its values
should be freed when it is destroyed. This requires splitting packet_init in two: the hash table which must be created before protocol registration, and the caching of common protocol handles, which must happen after registration. svn path=/trunk/; revision=51329
This commit is contained in:
parent
14b098baf7
commit
a2b2885daf
|
@ -108,9 +108,10 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
|
|||
tap_init();
|
||||
prefs_init();
|
||||
expert_init();
|
||||
packet_init();
|
||||
proto_init(register_all_protocols_func, register_all_handoffs_func,
|
||||
cb, client_data);
|
||||
packet_init();
|
||||
packet_cache_proto_handles();
|
||||
dfilter_init();
|
||||
final_registration_all_protocols();
|
||||
expert_packet_init();
|
||||
|
|
|
@ -110,6 +110,13 @@ static GHashTable *heur_dissector_lists = NULL;
|
|||
|
||||
void
|
||||
packet_init(void)
|
||||
{
|
||||
registered_dissectors = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||
NULL, g_free);
|
||||
}
|
||||
|
||||
void
|
||||
packet_cache_proto_handles(void)
|
||||
{
|
||||
frame_handle = find_dissector("frame");
|
||||
g_assert(frame_handle != NULL);
|
||||
|
@ -2000,12 +2007,6 @@ register_dissector(const char *name, dissector_t dissector, const int proto)
|
|||
{
|
||||
struct dissector_handle *handle;
|
||||
|
||||
/* Create our hash table if it doesn't already exist */
|
||||
if (registered_dissectors == NULL) {
|
||||
registered_dissectors = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
g_assert(registered_dissectors != NULL);
|
||||
}
|
||||
|
||||
/* Make sure the registration is unique */
|
||||
g_assert(g_hash_table_lookup(registered_dissectors, name) == NULL);
|
||||
|
||||
|
@ -2026,12 +2027,6 @@ new_register_dissector(const char *name, new_dissector_t dissector, const int pr
|
|||
{
|
||||
struct dissector_handle *handle;
|
||||
|
||||
/* Create our hash table if it doesn't already exist */
|
||||
if (registered_dissectors == NULL) {
|
||||
registered_dissectors = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
g_assert(registered_dissectors != NULL);
|
||||
}
|
||||
|
||||
/* Make sure the registration is unique */
|
||||
g_assert(g_hash_table_lookup(registered_dissectors, name) == NULL);
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ typedef struct _packet_counts {
|
|||
#define PACKET_COUNTS_SIZE sizeof(packet_counts) / sizeof (gint)
|
||||
|
||||
extern void packet_init(void);
|
||||
extern void packet_cache_proto_handles(void);
|
||||
extern void packet_cleanup(void);
|
||||
|
||||
/* Handle for dissectors you call directly or register with "dissector_add_uint()".
|
||||
|
|
Loading…
Reference in New Issue