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

@@ -2314,8 +2314,7 @@ fdc_close(void *priv)
static void *
fdc_init(const device_t *info)
{
fdc_t *fdc = (fdc_t *) malloc(sizeof(fdc_t));
memset(fdc, 0, sizeof(fdc_t));
fdc_t *fdc = (fdc_t *) calloc(1, sizeof(fdc_t));
fdc->flags = info->local;

View File

@@ -90,8 +90,7 @@ b215_close(void *priv)
static void *
b215_init(UNUSED(const device_t *info))
{
b215_t *dev = (b215_t *) malloc(sizeof(b215_t));
memset(dev, 0, sizeof(b215_t));
b215_t *dev = (b215_t *) calloc(1, sizeof(b215_t));
rom_init(&dev->rom, ROM_B215, ROM_ADDR, 0x2000, 0x1fff, 0, MEM_MAPPING_EXTERNAL);

View File

@@ -13,7 +13,7 @@
* Authors: Jasmine Iwanek, <jasmine@iwanek.co.uk>
* Miran Grca, <mgrca8@gmail.com>
*
* Copyright 2022-2024 Jasmine Iwanek.
* Copyright 2022-2025 Jasmine Iwanek.
* Copyright 2024 Miran Grca.
*/
#include <stdarg.h>

View File

@@ -97,8 +97,7 @@ pii_init(const device_t *info)
{
pii_t *dev;
dev = (pii_t *) malloc(sizeof(pii_t));
memset(dev, 0, sizeof(pii_t));
dev = (pii_t *) calloc(1, sizeof(pii_t));
if (BIOS_ADDR != 0)
rom_init(&dev->bios_rom, DTK_VARIANT, BIOS_ADDR, 0x2000, 0x1ffff, 0, MEM_MAPPING_EXTERNAL);

View File

@@ -2731,8 +2731,7 @@ d86f_prepare_sector(int drive, int side, int prev_pos, uint8_t *id_buf, uint8_t
uint16_t datadam_mfm = 0x4A55;
if (fdd_get_turbo(drive) && (dev->version == 0x0063)) {
s = (sector_t *) malloc(sizeof(sector_t));
memset(s, 0, sizeof(sector_t));
s = (sector_t *) calloc(1, sizeof(sector_t));
s->c = id_buf[0];
s->h = id_buf[1];
s->r = id_buf[2];
@@ -3921,8 +3920,7 @@ d86f_setup(int drive)
d86f_t *dev;
/* Allocate a drive structure. */
dev = (d86f_t *) malloc(sizeof(d86f_t));
memset(dev, 0x00, sizeof(d86f_t));
dev = (d86f_t *) calloc(1, sizeof(d86f_t));
dev->state = STATE_IDLE;
dev->last_side_sector[0] = NULL;

View File

@@ -316,15 +316,13 @@ fdi_load(int drive, char *fn)
writeprot[drive] = fwriteprot[drive] = 1;
/* Allocate a drive block. */
dev = (fdi_t *) malloc(sizeof(fdi_t));
dev = (fdi_t *) calloc(1, sizeof(fdi_t));
if (dev == NULL) {
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
return;
}
memset(dev, 0x00, sizeof(fdi_t));
d86f_unregister(drive);
dev->fp = plat_fopen(fn, "rb");

View File

@@ -635,8 +635,7 @@ imd_load(int drive, char *fn)
writeprot[drive] = 0;
/* Allocate a drive block. */
dev = (imd_t *) malloc(sizeof(imd_t));
memset(dev, 0x00, sizeof(imd_t));
dev = (imd_t *) calloc(1, sizeof(imd_t));
dev->fp = plat_fopen(fn, "rb+");
if (dev->fp == NULL) {

View File

@@ -681,8 +681,7 @@ img_load(int drive, char *fn)
writeprot[drive] = 0;
/* Allocate a drive block. */
dev = (img_t *) malloc(sizeof(img_t));
memset(dev, 0x00, sizeof(img_t));
dev = (img_t *) calloc(1, sizeof(img_t));
dev->fp = plat_fopen(fn, "rb+");
if (dev->fp == NULL) {

View File

@@ -396,8 +396,7 @@ mfm_load(int drive, char *fn)
writeprot[drive] = fwriteprot[drive] = 1;
/* Allocate a drive block. */
dev = (mfm_t *) malloc(sizeof(mfm_t));
memset(dev, 0x00, sizeof(mfm_t));
dev = (mfm_t *) calloc(1, sizeof(mfm_t));
dev->fp = plat_fopen(fn, "rb");
if (dev->fp == NULL) {

View File

@@ -617,8 +617,7 @@ pcjs_load(int drive, char *fn)
d86f_unregister(drive);
/* Allocate a drive block */
dev = (pcjs_t *) malloc(sizeof(pcjs_t));
memset(dev, 0x00, sizeof(pcjs_t));
dev = (pcjs_t *) calloc(1, sizeof(pcjs_t));
/* Open the image file, read-only */
dev->fp = plat_fopen(fn, "rb");

View File

@@ -1214,8 +1214,7 @@ td0_load(int drive, char *fn)
writeprot[drive] = 1;
dev = (td0_t *) malloc(sizeof(td0_t));
memset(dev, 0x00, sizeof(td0_t));
dev = (td0_t *) calloc(1, sizeof(td0_t));
td0[drive] = dev;
dev->fp = plat_fopen(fn, "rb");