diff options
author | Evan Huus <eapache@gmail.com> | 2012-09-08 15:03:07 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2012-09-08 15:03:07 +0000 |
commit | d574361f5cbd248a0103cebabd9347cec968fdbc (patch) | |
tree | 0ec95142d1f2028120f95ae36a5bfeadfe1dea60 /epan/packet.c | |
parent | f5428eddcd9d7f0091a44baa205f2f9b5a9dda5c (diff) |
Use g_hash_table_new_full() instead of g_hash_table_new() for subdissector
registration tables, and use g_free as the value_destroy_func. This saves us
from manually freeing the value when we remove an item, and prevents us from
leaking memory when we accidentally overwrite an existing item.
svn path=/trunk/; revision=44814
Diffstat (limited to 'epan/packet.c')
-rw-r--r-- | epan/packet.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/epan/packet.c b/epan/packet.c index 62f6668516..81d64f4bba 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -822,11 +822,6 @@ dissector_delete_uint(const char *name, const guint32 pattern, */ g_hash_table_remove(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern)); - - /* - * Now free up the entry. - */ - g_free(dtbl_entry); } } @@ -893,7 +888,6 @@ dissector_reset_uint(const char *name, const guint32 pattern) } else { g_hash_table_remove(sub_dissectors->hash_table, GUINT_TO_POINTER(pattern)); - g_free(dtbl_entry); } } @@ -1086,11 +1080,6 @@ dissector_delete_string(const char *name, const gchar *pattern, * Found - remove it. */ g_hash_table_remove(sub_dissectors->hash_table, pattern); - - /* - * Now free up the entry. - */ - g_free(dtbl_entry); } } @@ -1157,7 +1146,6 @@ dissector_reset_string(const char *name, const gchar *pattern) dtbl_entry->current = dtbl_entry->initial; } else { g_hash_table_remove(sub_dissectors->hash_table, pattern); - g_free(dtbl_entry); } } @@ -1568,14 +1556,18 @@ register_dissector_table(const char *name, const char *ui_name, const ftenum_t t * XXX - there's no "g_uint_hash()" or "g_uint_equal()", * so we use "g_direct_hash()" and "g_direct_equal()". */ - sub_dissectors->hash_table = g_hash_table_new( g_direct_hash, - g_direct_equal ); + sub_dissectors->hash_table = g_hash_table_new_full( g_direct_hash, + g_direct_equal, + NULL, + &g_free ); break; case FT_STRING: case FT_STRINGZ: - sub_dissectors->hash_table = g_hash_table_new( g_str_hash, - g_str_equal ); + sub_dissectors->hash_table = g_hash_table_new_full( g_str_hash, + g_str_equal, + NULL, + &g_free ); break; default: |