BLI_bitmap: typecheck maco
authorCampbell Barton <ideasman42@gmail.com>
Fri, 6 Jun 2014 06:00:53 +0000 (16:00 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 13 Jun 2014 14:47:12 +0000 (00:47 +1000)
source/blender/blenkernel/intern/multires.c
source/blender/blenlib/BLI_bitmap.h

index 5fe2a56c01a542fac50fbebb42c55e2b81d0a8b5..165b4b1e6e79da31b0fe126f4fef4a8ca3881124 100644 (file)
@@ -153,10 +153,12 @@ static BLI_bitmap *multires_mdisps_upsample_hidden(BLI_bitmap *lo_hidden,
                                                /* If prev_hidden is available, copy it to
                                                 * subd, except when the equivalent element in
                                                 * lo_hidden is different */
-                                               if (lo_val != prev_hidden[hi_ndx])
+                                               if (lo_val != prev_hidden[hi_ndx]) {
                                                        BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val);
-                                               else
+                                               }
+                                               else {
                                                        BLI_BITMAP_MODIFY(subd, hi_ndx, prev_hidden[hi_ndx]);
+                                               }
                                        }
                                        else {
                                                BLI_BITMAP_MODIFY(subd, hi_ndx, lo_val);
index 3d56156bfc10f60810d38fe289a12c3283d9e073..cff2b52012c925499b5e5c405eec26a21bada887 100644 (file)
@@ -37,17 +37,17 @@ typedef unsigned int BLI_bitmap;
 
 /* internal use */
 /* 2^5 = 32 (bits) */
-#define BLI_BITMAP_POWER 5
+#define _BITMAP_POWER 5
 /* 0b11111 */
-#define BLI_BITMAP_MASK 31
+#define _BITMAP_MASK 31
 
 /* number of blocks needed to hold '_tot' bits */
-#define BLI_BITMAP_NUM_BLOCKS(_tot) \
-       (((_tot) >> BLI_BITMAP_POWER) + 1)
+#define _BITMAP_NUM_BLOCKS(_tot) \
+       (((_tot) >> _BITMAP_POWER) + 1)
 
 /* size (in bytes) used to hold '_tot' bits */
 #define BLI_BITMAP_SIZE(_tot) \
-       (BLI_BITMAP_NUM_BLOCKS(_tot) * sizeof(unsigned int))
+       (_BITMAP_NUM_BLOCKS(_tot) * sizeof(unsigned int))
 
 /* allocate memory for a bitmap with '_tot' bits; free
  *  with MEM_freeN() */
@@ -61,33 +61,41 @@ typedef unsigned int BLI_bitmap;
 
 /* get the value of a single bit at '_index' */
 #define BLI_BITMAP_GET(_bitmap, _index) \
-       ((_bitmap)[(_index) >> BLI_BITMAP_POWER] & \
-        (1u << ((_index) & BLI_BITMAP_MASK)))
+       (CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
+        ((_bitmap)[(_index) >> _BITMAP_POWER] & \
+         (1u << ((_index) & _BITMAP_MASK))))
 
 #define BLI_BITMAP_GET_BOOL(_bitmap, _index) \
-       (BLI_BITMAP_GET(_bitmap, _index) != 0)
+       (CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
+        (BLI_BITMAP_GET(_bitmap, _index) != 0))
 
 /* set the value of a single bit at '_index' */
 #define BLI_BITMAP_SET(_bitmap, _index) \
-       ((_bitmap)[(_index) >> BLI_BITMAP_POWER] |= \
-        (1u << ((_index) & BLI_BITMAP_MASK)))
+       (CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
+        ((_bitmap)[(_index) >> _BITMAP_POWER] |= \
+         (1u << ((_index) & _BITMAP_MASK))))
 
 /* clear the value of a single bit at '_index' */
 #define BLI_BITMAP_CLEAR(_bitmap, _index) \
-       ((_bitmap)[(_index) >> BLI_BITMAP_POWER] &= \
-        ~(1u << ((_index) & BLI_BITMAP_MASK)))
+       (CHECK_TYPE_INLINE(_bitmap, BLI_bitmap *), \
+        ((_bitmap)[(_index) >> _BITMAP_POWER] &= \
+         ~(1u << ((_index) & _BITMAP_MASK))))
 
 /* set or clear the value of a single bit at '_index' */
 #define BLI_BITMAP_MODIFY(_bitmap, _index, _set) \
-       do { \
+       { \
+               CHECK_TYPE(_bitmap, BLI_bitmap *); \
                if (_set) \
                        BLI_BITMAP_SET(_bitmap, _index); \
                else \
                        BLI_BITMAP_CLEAR(_bitmap, _index); \
-       } while (0)
+       } (void)0
 
 /* resize bitmap to have space for '_tot' bits */
 #define BLI_BITMAP_RESIZE(_bitmap, _tot) \
-       (_bitmap) = MEM_reallocN(_bitmap, BLI_BITMAP_SIZE(_tot))
+       { \
+               CHECK_TYPE(_bitmap, BLI_bitmap *); \
+               (_bitmap) = MEM_reallocN(_bitmap, BLI_BITMAP_SIZE(_tot)); \
+       } (void)0
 
 #endif