mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 18:16: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:
@@ -74,7 +74,7 @@ _is_valid_form_element(xmpp_stanza_t* stanza)
|
||||
static DataForm*
|
||||
_form_new(void)
|
||||
{
|
||||
DataForm* form = calloc(1, sizeof(DataForm));
|
||||
DataForm* form = g_new0(DataForm, 1);
|
||||
|
||||
return form;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ _form_new(void)
|
||||
static FormField*
|
||||
_field_new(void)
|
||||
{
|
||||
FormField* field = calloc(1, sizeof(FormField));
|
||||
FormField* field = g_new0(FormField, 1);
|
||||
|
||||
return field;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user