From: Alejandro Colomar Date: Thu, 22 Dec 2022 12:51:20 +0000 (+0100) Subject: Add NITEMS(arr) to get the number of elements of an array X-Git-Tag: 4.14.0-rc1~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb164165f66e5785f5a5f8e0af650f4ff5d9ae95;p=thirdparty%2Fshadow.git Add NITEMS(arr) to get the number of elements of an array Signed-off-by: Alejandro Colomar --- diff --git a/lib/defines.h b/lib/defines.h index b2185793f..1a25e5807 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -171,6 +171,8 @@ static inline void memzero(void *ptr, size_t size) #define SCALE DAY #endif +#define NITEMS(arr) (sizeof((arr)) / sizeof((arr)[0])) + /* Copy string pointed by B to array A with size checking. It was originally in lmain.c but is _very_ useful elsewhere. Some setuid root programs with very sloppy coding used to assume that BUFSIZ will always be enough... */