summaryrefslogtreecommitdiffstats
path: root/src/config.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-12-07 10:21:19 -0500
committerTavian Barnes <tavianator@tavianator.com>2022-12-07 10:51:47 -0500
commit2898d6b79d15c984f95977f7385dd4273087c61b (patch)
treee436af4a2a1fc627b2b48a2e93cc77b27f7130b3 /src/config.h
parentd1e532ed839c1b2be093c88006fcf4cd3d11805d (diff)
downloadbfs-2898d6b79d15c984f95977f7385dd4273087c61b.tar.xz
config: New BFS_COUNTOF macro
Diffstat (limited to 'src/config.h')
-rw-r--r--src/config.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h
index 0822e3c..4a49b75 100644
--- a/src/config.h
+++ b/src/config.h
@@ -155,6 +155,11 @@
# define BFS_FALLTHROUGH ((void)0)
#endif
+/**
+ * Get the length of an array.
+ */
+#define BFS_COUNTOF(array) (sizeof(array) / sizeof(0[array]))
+
// Lower bound on BFS_FLEX_SIZEOF()
#define BFS_FLEX_LB(type, member, length) (offsetof(type, member) + sizeof(((type *)NULL)->member[0]) * (length))