Use calloc for certain things
Some information needs to be zero'd out, calloc helps here FossilOrigin-Name: d8b7f456384ed1c29b0f4fddafa1bae768990d0fce455aca3f84123561640a89
This commit is contained in:
parent
a381260315
commit
23c99ba5a2
5 changed files with 6 additions and 6 deletions
|
@ -35,7 +35,7 @@ void _mstdnt_val_malloc_account_call(cJSON* v, void* _type)
|
|||
{
|
||||
struct mstdnt_account** type = _type;
|
||||
|
||||
*type = malloc(sizeof(struct mstdnt_account));
|
||||
*type = calloc(1, sizeof(struct mstdnt_account));
|
||||
|
||||
if (*type)
|
||||
mstdnt_account_from_json(*type, v->child);
|
||||
|
|
|
@ -53,7 +53,7 @@ void _mstdnt_val_attachments_call(cJSON* v, void* _type)
|
|||
return;
|
||||
}
|
||||
|
||||
*attachments = malloc(sizeof(struct mstdnt_attachment) * size);
|
||||
*attachments = calloc(1, sizeof(struct mstdnt_attachment) * size);
|
||||
if (*attachments == NULL)
|
||||
return;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void _mstdnt_val_emoji_reactions_call(cJSON* v, void* _type)
|
|||
return;
|
||||
}
|
||||
|
||||
*emos = malloc(sizeof(struct mstdnt_emoji_reaction) * size);
|
||||
*emos = calloc(1, sizeof(struct mstdnt_emoji_reaction) * size);
|
||||
if (*emos == NULL)
|
||||
return;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ int mstdnt_notifications_from_result(struct mstdnt_fetch_results* results,
|
|||
if (size) *size = cJSON_GetArraySize(root);
|
||||
|
||||
/* malloc array - cJSON does a loop to count, let's do it once preferably */
|
||||
*notif = malloc((size ? *size : cJSON_GetArraySize(root))
|
||||
*notif = calloc(1, (size ? *size : cJSON_GetArraySize(root))
|
||||
* sizeof(struct mstdnt_notification));
|
||||
if (*notif == NULL)
|
||||
return 1;
|
||||
|
|
|
@ -34,7 +34,7 @@ void _mstdnt_val_malloc_status_call(cJSON* v, void* _type)
|
|||
{
|
||||
struct mstdnt_status** type = _type;
|
||||
|
||||
*type = malloc(sizeof(struct mstdnt_status));
|
||||
*type = calloc(1, sizeof(struct mstdnt_status));
|
||||
|
||||
if (*type)
|
||||
mstdnt_status_from_json(*type, v->child);
|
||||
|
@ -118,7 +118,7 @@ int mstdnt_statuses_from_result(struct mstdnt_storage* storage,
|
|||
if (size) *size = cJSON_GetArraySize(root);
|
||||
|
||||
/* malloc array - cJSON does a loop to count, let's do it once preferably */
|
||||
*statuses = malloc((size ? *size : cJSON_GetArraySize(root))
|
||||
*statuses = calloc(1, (size ? *size : cJSON_GetArraySize(root))
|
||||
* sizeof(struct mstdnt_status));
|
||||
if (*statuses == NULL)
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue