refactor: Use g_malloc0 instead of calloc in get_random_string()

It automatically aborts the program on allocation failure.
Also eliminates the need for repetitive manual NULL checks.
This commit is contained in:
Michael Vetter
2026-02-26 16:29:50 +01:00
parent ec45a19c72
commit f1d4ed41d6

View File

@@ -687,7 +687,7 @@ get_random_string(int length)
char alphabet[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int endrange = sizeof(alphabet) - 1;
rand = calloc(length + 1, sizeof(char));
rand = g_malloc0(length + 1);
prng = g_rand_new();