refactor: replace calloc with g_new0 for struct allocations
Migrate structure allocations from calloc to glibs g_new0 macro to improve type safety and memory robustness. * Type Safety: The macro takes the type name directly, ensuring the allocated size always matches the pointer type. * Static Analysis: It guarantees a non-NULL return by aborting on failure, which silences -fanalyzer warnings regarding potential NULL pointer dereferences. * Readability: Removes redundant sizeof() calls and is the glib way
This commit is contained in:
@@ -102,7 +102,7 @@ status_bar_init(void)
|
||||
statusbar->prompt = NULL;
|
||||
statusbar->fulljid = NULL;
|
||||
statusbar->tabs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)_destroy_tab);
|
||||
StatusBarTab* console = calloc(1, sizeof(StatusBarTab));
|
||||
StatusBarTab* console = g_new0(StatusBarTab, 1);
|
||||
console->window_type = WIN_CONSOLE;
|
||||
console->identifier = strdup("console");
|
||||
console->display_name = NULL;
|
||||
|
||||
Reference in New Issue
Block a user