mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
Optimization in igmp_remove_group() pointed out by Axel Lin
No need to handle special case "first in list" since this is always the allsystems group that shall not be removed
This commit is contained in:
parent
102a50fa96
commit
5c1dd6a4c6
@ -295,24 +295,24 @@ static err_t
|
|||||||
igmp_remove_group(struct netif* netif, struct igmp_group *group)
|
igmp_remove_group(struct netif* netif, struct igmp_group *group)
|
||||||
{
|
{
|
||||||
err_t err = ERR_OK;
|
err_t err = ERR_OK;
|
||||||
|
struct igmp_group *tmp_group = netif_igmp_data(netif);
|
||||||
|
|
||||||
|
/* Skip the first group in the list, it is always the allsystems group added in igmp_start() */
|
||||||
|
if(tmp_group != NULL) {
|
||||||
|
tmp_group = tmp_group->next;
|
||||||
|
}
|
||||||
|
|
||||||
/* Is it the first group? */
|
|
||||||
if (netif_igmp_data(netif) == group) {
|
|
||||||
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_IGMP, group->next);
|
|
||||||
} else {
|
|
||||||
/* look for group further down the list */
|
/* look for group further down the list */
|
||||||
struct igmp_group *tmpGroup;
|
for (; tmp_group != NULL; tmp_group = tmp_group->next) {
|
||||||
for (tmpGroup = netif_igmp_data(netif); tmpGroup != NULL; tmpGroup = tmpGroup->next) {
|
if (tmp_group->next == group) {
|
||||||
if (tmpGroup->next == group) {
|
tmp_group->next = group->next;
|
||||||
tmpGroup->next = group->next;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Group not found in the global igmp_group_list */
|
/* Group not found in the global igmp_group_list */
|
||||||
if (tmpGroup == NULL) {
|
if (tmp_group == NULL) {
|
||||||
err = ERR_ARG;
|
err = ERR_ARG;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user