summaryrefslogtreecommitdiff
path: root/lib/typesafe.h
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2021-09-29 19:59:27 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2021-10-19 14:55:39 +0200
commit40ee228da9ae156f6129a7fd87845e1272d2bf92 (patch)
tree9c1147d24e5b99665bd87231fbe97f4374933798 /lib/typesafe.h
parentd259ca0989c793767c912622437c3c5b2c6d84b2 (diff)
lib: add unsorted typesafe_anywhere()
*_anywhere(item) returns whether an item is on _any_ container. Only available for unsorted containers for now. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/typesafe.h')
-rw-r--r--lib/typesafe.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/typesafe.h b/lib/typesafe.h
index b03934b964..44c42ffbca 100644
--- a/lib/typesafe.h
+++ b/lib/typesafe.h
@@ -258,6 +258,10 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \
{ \
return h->sh.count; \
} \
+macro_pure bool prefix ## _anywhere(const type *item) \
+{ \
+ return item->field.si.next != NULL; \
+} \
macro_pure bool prefix ## _member(const struct prefix##_head *h, \
const type *item) \
{ \
@@ -405,6 +409,11 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \
{ \
return h->dh.count; \
} \
+macro_pure bool prefix ## _anywhere(const type *item) \
+{ \
+ const struct dlist_item *ditem = &item->field.di; \
+ return ditem->next && ditem->prev; \
+} \
macro_pure bool prefix ## _member(const struct prefix##_head *h, \
const type *item) \
{ \