mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 23:28:10 +00:00
add comments clarifying the operation of listnode_add_sort
This commit is contained in:
parent
1f431d2d98
commit
297602162c
@ -80,7 +80,12 @@ listnode_add (struct list *list, void *val)
|
|||||||
list->count++;
|
list->count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add new node with sort function. */
|
/*
|
||||||
|
* Add a node to the list. If the list was sorted according to the
|
||||||
|
* cmp function, insert a new node with the given val such that the
|
||||||
|
* list remains sorted. The new node is always inserted; there is no
|
||||||
|
* notion of omitting duplicates.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
listnode_add_sort (struct list *list, void *val)
|
listnode_add_sort (struct list *list, void *val)
|
||||||
{
|
{
|
||||||
@ -94,6 +99,7 @@ listnode_add_sort (struct list *list, void *val)
|
|||||||
{
|
{
|
||||||
for (n = list->head; n; n = n->next)
|
for (n = list->head; n; n = n->next)
|
||||||
{
|
{
|
||||||
|
/* XXX should an "equal" node be inserted before or after? */
|
||||||
if ((*list->cmp) (val, n->data) <= 0)
|
if ((*list->cmp) (val, n->data) <= 0)
|
||||||
{
|
{
|
||||||
new->next = n;
|
new->next = n;
|
||||||
|
Loading…
Reference in New Issue
Block a user