chg: use calloc

This commit is contained in:
iceman1001 2019-01-30 21:16:20 +01:00
parent e81b0fa355
commit 99b6087b01
7 changed files with 9 additions and 9 deletions

View file

@ -90,7 +90,7 @@ static int close_buffer(void *cookie)
FILE *open_memstream(char **bufptr, size_t *lenptr)
{
struct Buffer *b = (struct Buffer *)malloc(sizeof(struct Buffer));
struct Buffer *b = (struct Buffer *)calloc(sizeof(struct Buffer), sizeof(uint8_t));
if (b == NULL)
return NULL;
b->alloc = 0;

View file

@ -196,7 +196,7 @@ void SetFlushAfterWrite(bool value) {
int i,j;
int * output = (int* ) malloc(sizeof(int) * len);
int * output = (int* ) calloc(sizeof(int) * len, sizeof(uint8_t));
if ( !output ) return;
// clear mem

View file

@ -884,8 +884,8 @@ extern void strcreplace(char *buf, size_t len, char from, char to) {
}
extern char *strmcopy(char *buf) {
char* str = NULL;
if ((str = (char*) malloc(strlen(buf) + 1)) != NULL) {
char* str = (char*) calloc(strlen(buf) + 1, sizeof(uint8_t));
if (str != NULL) {
memset(str, 0, strlen(buf) + 1);
strcpy(str, buf);
}

View file

@ -405,7 +405,7 @@ int nonce_distance(uint32_t from, uint32_t to)
{
uint16_t x, i;
if(!dist) {
dist = malloc(2 << 16);
dist = calloc(2 << 16, sizeof(uint8_t));
if(!dist)
return -1;
for (x = i = 1; i; ++i) {
@ -443,7 +443,7 @@ static uint32_t fastfwd[2][8] = {
*/
uint32_t *lfsr_prefix_ks(uint8_t ks[8], int isodd)
{
uint32_t *candidates = malloc(4 << 10);
uint32_t *candidates = calloc(4 << 10, sizeof(uint8_t));
if (!candidates) return 0;
uint32_t c, entry;

View file

@ -3,7 +3,7 @@
uint64_t * radixSort(uint64_t * array, uint32_t size) {
rscounts_t counts;
memset(&counts, 0, 256 * 8 * sizeof(uint32_t));
uint64_t * cpy = (uint64_t *)malloc(size * sizeof(uint64_t));
uint64_t * cpy = (uint64_t *)calloc(size * sizeof(uint64_t), sizeof(uint8_t));
uint32_t o8=0, o7=0, o6=0, o5=0, o4=0, o3=0, o2=0, o1=0;
uint32_t t8, t7, t6, t5, t4, t3, t2, t1;
uint32_t x;

View file

@ -75,7 +75,7 @@ const struct timeval timeout = {
serial_port uart_open(const char* pcPortName)
{
serial_port_unix* sp = malloc(sizeof(serial_port_unix));
serial_port_unix* sp = calloc(sizeof(serial_port_unix), sizeof(uint8_t));
if (sp == 0) return INVALID_SERIAL_PORT;
if (memcmp(pcPortName, "tcp:", 4) == 0) {

View file

@ -50,7 +50,7 @@ typedef struct {
serial_port uart_open(const char* pcPortName) {
char acPortName[255];
serial_port_windows* sp = malloc(sizeof(serial_port_windows));
serial_port_windows* sp = calloc(sizeof(serial_port_windows), sizeof(uint8_t));
if (sp == 0) {
printf("[!] UART failed to allocate memory\n");