[Bf-blender-cvs] [63ea0f7581f] master: BLI_bitmap: fix _BITMAP_NUM_BLOCKS to not over-count by one block
Aras Pranckevicius
noreply at git.blender.org
Fri Jul 15 09:21:20 CEST 2022
Commit: 63ea0f7581faeeb629b040b7a4dc661bc84c789c
Author: Aras Pranckevicius
Date: Fri Jul 15 10:21:27 2022 +0300
Branches: master
https://developer.blender.org/rB63ea0f7581faeeb629b040b7a4dc661bc84c789c
BLI_bitmap: fix _BITMAP_NUM_BLOCKS to not over-count by one block
For bit counts that were exact multiple of block size, the macro was
computing one block too much.
Reviewed By: Campbell Barton, Bastien Montagne
Differential Revision: https://developer.blender.org/D15454
===================================================================
M source/blender/blenlib/BLI_bitmap.h
===================================================================
diff --git a/source/blender/blenlib/BLI_bitmap.h b/source/blender/blenlib/BLI_bitmap.h
index 26dc6c7ffc9..973cc5c3d1e 100644
--- a/source/blender/blenlib/BLI_bitmap.h
+++ b/source/blender/blenlib/BLI_bitmap.h
@@ -27,7 +27,7 @@ typedef unsigned int BLI_bitmap;
/**
* Number of blocks needed to hold '_num' bits.
*/
-#define _BITMAP_NUM_BLOCKS(_num) (((_num) >> _BITMAP_POWER) + 1)
+#define _BITMAP_NUM_BLOCKS(_num) (((_num) + _BITMAP_MASK) >> _BITMAP_POWER)
/**
* Size (in bytes) used to hold '_num' bits.
More information about the Bf-blender-cvs
mailing list