[asterisk-commits] russell: trunk r170943 - /trunk/include/asterisk/utils.h

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jan 24 20:49:31 CST 2009


Author: russell
Date: Sat Jan 24 20:49:30 2009
New Revision: 170943

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=170943
Log:
Change ARRAY_LEN() to be more C++ safe.

When the second part of this macro is written as 0[a] instead of a[0], it will
force a failure if the macro is used on a C++ object that overloads the []
operator.

Modified:
    trunk/include/asterisk/utils.h

Modified: trunk/include/asterisk/utils.h
URL: http://svn.digium.com/svn-view/asterisk/trunk/include/asterisk/utils.h?view=diff&rev=170943&r1=170942&r2=170943
==============================================================================
--- trunk/include/asterisk/utils.h (original)
+++ trunk/include/asterisk/utils.h Sat Jan 24 20:49:30 2009
@@ -657,7 +657,7 @@
  */
 int ast_mkdir(const char *path, int mode);
 
-#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
+#define ARRAY_LEN(a) (sizeof(a) / sizeof(0[a]))
 
 #ifdef AST_DEVMODE
 #define ast_assert(a) _ast_assert(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)




More information about the asterisk-commits mailing list