Eina: Added EINA_C_ARRAY_LENGTH.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 29 Jan 2012 15:38:01 +0000 (15:38 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 29 Jan 2012 15:38:01 +0000 (15:38 +0000)
This macro returns the length of a standard C array.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@67589 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
src/include/eina_types.h

index 84c1190..f75800a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 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.
+
index 1653949..96176b4 100644 (file)
@@ -276,6 +276,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]))
+
+/**
  * @}
  */