This method will add a node to the end of the list. BUG=b:179699789 TEST=Boot guybrush to the OS Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I1792e40f789e3ef16ceca65ce4cae946e08583d1 Reviewed-on: https://review.coreboot.org/c/coreboot/+/58805 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
39 lines
788 B
C
39 lines
788 B
C
/* Taken from depthcharge: src/base/list.c */
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#include <list.h>
|
|
|
|
void list_remove(struct list_node *node)
|
|
{
|
|
if (node->prev)
|
|
node->prev->next = node->next;
|
|
if (node->next)
|
|
node->next->prev = node->prev;
|
|
}
|
|
|
|
void list_insert_after(struct list_node *node, struct list_node *after)
|
|
{
|
|
node->next = after->next;
|
|
node->prev = after;
|
|
after->next = node;
|
|
if (node->next)
|
|
node->next->prev = node;
|
|
}
|
|
|
|
void list_insert_before(struct list_node *node, struct list_node *before)
|
|
{
|
|
node->prev = before->prev;
|
|
node->next = before;
|
|
before->prev = node;
|
|
if (node->prev)
|
|
node->prev->next = node;
|
|
}
|
|
|
|
void list_append(struct list_node *node, struct list_node *head)
|
|
{
|
|
while (head->next)
|
|
head = head->next;
|
|
|
|
list_insert_after(node, head);
|
|
}
|