Change in libosmocore[master]: linuxlist: add function to check entry presence

dexter gerrit-no-reply at lists.osmocom.org
Wed Jun 30 15:10:57 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/24813 )


Change subject: linuxlist: add function to check entry presence
......................................................................

linuxlist: add function to check entry presence

The current linuxlist implementation has not convinient way to check if
a given element is actually contained in a list. However, this may be
helpful when we must be sure that a pointer to a list element is still
valid.

Change-Id: Id1e8281d9d9f34277095ce9307e298bf29affa71
Related: SYS#4971
---
M include/osmocom/core/linuxlist.h
1 file changed, 14 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/13/24813/1

diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h
index f28f88b..d450bb9 100644
--- a/include/osmocom/core/linuxlist.h
+++ b/include/osmocom/core/linuxlist.h
@@ -394,6 +394,20 @@
 	return i;
 }
 
+/*! Check whether a given element actually exists in the list.
+ *  \param head the llist head of the list to check.
+ *  \param entry the element to check.
+ *  \returns true if the element exists in the list, false otherwise.
+ */
+static inline bool llist_contains(struct llist_head *head, struct llist_head *entry)
+{
+	struct llist_head *llist_entry;
+	llist_for_each(llist_entry, head) {
+		if (llist_entry == entry)
+			return true;
+	}
+	return false;
+}
 
 
 /*! Double linked lists with a single pointer list head.

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24813
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id1e8281d9d9f34277095ce9307e298bf29affa71
Gerrit-Change-Number: 24813
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210630/8e2257b8/attachment.htm>


More information about the gerrit-log mailing list