Add NITEMS(arr) to get the number of elements of an array

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar 2022-12-22 13:51:20 +01:00 committed by Serge Hallyn
parent 220b352b70
commit eb164165f6

View File

@ -171,6 +171,8 @@ static inline void memzero(void *ptr, size_t size)
#define SCALE DAY #define SCALE DAY
#endif #endif
#define NITEMS(arr) (sizeof((arr)) / sizeof((arr)[0]))
/* Copy string pointed by B to array A with size checking. It was originally /* 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 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... */ very sloppy coding used to assume that BUFSIZ will always be enough... */