]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Typed list: macro for list length
authorMaria Matejka <mq@ucw.cz>
Thu, 21 Mar 2024 22:37:04 +0000 (23:37 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 3 Apr 2024 11:58:41 +0000 (13:58 +0200)
lib/tlists.h

index 70b8eb3f436cd4c2915fea22df7d7ddc7a3888c2..96172ad6c5b24829602038c85d6e2bec318a92a9 100644 (file)
@@ -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