mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-20 14:26:21 +00:00
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:
@@ -101,7 +101,7 @@ aesgcm_file_get(void* userdata)
|
||||
|
||||
// We wrap the HTTPDownload tool and use it for retrieving the ciphertext
|
||||
// and storing it in the temporary file previously opened.
|
||||
HTTPDownload* http_dl = calloc(1, sizeof(HTTPDownload));
|
||||
HTTPDownload* http_dl = g_new0(HTTPDownload, 1);
|
||||
http_dl->window = aesgcm_dl->window;
|
||||
http_dl->worker = aesgcm_dl->worker;
|
||||
http_dl->id = strdup(aesgcm_dl->id);
|
||||
|
||||
@@ -62,7 +62,7 @@ static gchar* _search(Autocomplete ac, GList* curr, gboolean quote, search_direc
|
||||
Autocomplete
|
||||
autocomplete_new(void)
|
||||
{
|
||||
return calloc(1, sizeof(struct autocomplete_t));
|
||||
return g_new0(struct autocomplete_t, 1);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user