remove insert helper function from list.c
This commit is contained in:
parent
7d0353b1d7
commit
13df16bf59
35
src/list.c
35
src/list.c
|
@ -6,24 +6,6 @@ void rt_list_init(struct rt_list *list)
|
|||
list->next = list;
|
||||
}
|
||||
|
||||
static void insert(struct rt_list *node, struct rt_list *prev,
|
||||
struct rt_list *next)
|
||||
{
|
||||
next->prev = node;
|
||||
prev->next = node;
|
||||
node->prev = prev;
|
||||
node->next = next;
|
||||
}
|
||||
|
||||
void rt_list_remove(struct rt_list *node)
|
||||
{
|
||||
struct rt_list *const next = node->next, *const prev = node->prev;
|
||||
node->prev = node;
|
||||
node->next = node;
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
bool rt_list_is_empty(const struct rt_list *list)
|
||||
{
|
||||
return list->next == list;
|
||||
|
@ -36,7 +18,20 @@ struct rt_list *rt_list_front(const struct rt_list *list)
|
|||
|
||||
void rt_list_push_back(struct rt_list *list, struct rt_list *node)
|
||||
{
|
||||
insert(node, list->prev, list);
|
||||
struct rt_list *const prev = list->prev;
|
||||
list->prev = node;
|
||||
prev->next = node;
|
||||
node->prev = prev;
|
||||
node->next = list;
|
||||
}
|
||||
|
||||
void rt_list_remove(struct rt_list *node)
|
||||
{
|
||||
struct rt_list *const next = node->next, *const prev = node->prev;
|
||||
node->prev = node;
|
||||
node->next = node;
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
void rt_list_insert_by(struct rt_list *list, struct rt_list *node,
|
||||
|
@ -51,5 +46,5 @@ void rt_list_insert_by(struct rt_list *list, struct rt_list *node,
|
|||
break;
|
||||
}
|
||||
}
|
||||
insert(node, next->prev, next);
|
||||
rt_list_push_back(next, node);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue