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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-11-06 08:17:46 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-06 08:17:46 +0400
commitfb6ded3f593d5084e488093fb8ac4d133a27a659 (patch)
tree5e46963dd553e9c6a1182ef769e339bf5480f55f /source/blender/blenlib/intern/smallhash.c
parentdbd414deedd6b176c0dd266814b7baaef9f187b8 (diff)
bad use of assignment within ABS() caused SMHASH_NEXT macro to step the offset twice in some cases.
Diffstat (limited to 'source/blender/blenlib/intern/smallhash.c')
-rw-r--r--source/blender/blenlib/intern/smallhash.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/smallhash.c b/source/blender/blenlib/intern/smallhash.c
index 92125c6e988..64bb503fa3c 100644
--- a/source/blender/blenlib/intern/smallhash.c
+++ b/source/blender/blenlib/intern/smallhash.c
@@ -43,8 +43,22 @@
#define SMHASH_CELL_UNUSED ((void *)0x7FFFFFFF)
#define SMHASH_CELL_FREE ((void *)0x7FFFFFFD)
-#define SMHASH_NONZERO(n) ((n) + !(n))
-#define SMHASH_NEXT(h, hoff) ABS(((h) + ((hoff = SMHASH_NONZERO(hoff * 2) + 1), hoff)))
+BLI_INLINE int smhash_nonzero(const int n)
+{
+ return n + !n;
+}
+
+BLI_INLINE int smhash_abs_i(const int n)
+{
+ return (n > 0) ? n : -n;
+}
+
+/* typically this re-assigns 'h' */
+#define SMHASH_NEXT(h, hoff) ( \
+ CHECK_TYPE_INLINE(&(h), int), \
+ CHECK_TYPE_INLINE(&(hoff), int), \
+ smhash_abs_i((h) + (((hoff) = smhash_nonzero((hoff) * 2) + 1), (hoff))) \
+ )
extern unsigned int hashsizes[];