Rewrite ARRAY_LENGTH as a template function
authorBehdad Esfahbod <behdad@behdad.org>
Sat, 4 Aug 2012 23:43:18 +0000 (16:43 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Sat, 4 Aug 2012 23:43:18 +0000 (16:43 -0700)
Such it wouldn't apply to pointers accidentally.

src/hb-ot-shape-complex-arabic-table.hh
src/hb-private.hh

index df85086..c66111b 100644 (file)
@@ -914,9 +914,9 @@ static const uint16_t shaping_table[][4] =
 #define SHAPING_TABLE_LAST     0x06D3
 
 
-static const struct {
+static const struct ligature_set_t {
  uint16_t first;
- struct {
+ struct ligature_pairs_t {
    uint16_t second;
    uint16_t ligature;
  } ligatures[4];
index 2f85025..0f1e5ce 100644 (file)
 
 
 #undef MIN
-template <typename Type> static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; }
+template <typename Type>
+static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; }
 
 #undef MAX
-template <typename Type> static inline Type MAX (const Type &a, const Type &b) { return a > b ? a : b; }
+template <typename Type>
+static inline Type MAX (const Type &a, const Type &b) { return a > b ? a : b; }
 
 
 #undef  ARRAY_LENGTH
-#define ARRAY_LENGTH(__array) ((signed int) (sizeof (__array) / sizeof (__array[0])))
+template <typename Type, unsigned int n>
+static inline unsigned int ARRAY_LENGTH (const Type (&a)[n]) { return n; }
 
 #define HB_STMT_START do
 #define HB_STMT_END   while (0)