From f1d4ed41d67784c7ca325b9f4d19994acc5cac3a Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Thu, 26 Feb 2026 16:29:50 +0100 Subject: [PATCH] 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. --- src/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common.c b/src/common.c index 52aa0ee6..c0076ff3 100644 --- a/src/common.c +++ b/src/common.c @@ -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();