mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-26 08:06: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:
@@ -56,7 +56,7 @@ _chat_session_new(const char* const barejid, const char* const resource, gboolea
|
||||
assert(barejid != NULL);
|
||||
assert(resource != NULL);
|
||||
|
||||
ChatSession* new_session = calloc(1, sizeof(*new_session));
|
||||
ChatSession* new_session = g_new0(ChatSession, 1);
|
||||
new_session->barejid = strdup(barejid);
|
||||
new_session->resource = strdup(resource);
|
||||
new_session->resource_override = resource_override;
|
||||
|
||||
Reference in New Issue
Block a user