aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-03-26 13:12:02 +0100
committerMattias Andrée <maandree@kth.se>2016-03-26 13:12:02 +0100
commitfedc34128bd8be38190ee70d7e308566f9076ab0 (patch)
treec2c8b3782f0bd89907a22d9630d4f1de063aa8a2
parentstrfry: fix support for empty strings (diff)
downloadslibc-fedc34128bd8be38190ee70d7e308566f9076ab0.tar.gz
slibc-fedc34128bd8be38190ee70d7e308566f9076ab0.tar.bz2
slibc-fedc34128bd8be38190ee70d7e308566f9076ab0.tar.xz
m
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/string/strfry.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/string/strfry.c b/src/string/strfry.c
index aa09d0b..39f53e6 100644
--- a/src/string/strfry.c
+++ b/src/string/strfry.c
@@ -35,13 +35,12 @@
*/
char* strfry(char* anagram)
{
- size_t i, j, n;
+ size_t i, j;
int r;
char t;
if (anagram == NULL)
return NULL;
- n = strlen(anagram);
- for (i = n - 1; n && i; i--)
+ for (i = strlen(anagram); i--;)
{
r = rand();
j = (size_t)((double)r / ((double)RAND_MAX + 1) * (double)i); /* TODO This is not uniformally random. */