style. we use calloc

This commit is contained in:
iceman1001 2024-01-07 20:47:07 +01:00
parent d906f23a0a
commit 482a6464a2
6 changed files with 7 additions and 7 deletions

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);

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};

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;

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;
}

View file

@ -452,7 +452,7 @@ int main(int argc, char *argv[]) {
void *status;
// make the table of tables
t = (struct table *)malloc(sizeof(struct table) * 65536);
t = (struct table *)calloc(sizeof(struct table) * 65536, sizeof(uint8_t));
if (!t) {
printf("malloc failed\n");
exit(1);

View file

@ -196,7 +196,7 @@ static void *crack(void *d) {
numnrar = data->numnrar;
// create space for tables
Tk = (struct Tklower *)malloc(sizeof(struct Tklower) * 0x40000);
Tk = (struct Tklower *)calloc(sizeof(struct Tklower) * 0x40000, sizeof(uint8_t));
if (!Tk) {
printf("Failed to allocate memory (Tk)\n");
exit(1);
@ -314,7 +314,7 @@ int main(int argc, char *argv[]) {
}
// create table of nR aR pairs
TnRaR = (struct nRaR *)malloc(sizeof(struct nRaR) * NUM_NRAR);
TnRaR = (struct nRaR *)calloc(sizeof(struct nRaR) * NUM_NRAR, sizeof(uint8_t));
// open file
fp = fopen(argv[2], "r");