Skip to content

Commit

Permalink
--Use calloc for buffers in the selection I/O tests
Browse files Browse the repository at this point in the history
--Try memset again in H5Dscatgath_read()
  • Loading branch information
vchoi-hdfgroup committed Sep 18, 2023
1 parent 98fac7f commit 83ef7c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
9 changes: 2 additions & 7 deletions src/H5Dscatgath.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,6 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_dset_io_info_t *dset_
(size_t)MIN(dset_info->type_info.request_nelmts, (dset_info->nelmts - smine_start));
}

if (H5D__SCATGATH_USE_CMPD_OPT_READ(dset_info, in_place_tconv)) {
memset(tmp_buf, 0,
smine_nelmts *
MAX(dset_info->type_info.src_type_size, dset_info->type_info.dst_type_size));
}

/*
* Gather the data from disk into the datatype conversion
* buffer. Also gather data from application to background buffer
Expand All @@ -560,7 +554,8 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_dset_io_info_t *dset_
n = H5D__gather_mem(buf, bkg_iter, smine_nelmts, io_info->bkg_buf /*out*/);
if (n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "mem gather failed");
}
} else
memset(tmp_buf, 0, smine_nelmts * MAX(dset_info->type_info.src_type_size, dset_info->type_info.dst_type_size));

/*
* Gather data
Expand Down
16 changes: 8 additions & 8 deletions test/cmpd_dset.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,13 @@ test_select_src_subset(char *fname, hid_t fapl, hid_t in_dxpl, unsigned set_fill
goto error;

/* Allocate space and initialize data */
rbuf = (unsigned char *)malloc(NX * NY * sizeof(stype3));
rbuf = (unsigned char *)calloc(NX * NY, sizeof(stype3));

rew_buf = (unsigned char *)malloc(NX * NY * sizeof(stype3));
rew_buf = (unsigned char *)calloc(NX * NY, sizeof(stype3));
initialize_stype3(rew_buf, (size_t)NX * NY);

/* Save a copy as the buffer may be clobbered due to H5Pset_modify_write_buf() */
save_rew_buf = (unsigned char *)malloc(NX * NY * sizeof(stype3));
save_rew_buf = (unsigned char *)calloc(NX * NY, sizeof(stype3));
initialize_stype3(save_rew_buf, (size_t)NX * NY);

/* Create dataset creation property list */
Expand Down Expand Up @@ -639,15 +639,15 @@ test_select_compound(char *fname, hid_t fapl, hid_t in_dxpl, unsigned set_fillva
hsize_t memb_size[1] = {4};

/* Allocate buffers */
if (NULL == (s1 = (s1_t *)malloc(sizeof(s1_t) * NX * NY)))
if (NULL == (s1 = (s1_t *)calloc(NX * NY, sizeof(s1_t))))
goto error;
if (NULL == (rbuf1 = (s1_t *)malloc(sizeof(s1_t) * NX * NY)))
if (NULL == (rbuf1 = (s1_t *)calloc(NX * NY, sizeof(s1_t))))
goto error;
if (NULL == (s3 = (s3_t *)malloc(sizeof(s3_t) * NX * NY)))
if (NULL == (s3 = (s3_t *)calloc(NX * NY, sizeof(s3_t))))
goto error;
if (NULL == (save_s3 = (s3_t *)malloc(sizeof(s3_t) * NX * NY)))
if (NULL == (save_s3 = (s3_t *)calloc(NX * NY, sizeof(s3_t))))
goto error;
if (NULL == (rbuf3 = (s3_t *)malloc(sizeof(s3_t) * NX * NY)))
if (NULL == (rbuf3 = (s3_t *)calloc(NX * NY, sizeof(s3_t))))
goto error;

/* Create the file */
Expand Down

0 comments on commit 83ef7c2

Please sign in to comment.