summaryrefslogtreecommitdiff
path: root/epan/tap.c
diff options
context:
space:
mode:
authorAndersBroman <anders.broman@ericsson.com>2016-09-28 12:09:58 +0200
committerAnders Broman <a.broman58@gmail.com>2016-09-28 12:36:26 +0000
commit148e4f77e9d528466e51d47c64acce106c5be0e7 (patch)
treeecddd441c87adcae43bbd3856a4f5103242406bd /epan/tap.c
parent152e245804397bfcd0fc3e4cfac22e1d49b0b169 (diff)
downloadwireshark-148e4f77e9d528466e51d47c64acce106c5be0e7.tar.gz
When regestering taps, only loop trough the list of taps once when adding
new taps. Change-Id: Ida5ad2375c95664ee1b911d265cb69672db2be2d Reviewed-on: https://code.wireshark.org/review/17964 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/tap.c')
-rw-r--r--epan/tap.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/epan/tap.c b/epan/tap.c
index 07d49ee489..fc626db039 100644
--- a/epan/tap.c
+++ b/epan/tap.c
@@ -214,13 +214,19 @@ tap_init(void)
int
register_tap(const char *name)
{
- tap_dissector_t *td, *tdl;
- int i, tap_id;
+ tap_dissector_t *td, *tdl = NULL, *tdl_prev;
+ int i=0;
if(tap_dissector_list){
- tap_id=find_tap_id(name);
- if (tap_id)
- return tap_id;
+ /* Check if we allready have the name registered, if it is return the tap_id of that tap.
+ * After the for loop tdl_prev will point to the last element of the list, add the new one there.
+ */
+ for (i = 1, tdl = tap_dissector_list; tdl; i++, tdl_prev = tdl, tdl = tdl->next) {
+ if (!strcmp(tdl->name, name)) {
+ return i;
+ }
+ }
+ tdl = tdl_prev;
}
td=(tap_dissector_t *)g_malloc(sizeof(tap_dissector_t));
@@ -231,8 +237,6 @@ register_tap(const char *name)
tap_dissector_list=td;
i=1;
} else {
- for(i=2,tdl=tap_dissector_list;tdl->next;i++,tdl=tdl->next)
- ;
tdl->next=td;
}
return i;