You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.0 KiB
57 lines
1.0 KiB
4 years ago
|
#include "webfuse_provider/impl/util/slist.h"
|
||
6 years ago
|
#include <stddef.h>
|
||
|
|
||
4 years ago
|
void wfp_slist_init(
|
||
|
struct wfp_slist * list)
|
||
6 years ago
|
{
|
||
5 years ago
|
list->head.next = NULL;
|
||
|
list->last = &list->head;
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
bool wfp_slist_empty(
|
||
|
struct wfp_slist * list)
|
||
6 years ago
|
{
|
||
5 years ago
|
return (list->last == &list->head);
|
||
|
}
|
||
|
|
||
4 years ago
|
struct wfp_slist_item * wfp_slist_first(
|
||
|
struct wfp_slist * list)
|
||
5 years ago
|
{
|
||
|
return list->head.next;
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
void wfp_slist_append(
|
||
|
struct wfp_slist * list,
|
||
|
struct wfp_slist_item * item)
|
||
6 years ago
|
{
|
||
|
item->next = NULL;
|
||
5 years ago
|
list->last->next = item;
|
||
|
list->last = item;
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
struct wfp_slist_item * wfp_slist_remove_first(
|
||
|
struct wfp_slist * list)
|
||
6 years ago
|
{
|
||
4 years ago
|
return wfp_slist_remove_after(list, &list->head);
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
struct wfp_slist_item * wfp_slist_remove_after(
|
||
|
struct wfp_slist * list,
|
||
|
struct wfp_slist_item * prev)
|
||
6 years ago
|
{
|
||
|
|
||
4 years ago
|
struct wfp_slist_item * result = prev->next;
|
||
5 years ago
|
|
||
|
if (NULL != result)
|
||
6 years ago
|
{
|
||
5 years ago
|
prev->next = result->next;
|
||
|
|
||
|
if (list->last == result)
|
||
6 years ago
|
{
|
||
|
list->last = prev;
|
||
5 years ago
|
}
|
||
6 years ago
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|