From 92d70212c5877d8663bd03b7af3815b7b3c6ef62 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 29 Jan 2012 15:38:01 +0000 Subject: [PATCH] Eina: Added EINA_C_ARRAY_LENGTH. This macro returns the length of a standard C array. SVN revision: 67589 --- legacy/eina/ChangeLog | 6 ++++++ legacy/eina/src/include/eina_types.h | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/legacy/eina/ChangeLog b/legacy/eina/ChangeLog index 84c1190373..f75800aec4 100644 --- a/legacy/eina/ChangeLog +++ b/legacy/eina/ChangeLog @@ -206,3 +206,9 @@ 2011-12-30 Vincent Torri * Fix Eina_RWLock code on Windows > XP. + +2012-01-29 Tom Hacohen + + * Added EINA_C_ARRAY_LENGTH, a macro that returns the length of a + standard C array. + diff --git a/legacy/eina/src/include/eina_types.h b/legacy/eina/src/include/eina_types.h index 16539495e7..96176b455c 100644 --- a/legacy/eina/src/include/eina_types.h +++ b/legacy/eina/src/include/eina_types.h @@ -275,6 +275,16 @@ typedef void (*Eina_Free_Cb)(void *data); */ #define EINA_FREE_CB(Function) ((Eina_Free_Cb)Function) +/** + * @def EINA_C_ARRAY_LENGTH + * Macro to return the array length of a standard c array. + * For example: + * int foo[] = { 0, 1, 2, 3 }; + * would return 4 and not 4 * sizeof(int). + * @since 1.2.0 + */ +#define EINA_C_ARRAY_LENGTH(arr) (sizeof(arr) / sizeof((arr)[0])) + /** * @} */