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-05-29 07:38:34 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-06-13 18:47:11 +0400
commit1962e21703b33bdaae87accc638cfe49ac737f64 (patch)
tree4dcf3c029d7dbfbf2c1b96e99bd774cb820a5fec /source
parentc3c04fe5823494dcf9195a327b354c88ac9b6757 (diff)
Code cleanup: remove redundant arg from ARRAY_LAST_ITEM
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/fcurve.c4
-rw-r--r--source/blender/blenlib/BLI_utildefines.h17
2 files changed, 15 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index d7d46427b8c..a8de9b69fbe 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -469,7 +469,7 @@ static short get_fcurve_end_keyframes(FCurve *fcu, BezTriple **first, BezTriple
}
/* find last selected */
- bezt = ARRAY_LAST_ITEM(fcu->bezt, BezTriple, sizeof(BezTriple), fcu->totvert);
+ bezt = ARRAY_LAST_ITEM(fcu->bezt, BezTriple, fcu->totvert);
for (i = 0; i < fcu->totvert; bezt--, i++) {
if (BEZSELECTED(bezt)) {
*last = bezt;
@@ -481,7 +481,7 @@ static short get_fcurve_end_keyframes(FCurve *fcu, BezTriple **first, BezTriple
else {
/* just full array */
*first = fcu->bezt;
- *last = ARRAY_LAST_ITEM(fcu->bezt, BezTriple, sizeof(BezTriple), fcu->totvert);
+ *last = ARRAY_LAST_ITEM(fcu->bezt, BezTriple, fcu->totvert);
found = true;
}
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index af192d13369..747db558af7 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -147,9 +147,17 @@
__tmp = (__typeof(var_b) *)NULL; \
(void)__tmp; \
} (void)0
+
+#define CHECK_TYPE_PAIR_INLINE(var_a, var_b) ((void)({ \
+ __typeof(var_a) *__tmp; \
+ __tmp = (__typeof(var_b) *)NULL; \
+ (void)__tmp; \
+}))
+
#else
# define CHECK_TYPE(var, type)
# define CHECK_TYPE_PAIR(var_a, var_b)
+# define CHECK_TYPE_PAIR_INLINE(var_a, var_b)
#endif
/* can be used in simple macros */
@@ -348,11 +356,12 @@
#endif
/* array helpers */
-#define ARRAY_LAST_ITEM(arr_start, arr_dtype, elem_size, tot) \
- (arr_dtype *)((char *)arr_start + (elem_size * (tot - 1)))
+#define ARRAY_LAST_ITEM(arr_start, arr_dtype, tot) \
+ (arr_dtype *)((char *)arr_start + (sizeof(*((arr_dtype *)NULL)) * (size_t)(tot - 1)))
-#define ARRAY_HAS_ITEM(arr_item, arr_start, tot) \
- ((unsigned int)((arr_item) - (arr_start)) < (unsigned int)(tot))
+#define ARRAY_HAS_ITEM(arr_item, arr_start, tot) ( \
+ CHECK_TYPE_PAIR_INLINE(arr_start, arr_item), \
+ ((unsigned int)((arr_item) - (arr_start)) < (unsigned int)(tot)))
#define ARRAY_DELETE(arr, index, tot_delete, tot) { \
BLI_assert(index + tot_delete <= tot); \