1
0
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:
Vladislav Vaintroub
2016-09-10 13:21:02 +00:00
parent 12797530d5
commit 4ed1ca0c68

View File

@@ -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;