From: Amos Jeffries Date: Sun, 8 Feb 2015 16:25:58 +0000 (-0800) Subject: Convert random() in hash test duplicate to C++11 random engine X-Git-Tag: merge-candidate-3-v1~109^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4757a949bf32e27d757a273236f34b66278bb15;p=thirdparty%2Fsquid.git Convert random() in hash test duplicate to C++11 random engine --- diff --git a/test-suite/hash.c b/test-suite/hash.c index f97d45a501..52eaa33f0f 100644 --- a/test-suite/hash.c +++ b/test-suite/hash.c @@ -354,12 +354,15 @@ main(void) } printf("done creating hash table: %d\n", hid); + std::mt19937 mt; + std::uniform_int_distribution<> dist(0,16); + while (fgets(buf, BUFSIZ, stdin)) { buf[strlen(buf) - 1] = '\0'; printf("Inserting '%s' for item %p to hash table: %d\n", buf, buf, hid); hash_insert(hid, xstrdup(buf), (void *) 0x12345678); - if (random() % 17 == 0) + if (dist(mt) == 0) strcpy(todelete, buf); }