diff options
author | Adam Langley <agl@chromium.org> | 2014-07-09 03:10:12 +0400 |
---|---|---|
committer | Adam Langley <agl@chromium.org> | 2014-07-09 03:10:12 +0400 |
commit | 2f1f89d6afefb89aa19257b5c624e3b3eb15203d (patch) | |
tree | 1b37eb5a58b181f63802e2b1ae1bdf967bb1b23c /crypto | |
parent | 23b460df0275d7b1543d3b5e0a33b1660a501ce9 (diff) |
Switch from rand_r to rand in lhash_test.
Android doesn't support rand_r.
Change-Id: Iaea767f64da4f6b83907c20d891811a0023ce530
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/lhash/lhash_test.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/crypto/lhash/lhash_test.c b/crypto/lhash/lhash_test.c index 578bb66f..2aa90c33 100644 --- a/crypto/lhash/lhash_test.c +++ b/crypto/lhash/lhash_test.c @@ -14,12 +14,6 @@ #define _BSD_SOURCE -#if !defined(__APPLE__) -/* _POSIX_SOURCE is needed on Linux in order to get rand_r, but on OS X causes - * a build failure. */ -#define _POSIX_SOURCE -#endif - #include <openssl/lhash.h> #include <stdio.h> @@ -105,13 +99,13 @@ static char *dummy_lh_delete(struct dummy_lhash *lh, const void *s) { return NULL; } -static char *rand_string(unsigned *rand_state) { - unsigned len = 1 + (rand_r(rand_state) % 3); +static char *rand_string() { + unsigned len = 1 + (rand() % 3); char *ret = malloc(len + 1); unsigned i; for (i = 0; i < len; i++) { - ret[i] = '0' + (rand_r(rand_state) & 7); + ret[i] = '0' + (rand() & 7); } ret[i] = 0; @@ -121,7 +115,6 @@ static char *rand_string(unsigned *rand_state) { int main(int argc, char **argv) { _LHASH *lh = lh_new(NULL, NULL); struct dummy_lhash dummy_lh = {NULL}; - unsigned rand_state = 0; unsigned i; for (i = 0; i < 100000; i++) { @@ -133,10 +126,10 @@ int main(int argc, char **argv) { return 1; } - action = rand_r(&rand_state) % 3; + action = rand() % 3; switch (action) { case 0: - s = rand_string(&rand_state); + s = rand_string(); s1 = (char *)lh_retrieve(lh, s); s2 = dummy_lh_retrieve(&dummy_lh, s); if (s1 != NULL && (s2 == NULL || strcmp(s1, s2) != 0)) { @@ -147,7 +140,7 @@ int main(int argc, char **argv) { break; case 1: - s = rand_string(&rand_state); + s = rand_string(); lh_insert(lh, (void **)&s1, s); dummy_lh_insert(&dummy_lh, &s2, strdup(s)); @@ -165,7 +158,7 @@ int main(int argc, char **argv) { break; case 2: - s = rand_string(&rand_state); + s = rand_string(); s1 = lh_delete(lh, s); s2 = dummy_lh_delete(&dummy_lh, s); |