use rand instead of drand48
This commit is contained in:
@@ -39,14 +39,14 @@ static char lRandomAlNum()
|
|||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"abcdefghijklmnopqrstuvwxyz";
|
"abcdefghijklmnopqrstuvwxyz";
|
||||||
const size_t max_index = (sizeof(charset) - 1);
|
const size_t max_index = (sizeof(charset) - 1);
|
||||||
return charset[ int(drand48() * (1ULL<<31)) % max_index ];
|
return charset[ rand() % max_index ];
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string lRandomString(const size_t length)
|
static std::string lRandomString(const size_t length)
|
||||||
{
|
{
|
||||||
timeval t1;
|
timeval t1;
|
||||||
gettimeofday(&t1, NULL);
|
gettimeofday(&t1, NULL);
|
||||||
srand48((long long)t1.tv_usec * t1.tv_sec);
|
srand(t1.tv_usec * t1.tv_sec);
|
||||||
std::string str(length,0);
|
std::string str(length,0);
|
||||||
std::generate_n( str.begin(), length, lRandomAlNum);
|
std::generate_n( str.begin(), length, lRandomAlNum);
|
||||||
return str;
|
return str;
|
||||||
|
|||||||
Reference in New Issue
Block a user