aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/core
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2021-06-30 17:06:16 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2021-07-07 16:53:47 +0200
commitff84de7e1810ceed15d3eea249dc4e7f4a3ceeab (patch)
tree8ecae328d41d1f75bd1cde531b2cffb38c3cb705 /include/osmocom/core
parent5e040bf1f10ea6fdc58296575890e990cf755a57 (diff)
linuxlist: add macro to get last element of a list
It is not be obvious on the first look that ->prev actually points to the last element of a list, lets add a macro for that to make the API easier to use Change-Id: Icf455bf6ba9d60bd311af17c9e80febaa42cacc9 Related: SYS#4971
Diffstat (limited to 'include/osmocom/core')
-rw-r--r--include/osmocom/core/linuxlist.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h
index f28f88b9..725c60ca 100644
--- a/include/osmocom/core/linuxlist.h
+++ b/include/osmocom/core/linuxlist.h
@@ -238,6 +238,12 @@ static inline void llist_splice_init(struct llist_head *llist,
#define llist_last_entry(ptr, type, member) \
llist_entry((ptr)->prev, type, member)
+/*! Return the last element of the list.
+ * \param head the llist head of the list.
+ * \returns last element of the list, head if the list is empty.
+ */
+#define llist_last(head) (head)->prev
+
/*! Get the first 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.