[Bf-blender-cvs] [6d40261] master: Correct error in wrapped array-span-iteration

Campbell Barton noreply at git.blender.org
Sat May 7 15:43:35 CEST 2016


Commit: 6d402610c1c053f4febe3d1ed4da34c7af0bd276
Author: Campbell Barton
Date:   Sat May 7 23:47:58 2016 +1000
Branches: master
https://developer.blender.org/rB6d402610c1c053f4febe3d1ed4da34c7af0bd276

Correct error in wrapped array-span-iteration

===================================================================

M	source/blender/blenlib/intern/array_utils.c

===================================================================

diff --git a/source/blender/blenlib/intern/array_utils.c b/source/blender/blenlib/intern/array_utils.c
index cbc9b49..5d485e2 100644
--- a/source/blender/blenlib/intern/array_utils.c
+++ b/source/blender/blenlib/intern/array_utils.c
@@ -196,6 +196,9 @@ bool _bli_array_iter_span(
 	if (arr_len == 0) {
 		return false;
 	}
+	else if (use_wrap && (span_step[0] != arr_len) && (span_step[0] > span_step[1])) {
+		return false;
+	}
 
 	const unsigned int arr_stride_uint = (unsigned int)arr_stride;
 	const void *item_prev;
@@ -252,7 +255,12 @@ bool _bli_array_iter_span(
 					}
 				}
 
-				span_len = (i_step_prev - ((i_step_prev >= i_curr) ? i_curr : (i_curr + arr_len))) + 1;
+				if (i_step_prev < i_curr) {
+					span_len = (i_step_prev + (arr_len - i_curr)) + 1;
+				}
+				else {
+					span_len = (i_step_prev - i_curr) + 1;
+				}
 			}
 			else {
 				unsigned int i_step = i_curr + 1;




More information about the Bf-blender-cvs mailing list