<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/24813">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">linuxlist: add function to check entry presence<br><br>The current linuxlist implementation has not convinient way to check if<br>a given element is actually contained in a list. However, this may be<br>helpful when we must be sure that a pointer to a list element is still<br>valid.<br><br>Change-Id: Id1e8281d9d9f34277095ce9307e298bf29affa71<br>Related: SYS#4971<br>---<br>M include/osmocom/core/linuxlist.h<br>1 file changed, 14 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/13/24813/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h</span><br><span>index f28f88b..d450bb9 100644</span><br><span>--- a/include/osmocom/core/linuxlist.h</span><br><span>+++ b/include/osmocom/core/linuxlist.h</span><br><span>@@ -394,6 +394,20 @@</span><br><span>  return i;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! Check whether a given element actually exists in the list.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param head the llist head of the list to check.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param entry the element to check.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns true if the element exists in the list, false otherwise.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+static inline bool llist_contains(struct llist_head *head, struct llist_head *entry)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct llist_head *llist_entry;</span><br><span style="color: hsl(120, 100%, 40%);">+       llist_for_each(llist_entry, head) {</span><br><span style="color: hsl(120, 100%, 40%);">+           if (llist_entry == entry)</span><br><span style="color: hsl(120, 100%, 40%);">+                     return true;</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span style="color: hsl(120, 100%, 40%);">+     return false;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span> </span><br><span> </span><br><span> /*! Double linked lists with a single pointer list head.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/24813">change 24813</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/24813"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id1e8281d9d9f34277095ce9307e298bf29affa71 </div>
<div style="display:none"> Gerrit-Change-Number: 24813 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>