mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 06:33:21 -05:00
refactor use for loop to remove item from linked list
This commit is contained in:
parent
3886ec6638
commit
baffe49887
@ -51,27 +51,25 @@ listener_remove(notify notify_cb)
|
||||
struct listener *listener;
|
||||
struct listener *prev;
|
||||
|
||||
listener = listener_list;
|
||||
prev = NULL;
|
||||
|
||||
while (listener)
|
||||
for (listener = listener_list; listener; listener = listener->next)
|
||||
{
|
||||
if (listener->notify_cb == notify_cb)
|
||||
{
|
||||
if (prev)
|
||||
prev->next = listener->next;
|
||||
else
|
||||
listener_list = NULL;
|
||||
|
||||
free(listener);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
prev = listener;
|
||||
listener = listener->next;
|
||||
}
|
||||
|
||||
return -1;
|
||||
if (!listener)
|
||||
return 0;
|
||||
|
||||
if (prev)
|
||||
prev->next = listener->next;
|
||||
else
|
||||
listener_list = NULL;
|
||||
|
||||
free(listener);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
x
Reference in New Issue
Block a user