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
|
int
|
||||||
register_tap(const char *name)
|
register_tap(const char *name)
|
||||||
{
|
{
|
||||||
tap_dissector_t *td, *tdl;
|
tap_dissector_t *td, *tdl = NULL, *tdl_prev;
|
||||||
int i, tap_id;
|
int i=0;
|
||||||
|
|
||||||
if(tap_dissector_list){
|
if(tap_dissector_list){
|
||||||
tap_id=find_tap_id(name);
|
/* Check if we allready have the name registered, if it is return the tap_id of that tap.
|
||||||
if (tap_id)
|
* After the for loop tdl_prev will point to the last element of the list, add the new one there.
|
||||||
return tap_id;
|
*/
|
||||||
|
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));
|
td=(tap_dissector_t *)g_malloc(sizeof(tap_dissector_t));
|
||||||
|
@ -231,8 +237,6 @@ register_tap(const char *name)
|
||||||
tap_dissector_list=td;
|
tap_dissector_list=td;
|
||||||
i=1;
|
i=1;
|
||||||
} else {
|
} else {
|
||||||
for(i=2,tdl=tap_dissector_list;tdl->next;i++,tdl=tdl->next)
|
|
||||||
;
|
|
||||||
tdl->next=td;
|
tdl->next=td;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
|
Loading…
Reference in New Issue