malloc to calloc

This commit is contained in:
Jasmine Iwanek
2025-01-07 00:42:06 -05:00
parent f599e72114
commit 4e6f29a7d5
183 changed files with 245 additions and 493 deletions

View File

@@ -920,8 +920,7 @@ wd1007vse1_init(UNUSED(const device_t *info))
{
int c;
esdi_t *esdi = malloc(sizeof(esdi_t));
memset(esdi, 0x00, sizeof(esdi_t));
esdi_t *esdi = calloc(1, sizeof(esdi_t));
c = 0;
for (uint8_t d = 0; d < HDD_NUM; d++) {

View File

@@ -1249,10 +1249,9 @@ esdi_init(UNUSED(const device_t *info))
uint8_t c;
uint8_t i;
dev = malloc(sizeof(esdi_t));
dev = calloc(1, sizeof(esdi_t));
if (dev == NULL)
return (NULL);
memset(dev, 0x00, sizeof(esdi_t));
/* Mark as unconfigured. */
dev->irq_status = 0xff;

View File

@@ -504,8 +504,7 @@ cmd640_close(void *priv)
static void *
cmd640_init(const device_t *info)
{
cmd640_t *dev = (cmd640_t *) malloc(sizeof(cmd640_t));
memset(dev, 0x00, sizeof(cmd640_t));
cmd640_t *dev = (cmd640_t *) calloc(1, sizeof(cmd640_t));
dev->id = next_id | 0x60;

View File

@@ -391,8 +391,7 @@ cmd646_close(void *priv)
static void *
cmd646_init(const device_t *info)
{
cmd646_t *dev = (cmd646_t *) malloc(sizeof(cmd646_t));
memset(dev, 0x00, sizeof(cmd646_t));
cmd646_t *dev = (cmd646_t *) calloc(1, sizeof(cmd646_t));
dev->local = info->local;

View File

@@ -317,8 +317,7 @@ opti611_close(void *priv)
static void *
opti611_init(UNUSED(const device_t *info))
{
opti611_t *dev = (opti611_t *) malloc(sizeof(opti611_t));
memset(dev, 0, sizeof(opti611_t));
opti611_t *dev = (opti611_t *) calloc(1, sizeof(opti611_t));
dev->is_sec = info->local;

View File

@@ -578,8 +578,7 @@ sff_close(void *priv)
static void *
sff_init(UNUSED(const device_t *info))
{
sff8038i_t *dev = (sff8038i_t *) malloc(sizeof(sff8038i_t));
memset(dev, 0, sizeof(sff8038i_t));
sff8038i_t *dev = (sff8038i_t *) calloc(1, sizeof(sff8038i_t));
/* Make sure to only add IDE once. */
if (next_id == 0)

View File

@@ -353,8 +353,7 @@ w83769f_close(void *priv)
static void *
w83769f_init(const device_t *info)
{
w83769f_t *dev = (w83769f_t *) malloc(sizeof(w83769f_t));
memset(dev, 0x00, sizeof(w83769f_t));
w83769f_t *dev = (w83769f_t *) calloc(1, sizeof(w83769f_t));
dev->id = next_id | 0x60;

View File

@@ -744,8 +744,7 @@ mfm_init(UNUSED(const device_t *info))
int c;
st506_at_log("WD1003: ISA MFM/RLL Fixed Disk Adapter initializing ...\n");
mfm = malloc(sizeof(mfm_t));
memset(mfm, 0x00, sizeof(mfm_t));
mfm = calloc(1, sizeof(mfm_t));
c = 0;
for (uint8_t d = 0; d < HDD_NUM; d++) {

View File

@@ -1627,8 +1627,7 @@ st506_init(const device_t *info)
int i;
int c;
dev = (hdc_t *) malloc(sizeof(hdc_t));
memset(dev, 0x00, sizeof(hdc_t));
dev = (hdc_t *) calloc(1, sizeof(hdc_t));
dev->type = info->local & 255;
/* Set defaults for the controller. */

View File

@@ -1000,8 +1000,7 @@ xta_init(const device_t *info)
int max = XTA_NUM;
/* Allocate and initialize device block. */
dev = malloc(sizeof(hdc_t));
memset(dev, 0x00, sizeof(hdc_t));
dev = calloc(1, sizeof(hdc_t));
dev->type = info->local;
/* Do per-controller-type setup. */

View File

@@ -132,13 +132,11 @@ xtide_read(uint16_t port, void *priv)
static void *
xtide_init(const device_t *info)
{
xtide_t *xtide = malloc(sizeof(xtide_t));
xtide_t *xtide = calloc(1, sizeof(xtide_t));
memset(xtide, 0x00, sizeof(xtide_t));
rom_init(&xtide->bios_rom,
device_get_bios_file(info, device_get_config_bios("bios"), 0),
0xc8000, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL);
rom_init(&xtide->bios_rom,
device_get_bios_file(info, device_get_config_bios("bios"), 0),
0xc8000, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL);
xtide->ide_board = ide_xtide_init();
@@ -152,13 +150,11 @@ xtide_init(const device_t *info)
static void *
xtide_at_init(const device_t *info)
{
xtide_t *xtide = malloc(sizeof(xtide_t));
xtide_t *xtide = calloc(1, sizeof(xtide_t));
memset(xtide, 0x00, sizeof(xtide_t));
rom_init(&xtide->bios_rom,
device_get_bios_file(info, device_get_config_bios("bios"), 0),
0xc8000, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL);
rom_init(&xtide->bios_rom,
device_get_bios_file(info, device_get_config_bios("bios"), 0),
0xc8000, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL);
device_add(&ide_isa_2ch_device);
@@ -168,9 +164,7 @@ xtide_at_init(const device_t *info)
static void *
xtide_acculogic_init(UNUSED(const device_t *info))
{
xtide_t *xtide = malloc(sizeof(xtide_t));
memset(xtide, 0x00, sizeof(xtide_t));
xtide_t *xtide = calloc(1, sizeof(xtide_t));
rom_init(&xtide->bios_rom, ROM_PATH_PS2,
0xc8000, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL);
@@ -203,9 +197,7 @@ xtide_close(void *priv)
static void *
xtide_at_ps2_init(UNUSED(const device_t *info))
{
xtide_t *xtide = malloc(sizeof(xtide_t));
memset(xtide, 0x00, sizeof(xtide_t));
xtide_t *xtide = calloc(1, sizeof(xtide_t));
rom_init(&xtide->bios_rom, ROM_PATH_PS2AT,
0xc8000, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL);