You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Simplify rand_str()function
This commit is contained in:
@@ -26,8 +26,7 @@ char *rand_str(size_t length) {
|
||||
char *dest= (char *)malloc(length+1);
|
||||
char *p= dest;
|
||||
while (length-- > 0) {
|
||||
size_t index = (size_t)((double)rand() / RAND_MAX * (sizeof charset - 1));
|
||||
*dest++ = charset[index];
|
||||
*dest++ = charset[rand() % sizeof(charset)];
|
||||
}
|
||||
*dest = '\0';
|
||||
return p;
|
||||
|
Reference in New Issue
Block a user