1
0
Fork 0
forked from len0rd/rockbox

Reverted to the earlier modulo method for creating a range of random numbers, since the new method could generate too large numbers

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5386 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2004-11-06 23:37:21 +00:00
parent 04c5ecb4ee
commit 1c9ab1ba69

View file

@ -727,7 +727,7 @@ static int randomise_playlist(struct playlist_info* playlist,
for(count = playlist->amount - 1; count >= 0; count--) for(count = playlist->amount - 1; count >= 0; count--)
{ {
/* the rand is from 0 to RAND_MAX, so adjust to our value range */ /* the rand is from 0 to RAND_MAX, so adjust to our value range */
candidate = rand() / (RAND_MAX / (count + 1)); candidate = rand() % (count + 1);
/* now swap the values at the 'count' and 'candidate' positions */ /* now swap the values at the 'count' and 'candidate' positions */
store = playlist->indices[candidate]; store = playlist->indices[candidate];