]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Change ARRAY_LEN() to be more C++ safe.
authorRussell Bryant <russell@russellbryant.com>
Sun, 25 Jan 2009 02:49:30 +0000 (02:49 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sun, 25 Jan 2009 02:49:30 +0000 (02:49 +0000)
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.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@170943 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/utils.h

index 941b5e57affc19cb92b9d641e980dd59bae359d6..ee8bbd511d1532e097fba5a3651c819cb1bb0907 100644 (file)
@@ -657,7 +657,7 @@ void ast_enable_packet_fragmentation(int sock);
  */
 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__)