Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-06-06 10:00:53 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-06-13 18:47:12 +0400
commita427fa5261565746b24c626766b7ffcb83712d3c (patch)
treeebdadc488d1f4c2a91aaa85a399a3ca5b53877be /source
parent341fd67fbf0f83eaf91dae36508c54e53e097360 (diff)
BLI_bitmap: typecheck maco
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/multires.c6
-rw-r--r--source/blender/blenlib/BLI_bitmap.h38
2 files changed, 27 insertions, 17 deletions
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