[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51928] trunk/blender/source/blender/ blenlib/intern/smallhash.c: bad use of assignment within ABS() caused SMHASH_NEXT macro to step the offset twice in some cases.
Campbell Barton
ideasman42 at gmail.com
Tue Nov 6 05:17:55 CET 2012
Revision: 51928
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51928
Author: campbellbarton
Date: 2012-11-06 04:17:46 +0000 (Tue, 06 Nov 2012)
Log Message:
-----------
bad use of assignment within ABS() caused SMHASH_NEXT macro to step the offset twice in some cases.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/smallhash.c
Modified: trunk/blender/source/blender/blenlib/intern/smallhash.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/smallhash.c 2012-11-06 02:13:24 UTC (rev 51927)
+++ trunk/blender/source/blender/blenlib/intern/smallhash.c 2012-11-06 04:17:46 UTC (rev 51928)
@@ -43,9 +43,23 @@
#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[];
void BLI_smallhash_init(SmallHash *hash)
More information about the Bf-blender-cvs
mailing list