diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 5fe2a56c01a..165b4b1e6e7 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -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); diff --git a/source/blender/blenlib/BLI_bitmap.h b/source/blender/blenlib/BLI_bitmap.h index 3d56156bfc1..cff2b52012c 100644 --- a/source/blender/blenlib/BLI_bitmap.h +++ b/source/blender/blenlib/BLI_bitmap.h @@ -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