]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Convert random() in hash test duplicate to C++11 random engine
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 8 Feb 2015 16:25:58 +0000 (08:25 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 8 Feb 2015 16:25:58 +0000 (08:25 -0800)
test-suite/hash.c

index f97d45a501ae27d78b2f3fbd855cb0f29bc005c4..52eaa33f0f094da8e8b3362df79ba1faeb0850d7 100644 (file)
@@ -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);
     }