pespin submitted this change.

View Change

Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved
linuxlist.h: add llist_last_entry_or_null macro

Related: OS#6705
Change-Id: Iaa5c8900434fe327a9c8b072182624a7fbfb369c
---
M include/osmocom/core/linuxlist.h
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h
index 2fc3fa7..8c8b1bc 100644
--- a/include/osmocom/core/linuxlist.h
+++ b/include/osmocom/core/linuxlist.h
@@ -254,6 +254,16 @@
#define llist_first_entry_or_null(ptr, type, member) \
(!llist_empty(ptr) ? llist_first_entry(ptr, type, member) : NULL)

+/*! Get the last element from a list, or NULL.
+ * \param ptr the list head to take the element from.
+ * \param type the type of the struct this is embedded in.
+ * \param member the name of the list_head within the struct.
+ *
+ * Note that if the list is empty, it returns NULL.
+ */
+#define llist_last_entry_or_null(ptr, type, member) \
+ (!llist_empty(ptr) ? llist_last_entry(ptr, type, member) : NULL)
+
/*! Iterate over a linked list.
* \param pos the llist_head to use as a loop counter.
* \param head the head of the list over which to iterate.

To view, visit change 40724. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iaa5c8900434fe327a9c8b072182624a7fbfb369c
Gerrit-Change-Number: 40724
Gerrit-PatchSet: 1
Gerrit-Owner: jolly <andreas@eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>