mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 07:16:14 +08:00
style. we use calloc
This commit is contained in:
parent
d906f23a0a
commit
482a6464a2
|
@ -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);
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue