{
struct fio_client *client;
- client = malloc(sizeof(*client));
- memset(client, 0, sizeof(*client));
+ client = calloc(1, sizeof(*client));
INIT_FLIST_HEAD(&client->list);
INIT_FLIST_HEAD(&client->hash_list);
dprint(FD_NET, "send remote ini %s to %s\n", filename, client->hostname);
p_size = sizeof(*pdu) + strlen(filename) + 1;
- pdu = malloc(p_size);
- memset(pdu, 0, p_size);
+ pdu = calloc(1, p_size);
pdu->name_len = strlen(filename);
strcpy((char *) pdu->file, filename);
pdu->client_type = cpu_to_le16((uint16_t) client->type);
return 1;
}
- ed = malloc(sizeof(*ed));
+ ed = calloc(1, sizeof(*ed));
if (!ed) {
td_verror(td, ENOMEM, "io_queue_init");
return 1;
}
- memset(ed, 0 ,sizeof(*ed));
if (td->o.directory)
len = sprintf(donor_name, "%s/", td->o.directory);
/* default to off, as that's always safe */
o->nonvectored = 0;
- p = malloc(sizeof(*p) + 256 * sizeof(struct io_uring_probe_op));
+ p = calloc(1, sizeof(*p) + 256 * sizeof(struct io_uring_probe_op));
if (!p)
return;
- memset(p, 0, sizeof(*p) + 256 * sizeof(struct io_uring_probe_op));
ret = syscall(__NR_io_uring_register, ld->ring_fd,
IORING_REGISTER_PROBE, p, 256);
if (ret < 0)
uint64_t file_size, total_file_size;
if (!td->io_ops_data) {
- hd = malloc(sizeof(*hd));
- memset(hd, 0, sizeof(*hd));
+ hd = calloc(1, sizeof(*hd));
hd->curr_file_id = -1;
struct scsi_readcapacity16 *rc16 = NULL;
int ret = 0;
- iscsi_lun = malloc(sizeof(struct iscsi_lun));
- memset(iscsi_lun, 0, sizeof(struct iscsi_lun));
+ iscsi_lun = calloc(1, sizeof(struct iscsi_lun));
iscsi_lun->iscsi_info = iscsi_info;
}
if (!td->io_ops_data) {
- nd = malloc(sizeof(*nd));
-
- memset(nd, 0, sizeof(*nd));
+ nd = calloc(1, sizeof(*nd));
nd->listenfd = -1;
nd->pipes[0] = nd->pipes[1] = -1;
td->io_ops_data = nd;
return -1;
}
- options->events = malloc(event_size);
- memset(options->events, 0, event_size);
+ options->events = calloc(1, event_size);
options->prev_requested_event_index = -1;
options->queue_depth = td->o.iodepth;
options->nfs_url, ret, nfs_get_error(options->context));
return ret;
}
- nfs_data = malloc(sizeof(struct nfs_data));
- memset(nfs_data, 0, sizeof(struct nfs_data));
+ nfs_data = calloc(1, sizeof(struct nfs_data));
nfs_data->options = options;
if (td->o.td_ddir == TD_DDIR_WRITE)
memset(nd, 0, sizeof(*nd));
if (td->o.iodepth != 1) {
- nd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
- memset(nd->io_us, 0, td->o.iodepth * sizeof(struct io_u *));
+ nd->io_us = calloc(td->o.iodepth, sizeof(struct io_u *));
td->io_ops->flags |= FIO_ASYNCIO_SETS_ISSUE_TIME;
} else
td->io_ops->flags |= FIO_SYNCIO;
static int fio_posixaio_init(struct thread_data *td)
{
struct posixaio_data *pd;
- pd = malloc(sizeof(*pd));
-
- memset(pd, 0, sizeof(*pd));
- pd->aio_events = malloc(td->o.iodepth * sizeof(struct io_u *));
- memset(pd->aio_events, 0, td->o.iodepth * sizeof(struct io_u *));
+ pd = calloc(1, sizeof(*pd));
+ pd->aio_events = calloc(td->o.iodepth, sizeof(struct io_u *));
td->io_ops_data = pd;
return 0;
if ((rd->rdma_protocol == FIO_RDMA_MEM_WRITE) ||
(rd->rdma_protocol == FIO_RDMA_MEM_READ)) {
- rd->rmt_us =
- malloc(FIO_RDMA_MAX_IO_DEPTH * sizeof(struct remote_u));
- memset(rd->rmt_us, 0,
- FIO_RDMA_MAX_IO_DEPTH * sizeof(struct remote_u));
+ rd->rmt_us = calloc(FIO_RDMA_MAX_IO_DEPTH,
+ sizeof(struct remote_u));
rd->rmt_nr = 0;
}
- rd->io_us_queued = malloc(td->o.iodepth * sizeof(struct io_u *));
- memset(rd->io_us_queued, 0, td->o.iodepth * sizeof(struct io_u *));
+ rd->io_us_queued = calloc(td->o.iodepth, sizeof(struct io_u *));
rd->io_u_queued_nr = 0;
- rd->io_us_flight = malloc(td->o.iodepth * sizeof(struct io_u *));
- memset(rd->io_us_flight, 0, td->o.iodepth * sizeof(struct io_u *));
+ rd->io_us_flight = calloc(td->o.iodepth, sizeof(struct io_u *));
rd->io_u_flight_nr = 0;
- rd->io_us_completed = malloc(td->o.iodepth * sizeof(struct io_u *));
- memset(rd->io_us_completed, 0, td->o.iodepth * sizeof(struct io_u *));
+ rd->io_us_completed = calloc(td->o.iodepth, sizeof(struct io_u *));
rd->io_u_completed_nr = 0;
if (td_read(td)) { /* READ as the server */
for (i = 0; i < td->io_u_freelist.nr; i++) {
struct io_u *io_u = td->io_u_freelist.io_us[i];
- io_u->engine_data = malloc(sizeof(struct rdma_io_u_data));
- memset(io_u->engine_data, 0, sizeof(struct rdma_io_u_data));
+ io_u->engine_data = calloc(1, sizeof(struct rdma_io_u_data));
((struct rdma_io_u_data *)io_u->engine_data)->wr_id = i;
io_u->mr = ibv_reg_mr(rd->pd, io_u->buf, max_bs,
}
if (!td->io_ops_data) {
- rd = malloc(sizeof(*rd));
-
- memset(rd, 0, sizeof(*rd));
+ rd = calloc(1, sizeof(*rd));
init_rand_seed(&rd->rand_state, (unsigned int) GOLDEN_RATIO_64, 0);
td->io_ops_data = rd;
}
{
unsigned int max_depth;
struct solarisaio_data *sd;
- sd = malloc(sizeof(*sd));
- memset(sd, 0, sizeof(*sd));
+ sd = calloc(1, sizeof(*sd));
max_depth = td->o.iodepth;
if (max_depth > MAXASYNCHIO) {
max_depth);
}
- sd->aio_events = malloc(max_depth * sizeof(struct io_u *));
- memset(sd->aio_events, 0, max_depth * sizeof(struct io_u *));
+ sd->aio_events = calloc(max_depth, sizeof(struct io_u *));
sd->max_depth = max_depth;
#ifdef USE_SIGNAL_COMPLETIONS
{
struct syncio_data *sd;
- sd = malloc(sizeof(*sd));
- memset(sd, 0, sizeof(*sd));
+ sd = calloc(1, sizeof(*sd));
sd->last_offset = -1ULL;
sd->iovecs = malloc(td->o.iodepth * sizeof(struct iovec));
sd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
if (!ddir_rw_sum(disp_io_bytes))
fill_start_time(&disp_prev_time);
- eta_secs = malloc(thread_number * sizeof(uint64_t));
- memset(eta_secs, 0, thread_number * sizeof(uint64_t));
+ eta_secs = calloc(thread_number, sizeof(uint64_t));
je->elapsed_sec = (mtime_since_genesis() + 999) / 1000;
return NULL;
*size = sizeof(*je) + THREAD_RUNSTR_SZ + 8;
- je = malloc(*size);
+ je = calloc(1, *size);
if (!je)
return NULL;
- memset(je, 0, *size);
if (!calc_thread_status(je, force)) {
free(je);
if (bs > left)
bs = left;
- b = malloc(bs);
+ b = calloc(1, bs);
if (!b) {
td_verror(td, errno, "malloc");
ret = false;
goto error;
}
- memset(b, 0, bs);
if (lseek(f->fd, f->file_offset, SEEK_SET) < 0) {
td_verror(td, errno, "lseek");
{
struct gui_entry *ge;
- ge = malloc(sizeof(*ge));
- memset(ge, 0, sizeof(*ge));
+ ge = calloc(1, sizeof(*ge));
ge->state = GE_STATE_NEW;
ge->ui = ui;
return ge;
struct graph *g = i->parent;
struct graph_value *x;
- x = malloc(sizeof(*x));
- memset(x, 0, sizeof(*x));
+ x = calloc(1, sizeof(*x));
INIT_FLIST_HEAD(&x->alias);
INIT_FLIST_HEAD(&x->list);
flist_add_tail(&x->list, &i->value_list);
* it's really 256 + small bit, 280 should suffice
*/
if (!nested) {
- name = malloc(280);
- memset(name, 0, 280);
+ name = calloc(1, 280);
}
opts = NULL;
struct io_uring_probe *p;
int ret;
- p = malloc(sizeof(*p) + 256 * sizeof(struct io_uring_probe_op));
+ p = calloc(1, sizeof(*p) + 256 * sizeof(struct io_uring_probe_op));
if (!p)
return;
- memset(p, 0, sizeof(*p) + 256 * sizeof(struct io_uring_probe_op));
ret = syscall(__NR_io_uring_register, fd, IORING_REGISTER_PROBE, p, 256);
if (ret < 0)
goto out;
/* Create verification table */
if (verify) {
v_size = numbers * sizeof(uint8_t);
- v = malloc(v_size);
- memset(v, 0, v_size);
+ v = calloc(1, v_size);
printf("\nVerification table is %lf KiB\n", (double)(v_size) / 1024);
}
v_start = v;
*sz = sizeof(*rep);
*sz += nr * sizeof(struct thread_io_list);
*sz += depth * sizeof(struct file_comp);
- rep = malloc(*sz);
- memset(rep, 0, *sz);
+ rep = calloc(1, *sz);
rep->threads = cpu_to_le64((uint64_t) nr);