diff options
author | Michael Mann <mmann78@netscape.net> | 2017-01-02 16:24:41 -0500 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-01-02 23:16:34 +0000 |
commit | ab075d356342b1f652ec56cf178104e16f68f4dd (patch) | |
tree | 50e6a5b7e65c2868cac0b42c6fac7f8f08e19250 /epan/packet.c | |
parent | c950ebdd0fe3938c4e8087ef1bce6d365d9de1f6 (diff) |
Use g_slist_find_custom instead of g_slist_nth when just looking for item in list.
Change-Id: Ida3c5d5826f0ca01a25052a67f1460ff4686008f
Reviewed-on: https://code.wireshark.org/review/19513
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/packet.c')
-rw-r--r-- | epan/packet.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/epan/packet.c b/epan/packet.c index 67ebb65f4b..56b64e62b8 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -3046,11 +3046,18 @@ void call_heur_dissector_direct(heur_dtbl_entry_t *heur_dtbl_entry, tvbuff_t *tv } +static gint +find_matching_proto_name(gconstpointer arg1, gconstpointer arg2) +{ + const char *protocol_name = (const char*)arg1; + const gchar *name = (const gchar *)arg2; + + return strcmp(protocol_name, name); +} + gboolean register_depend_dissector(const char* parent, const char* dependent) { - guint i, list_size; GSList *list_entry; - const char *protocol_name; depend_dissector_list_t sub_dissectors; if ((parent == NULL) || (dependent == NULL)) @@ -3068,14 +3075,9 @@ gboolean register_depend_dissector(const char* parent, const char* dependent) } /* Verify that sub-dissector is not already in the list */ - list_size = g_slist_length(sub_dissectors->dissectors); - for (i = 0; i < list_size; i++) - { - list_entry = g_slist_nth(sub_dissectors->dissectors, i); - protocol_name = (const char*)list_entry->data; - if (strcmp(dependent, protocol_name) == 0) - return TRUE; /* Dependency already exists */ - } + list_entry = g_slist_find_custom(sub_dissectors->dissectors, (gpointer)dependent, find_matching_proto_name); + if (list_entry != NULL) + return TRUE; /* Dependency already exists */ sub_dissectors->dissectors = g_slist_prepend(sub_dissectors->dissectors, (gpointer)g_strdup(dependent)); return TRUE; |