Skip to content

Commit

Permalink
Simplify slist impl (unused).
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim committed Dec 16, 2022
1 parent c9b9842 commit fc599bf
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions list.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,23 +234,6 @@ static inline void INIT_SLIST_HEAD(struct slist_head *list)
list->last = &list->first;
}

static inline void slist_add_head(struct slist_node *node,
struct slist_head *list)
{
node->next = list->first.next;
list->first.next = node;
if (!node->next)
list->last = node;
}

static inline void slist_add_tail(struct slist_node *node,
struct slist_head *list)
{
node->next = (struct slist_node *)0;
list->last->next = node;
list->last = node;
}

static inline void slist_add_after(struct slist_node *node,
struct slist_node *prev,
struct slist_head *list)
Expand All @@ -261,11 +244,18 @@ static inline void slist_add_after(struct slist_node *node,
list->last = node;
}

static inline void slist_del_head(struct slist_head *list)
static inline void slist_add_head(struct slist_node *node,
struct slist_head *list)
{
list->first.next = list->first.next->next;
if (!list->first.next)
list->last = &list->first;
slist_add_after(node, &list->first, list);
}

static inline void slist_add_tail(struct slist_node *node,
struct slist_head *list)
{
node->next = (struct slist_node *)0;
list->last->next = node;
list->last = node;
}

static inline void slist_del_after(struct slist_node *prev,
Expand All @@ -276,6 +266,11 @@ static inline void slist_del_after(struct slist_node *prev,
list->last = prev;
}

static inline void slist_del_head(struct slist_head *list)
{
slist_del_after(&list->first, list);
}

static inline int slist_empty(struct slist_head *list)
{
return !list->first.next;
Expand Down

0 comments on commit fc599bf

Please sign in to comment.