diff options
author | Evan Huus <eapache@gmail.com> | 2013-08-13 03:11:28 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2013-08-13 03:11:28 +0000 |
commit | a2b2885daf8c4a6dd9b4beda67d2d47ce974999d (patch) | |
tree | b0b2f51350dc676e5a15edceb19fcefe14436153 /epan/packet.c | |
parent | 14b098baf7ac4ba8382b4038fd717b5e186c03b8 (diff) | |
download | wireshark-a2b2885daf8c4a6dd9b4beda67d2d47ce974999d.tar.gz |
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
Diffstat (limited to 'epan/packet.c')
-rw-r--r-- | epan/packet.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/epan/packet.c b/epan/packet.c index cdf9cb96c9..9052dc558a 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -111,6 +111,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); |