mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-21 06:36: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:
@@ -59,7 +59,7 @@ account_new(gchar* name, gchar* jid, gchar* password, gchar* eval_password, gboo
|
||||
gchar* startscript, gchar* theme, gchar* tls_policy, gchar* auth_policy,
|
||||
gchar* client, int max_sessions)
|
||||
{
|
||||
ProfAccount* new_account = calloc(1, sizeof(ProfAccount));
|
||||
ProfAccount* new_account = g_new0(ProfAccount, 1);
|
||||
|
||||
new_account->name = name;
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ _tlscerts_new(gchar* fingerprint_sha1, int version, gchar* serialnumber, gchar*
|
||||
gchar* key_alg, gchar* signature_alg, gchar* pem,
|
||||
gchar* fingerprint_sha256, gchar* pubkey_fingerprint)
|
||||
{
|
||||
TLSCertificate* cert = calloc(1, sizeof(TLSCertificate));
|
||||
TLSCertificate* cert = g_new0(TLSCertificate, 1);
|
||||
|
||||
if (fingerprint_sha256 && fingerprint_sha1) {
|
||||
cert->fingerprint_sha256 = fingerprint_sha256;
|
||||
|
||||
Reference in New Issue
Block a user