Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: include/core/SkTypes.h

Issue 1114283003: SK_ARRAY_COUNT shouldn't work on pointers. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: count Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTypes.h
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index a1719f89e10e4f86a256c6aa178e94e8651e3c9e..1b0b12c621c6ce3ef282239959e0ec15e61c1f2e 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -296,9 +296,9 @@ static inline bool SkIsU16(long x) {
#define SK_OFFSETOF(type, field) (size_t)((char*)&(((type*)1)->field) - (char*)1)
#endif
-/** Returns the number of entries in an array (not a pointer)
-*/
-#define SK_ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0]))
+/** Returns the number of entries in an array (not a pointer) */
+template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N];
+#define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array)))
#define SkAlign2(x) (((x) + 1) >> 1 << 1)
#define SkIsAlign2(x) (0 == ((x) & 1))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698