You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +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 *dest= (char *)malloc(length+1);
|
||||||
char *p= dest;
|
char *p= dest;
|
||||||
while (length-- > 0) {
|
while (length-- > 0) {
|
||||||
size_t index = (size_t)((double)rand() / RAND_MAX * (sizeof charset - 1));
|
*dest++ = charset[rand() % sizeof(charset)];
|
||||||
*dest++ = charset[index];
|
|
||||||
}
|
}
|
||||||
*dest = '\0';
|
*dest = '\0';
|
||||||
return p;
|
return p;
|
||||||
|
Reference in New Issue
Block a user