From: Jeff Lucovsky Date: Sun, 17 Nov 2019 20:09:11 +0000 (-0500) Subject: Add general purpose `ARRAY_SIZE` macro X-Git-Tag: suricata-5.0.1~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90c2e3561c655c9485990e6032bcaa4abddfd767;p=thirdparty%2Fsuricata.git Add general purpose `ARRAY_SIZE` macro 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. --- diff --git a/src/suricata-common.h b/src/suricata-common.h index 627de0d78e..b55509c52e 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -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__ */