forked from osmocom/wireshark
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>
This commit is contained in:
parent
152e245804
commit
148e4f77e9
18
epan/tap.c
18
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;
|
||||
|
|
Loading…
Reference in New Issue