Skip to content

Commit

Permalink
Fix flipped calloc args (HDFGroup#5198)
Browse files Browse the repository at this point in the history
* Fix flipped calloc args in C++ tests
  • Loading branch information
derobins authored Jan 2, 2025
1 parent 655403a commit be3f299
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions c++/test/trefer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,10 @@ test_reference_region_1D()
*drbuf; // Buffer for reading numeric data from disk

// Allocate write & read buffers
wbuf = static_cast<hdset_reg_ref_t *>(calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1));
rbuf = static_cast<hdset_reg_ref_t *>(malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1));
dwbuf = static_cast<uint8_t *>(malloc(sizeof(uint8_t) * SPACE3_DIM1));
drbuf = static_cast<uint8_t *>(calloc(sizeof(uint8_t), SPACE3_DIM1));
wbuf = static_cast<hdset_reg_ref_t *>(calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t)));
rbuf = static_cast<hdset_reg_ref_t *>(calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t)));
dwbuf = static_cast<uint8_t *>(calloc(SPACE3_DIM1, sizeof(uint8_t)));
drbuf = static_cast<uint8_t *>(calloc(SPACE3_DIM1, sizeof(uint8_t)));

// Create file FILE1
H5File file1(FILE2, H5F_ACC_TRUNC);
Expand Down
2 changes: 1 addition & 1 deletion tools/src/h5repack/h5repack_refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ copy_refs_attr(hid_t loc_in, hid_t loc_out, trav_table_t *travt, hid_t fidout) /
* create output
*-------------------------------------------------------------------------
*/
refbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
refbuf = (hdset_reg_ref_t *)calloc((size_t)nelmts, sizeof(hdset_reg_ref_t)); /*init to zero */
if (refbuf == NULL) {
printf("cannot allocate memory\n");
H5TOOLS_GOTO_ERROR((-1), "calloc failed");
Expand Down
10 changes: 5 additions & 5 deletions tools/test/h5dump/h5dumpgentest.c
Original file line number Diff line number Diff line change
Expand Up @@ -2406,10 +2406,10 @@ gent_attrreg(void)
int i; /* counting variables */

/* Allocate write & read buffers */
wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
rbuf = (hdset_reg_ref_t *)malloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1);
dwbuf = (uint8_t *)malloc(sizeof(uint8_t) * SPACE2_DIM1 * SPACE2_DIM2);
drbuf = (uint8_t *)calloc(sizeof(uint8_t), SPACE2_DIM1 * SPACE2_DIM2);
wbuf = (hdset_reg_ref_t *)calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t));
rbuf = (hdset_reg_ref_t *)calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t));
dwbuf = (uint8_t *)calloc(SPACE2_DIM1 * SPACE2_DIM2, sizeof(uint8_t));
drbuf = (uint8_t *)calloc(SPACE2_DIM1 * SPACE2_DIM2, sizeof(uint8_t));

/* Create file */
fid1 = H5Fcreate(FILE64, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
Expand Down Expand Up @@ -3121,7 +3121,7 @@ gent_array1_big(void)
block[0] = 1;

/* Allocate write & read buffers */
wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1);
wbuf = (hdset_reg_ref_t *)calloc(SPACE1_DIM1, sizeof(hdset_reg_ref_t));
wdata = (int *)malloc(sizeof(int) * (size_t)(SPACE_ARRAY1BIG_DIM * ARRAY1BIG_DIM));

/* Allocate and initialize array data to write */
Expand Down

0 comments on commit be3f299

Please sign in to comment.