pespin submitted this change.
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.