X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Flib%2Fskiplist%2Fskiplist.c;h=b1764df8b4ebbaf594868224465ce8102d5657c7;hp=b4d7fd2bd28dc8e3ba6b5e8efcf1a89f50bb5f12;hb=37f713c79d74b5aa84b9eb6154befae7f1133ea0;hpb=8d6cd613e368e494095ec4747583ba513367f5af diff --git a/reactos/lib/skiplist/skiplist.c b/reactos/lib/skiplist/skiplist.c index b4d7fd2bd28..b1764df8b4e 100644 --- a/reactos/lib/skiplist/skiplist.c +++ b/reactos/lib/skiplist/skiplist.c @@ -28,11 +28,11 @@ _GetRandomLevel() DWORD dwLevel = 0; DWORD dwShifted; - // Generate 32 uniformly distributed pseudo-random bits using the Park-Miller Lehmer Minimal Standard Random Number Generator. + // Generate 31 uniformly distributed pseudo-random bits using the Park-Miller Lehmer Minimal Standard Random Number Generator. dwRandom = (DWORD)(((ULONGLONG)dwRandom * 48271UL) % 2147483647UL); - // Shift out (32 - SKIPLIST_LEVELS) bits to the right to have no more than SKIPLIST_LEVELS bits set. - dwShifted = dwRandom >> (32 - SKIPLIST_LEVELS); + // Shift out (31 - SKIPLIST_LEVELS) bits to the right to have no more than SKIPLIST_LEVELS bits set. + dwShifted = dwRandom >> (31 - SKIPLIST_LEVELS); // BitScanForward doesn't operate on a zero input value. if (dwShifted) @@ -42,7 +42,7 @@ _GetRandomLevel() BitScanForward(&dwLevel, dwShifted); } - // dwLevel can't have a value higher than 31 this way, so a CHAR is more than enough. + // dwLevel can't have a value higher than 30 this way, so a CHAR is more than enough. return (CHAR)dwLevel; }