]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Add general purpose `ARRAY_SIZE` macro
authorJeff Lucovsky <jeff@lucovsky.org>
Sun, 17 Nov 2019 20:09:11 +0000 (15:09 -0500)
committerVictor Julien <victor@inliniac.net>
Tue, 19 Nov 2019 16:24:43 +0000 (17:24 +0100)
This commit adds `ARRAY_SIZE` as an helper for determining the number of
elements in an initialized array. The calculation is the same but the
macro provides a convenient shortcut. The implementation was borrowed
from the kernel sources.

src/suricata-common.h

index 627de0d78e20da24945cd06300c5805291ae8055..b55509c52eb942022f1f271faad501a6abca2379 100644 (file)
@@ -494,5 +494,8 @@ char *strptime(const char * __restrict, const char * __restrict, struct tm * __r
 extern int coverage_unittests;
 extern int g_ut_modules;
 extern int g_ut_covered;
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
+
 #endif /* __SURICATA_COMMON_H__ */