style. we use calloc

This commit is contained in:
iceman1001 committed 2024-01-07 20:47:07 +01:00
1 parent d906f23a0a
commit 482a6464a2
6 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -1930,7 +1930,7 @@ static void add_matching_states(statelist_t *cands, uint8_t part_sum_a0, uint8_t
const uint32_t worstcase_size = 1 << 20;
cands->states[odd_even] = (uint32_t *)malloc(sizeof(uint32_t) * worstcase_size);
cands->states[odd_even] = (uint32_t *)calloc(sizeof(uint32_t) * worstcase_size, sizeof(uint8_t));
if (cands->states[odd_even] == NULL) {
PrintAndLogEx(ERR, "Out of memory error in add_matching_states() - statelist.\n");
exit(4);
+1 -1
View File
@@ -288,7 +288,7 @@ static void ntag424_calc_mac(ntag424_session_keys_t *session_keys, uint8_t comma
int mac_input_len = sizeof(mac_input_header) + datalen;
uint8_t *mac_input = (uint8_t *)malloc(mac_input_len);
uint8_t *mac_input = (uint8_t *)calloc(mac_input_len, sizeof(uint8_t));
memcpy(mac_input, mac_input_header, sizeof(mac_input_header));
memcpy(&mac_input[sizeof(mac_input_header)], data, datalen);
uint8_t mac[16] = {0};
+1 -1
View File
@@ -365,7 +365,7 @@ static void *bf_thread(void *thread_arg) {
// success
if (memcmp(calculated_MAC, mac, 4) == 0) {
loclass_thread_ret_t *r = (loclass_thread_ret_t *)malloc(sizeof(loclass_thread_ret_t));
loclass_thread_ret_t *r = (loclass_thread_ret_t *)calloc(sizeof(loclass_thread_ret_t), sizeof(uint8_t));
for (uint8_t i = 0 ; i < numbytes_to_recover; i++) {
r->values[i] = keytable[bytes_to_recover[i]] & 0xFF;
+1 -1
View File
@@ -2,7 +2,7 @@
#include <stdlib.h>
RingBuffer *RingBuf_create(int capacity) {
RingBuffer *buffer = (RingBuffer *)malloc(sizeof(RingBuffer));
RingBuffer *buffer = (RingBuffer *)calloc(sizeof(RingBuffer), sizeof(uint8_t));
if (!buffer) {
return NULL;
}