Author: tkreuzer
Date: Sun Jun 24 12:51:27 2012
New Revision: 56793
URL:
http://svn.reactos.org/svn/reactos?rev=56793&view=rev
Log:
[RTL]
Fix a bug in RtlNumberOfSetBits
Modified:
trunk/reactos/lib/rtl/bitmap.c
Modified: trunk/reactos/lib/rtl/bitmap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/bitmap.c?rev=56793…
==============================================================================
--- trunk/reactos/lib/rtl/bitmap.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/bitmap.c [iso-8859-1] Sun Jun 24 12:51:27 2012
@@ -410,16 +410,18 @@
IN PRTL_BITMAP BitMapHeader)
{
PUCHAR Byte, MaxByte;
- ULONG BitCount = 0;
+ ULONG BitCount = 0, Shift;
Byte = (PUCHAR)BitMapHeader->Buffer;
- MaxByte = Byte + (BitMapHeader->SizeOfBitMap + 7) / 8;
-
- do
+ MaxByte = Byte + BitMapHeader->SizeOfBitMap / 8;
+
+ while (Byte < MaxByte);
{
BitCount += BitCountTable[*Byte++];
}
- while (Byte <= MaxByte);
+
+ Shift = 8 - (BitMapHeader->SizeOfBitMap & 7);
+ BitCount += BitCountTable[(*Byte) << Shift];
return BitCount;
}