]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup-internal.h: add ARRAY_SIZE macro
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 7 Aug 2023 09:26:36 +0000 (14:56 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 7 Aug 2023 15:32:25 +0000 (09:32 -0600)
Add ARRAY_SIZE macro to calculate the size of an array, this helper
macro improves readability.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/libcgroup-internal.h

index 1c423e1d7ba79d8de728bead3af998e845e2047d..05dda6a215223e63f171c6d28ea3851cce773090 100644 (file)
@@ -88,6 +88,8 @@ extern "C" {
 #define max(x, y) ((y) < (x)?(x):(y))
 #define min(x, y) ((y) > (x)?(x):(y))
 
+#define ARRAY_SIZE(x)  (sizeof(x) / sizeof((x)[0]))
+
 struct control_value {
        char name[FILENAME_MAX];
        char value[CG_CONTROL_VALUE_MAX];