From 49778862934dcc435f4d5004179f608a35abbe61 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sat, 12 May 2012 13:38:59 +0200 Subject: [PATCH] common: add ARRAY_SIZE() macro --- common.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common.h b/common.h index 5717918..fed34e5 100644 --- a/common.h +++ b/common.h @@ -32,6 +32,11 @@ #define container_of(P,T,M) (T *)((char *)(P) - offsetof(T, M)) #endif +/** calculate number of elements of an array */ +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(A) (sizeof(A)/sizeof((A)[0])) +#endif + /** shortcut to printf to stderr */ #define errf(...) fprintf(stderr, __VA_ARGS__)