malloc to calloc
This commit is contained in:
@@ -192,8 +192,7 @@ catalyst_flash_init(UNUSED(const device_t *info))
|
||||
FILE *fp;
|
||||
flash_t *dev;
|
||||
|
||||
dev = malloc(sizeof(flash_t));
|
||||
memset(dev, 0, sizeof(flash_t));
|
||||
dev = calloc(1, sizeof(flash_t));
|
||||
|
||||
sprintf(flash_path, "%s.bin", machine_get_internal_name_ex(machine));
|
||||
|
||||
|
||||
@@ -128,8 +128,7 @@ log2i(uint32_t i)
|
||||
void *
|
||||
i2c_eeprom_init(void *i2c, uint8_t addr, uint8_t *data, uint32_t size, uint8_t writable)
|
||||
{
|
||||
i2c_eeprom_t *dev = (i2c_eeprom_t *) malloc(sizeof(i2c_eeprom_t));
|
||||
memset(dev, 0, sizeof(i2c_eeprom_t));
|
||||
i2c_eeprom_t *dev = (i2c_eeprom_t *) calloc(1, sizeof(i2c_eeprom_t));
|
||||
|
||||
/* Round size up to the next power of 2. */
|
||||
uint32_t pow_size = 1 << log2i(size);
|
||||
|
||||
@@ -351,8 +351,7 @@ intel_flash_init(const device_t *info)
|
||||
flash_t *dev;
|
||||
uint8_t type = info->local & 0xff;
|
||||
|
||||
dev = malloc(sizeof(flash_t));
|
||||
memset(dev, 0, sizeof(flash_t));
|
||||
dev = calloc(1, sizeof(flash_t));
|
||||
|
||||
sprintf(flash_path, "%s.bin", machine_get_internal_name_ex(machine));
|
||||
|
||||
|
||||
@@ -245,12 +245,11 @@ smram_add(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
temp_smram = (smram_t *) malloc(sizeof(smram_t));
|
||||
temp_smram = (smram_t *) calloc(1, sizeof(smram_t));
|
||||
if (temp_smram == NULL) {
|
||||
fatal("smram_add(): temp_smram malloc failed\n");
|
||||
fatal("smram_add(): temp_smram calloc failed\n");
|
||||
return NULL;
|
||||
}
|
||||
memset(temp_smram, 0x00, sizeof(smram_t));
|
||||
memset(&(temp_smram->mapping), 0x00, sizeof(mem_mapping_t));
|
||||
|
||||
/* Add struct to the beginning of the list if necessary.*/
|
||||
|
||||
@@ -221,8 +221,7 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size)
|
||||
if (!(slot_mask & (1 << slot)))
|
||||
continue; /* slot disabled */
|
||||
|
||||
spd_modules[slot] = (spd_t *) malloc(sizeof(spd_t));
|
||||
memset(spd_modules[slot], 0, sizeof(spd_t));
|
||||
spd_modules[slot] = (spd_t *) calloc(1, sizeof(spd_t));
|
||||
spd_modules[slot]->slot = slot;
|
||||
spd_modules[slot]->size = rows[row];
|
||||
|
||||
|
||||
@@ -505,8 +505,7 @@ static void *
|
||||
sst_init(const device_t *info)
|
||||
{
|
||||
FILE *fp;
|
||||
sst_t *dev = malloc(sizeof(sst_t));
|
||||
memset(dev, 0, sizeof(sst_t));
|
||||
sst_t *dev = calloc(1, sizeof(sst_t));
|
||||
|
||||
sprintf(flash_path, "%s.bin", machine_get_internal_name_ex(machine));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user