From 8f23dfa9148967b232ac46318f981aaad01d0d84 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Fri, 14 Oct 2022 17:39:47 +0200 Subject: [PATCH] linuxlist: add llist_entry_empty() Return true if an entry is not included in a llist or NULL. Change-Id: Ia4afe3e77f53728db1d139bded5925183dca011f --- include/osmocom/core/linuxlist.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h index 2fc3fa75d..398128d97 100644 --- a/include/osmocom/core/linuxlist.h +++ b/include/osmocom/core/linuxlist.h @@ -171,6 +171,17 @@ static inline int llist_empty(const struct llist_head *head) return head->next == head; } +/*! + * Test whether a linked list entry is empty or not included by any list. + * \param[in] entry the llist to test + * \return 1 if the entry is NULL or not included by any llist. + */ +static inline int llist_entry_empty(const struct llist_head *entry) +{ + return entry == NULL || (!entry->next && !entry->prev) + || (entry->next == LLIST_POISON1 && entry->prev == LLIST_POISON2); +} + static inline void __llist_splice(struct llist_head *llist, struct llist_head *head) {