From 6806aacf7471feceb8593091380b40cf1befa8a0 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Thu, 21 Mar 2024 23:37:04 +0100 Subject: [PATCH] Typed list: macro for list length --- lib/tlists.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tlists.h b/lib/tlists.h index 70b8eb3f..96172ad6 100644 --- a/lib/tlists.h +++ b/lib/tlists.h @@ -231,5 +231,8 @@ static inline void TLIST_NAME(rem_node)(TLIST_LIST_STRUCT *list, TLIST_TYPE *nod /* Empty check */ #define EMPTY_TLIST(_name, _list) (!(_list)->first) +/* List length */ +#define TLIST_LENGTH(_name, _list) ({ uint _len = 0; WALK_TLIST(_name, _, _list) _len++; _len; }) + #endif