aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-03-01 23:19:36 +0100
committerMattias Andrée <maandree@kth.se>2016-03-01 23:19:36 +0100
commit11225d3b3202cc3a6a04eb92fd6f5f00a8354bbc (patch)
treec109c1879f64abe37b96a7149157f086646a0023
parentstrfry: use Durstenfeld's algorithm instead of Satallo's algorithm (diff)
downloadslibc-11225d3b3202cc3a6a04eb92fd6f5f00a8354bbc.tar.gz
slibc-11225d3b3202cc3a6a04eb92fd6f5f00a8354bbc.tar.bz2
slibc-11225d3b3202cc3a6a04eb92fd6f5f00a8354bbc.tar.xz
derp
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/string/strfry.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/string/strfry.c b/src/string/strfry.c
index f8b5b2c..b46fb06 100644
--- a/src/string/strfry.c
+++ b/src/string/strfry.c
@@ -40,7 +40,7 @@ char* strfry(char* anagram)
char t;
if (anagram == NULL)
return NULL;
- for (i = strlen(anagram); i; i--)
+ for (i = strlen(anagram) - 1; i; i--)
{
r = rand();
j = (size_t)((double)r / ((double)RAND_MAX + 1) * (double)i); /* TODO This is not uniformally random. */