diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2013-10-31 04:20:36 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2013-10-31 04:20:36 (GMT) |
commit | e6cace9ee46e903a8612aba7d9d1d72fa0968217 (patch) | |
tree | ac7d07ea06d3d5ac73e34bc54ff17620a4d083fe /tools | |
parent | 2eb24b16dac78b3e27769c20502299475fb8dde6 (diff) | |
download | hdf5-e6cace9ee46e903a8612aba7d9d1d72fa0968217.zip hdf5-e6cace9ee46e903a8612aba7d9d1d72fa0968217.tar.gz hdf5-e6cace9ee46e903a8612aba7d9d1d72fa0968217.tar.bz2 |
[svn-r24376] Updated all code to use HDmalloc, HDcalloc, and HDfree.
Prep work for adding a memory free function, part of HDFFV-8551.
Tested on:
32-bit LE linux (jam)
* with C++, Fortran
* with thread safety on
These are minor changes (almost entirely renaming foo functions
to HDfoo) that don't change functionality. This should not
require a full commit test.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5copy/h5copygentest.c | 12 | ||||
-rw-r--r-- | tools/h5diff/h5diff_common.c | 2 | ||||
-rw-r--r-- | tools/h5diff/h5diffgentest.c | 22 | ||||
-rw-r--r-- | tools/h5jam/getub.c | 4 | ||||
-rw-r--r-- | tools/h5repack/h5repacktst.c | 32 | ||||
-rw-r--r-- | tools/h5stat/h5stat.c | 8 | ||||
-rw-r--r-- | tools/misc/h5repart.c | 4 | ||||
-rw-r--r-- | tools/misc/talign.c | 10 |
8 files changed, 47 insertions, 47 deletions
diff --git a/tools/h5copy/h5copygentest.c b/tools/h5copy/h5copygentest.c index e45d24a..f51acd4 100644 --- a/tools/h5copy/h5copygentest.c +++ b/tools/h5copy/h5copygentest.c @@ -237,10 +237,10 @@ static void gent_named_vl(hid_t loc_id) /* allocate and initialize VL dataset to write */ buf[0].len = 1; - buf[0].p = malloc( 1 * sizeof(int)); + buf[0].p = HDmalloc( 1 * sizeof(int)); ((int *)buf[0].p)[0]=1; buf[1].len = 2; - buf[1].p = malloc( 2 * sizeof(int)); + buf[1].p = HDmalloc( 2 * sizeof(int)); ((int *)buf[1].p)[0]=2; ((int *)buf[1].p)[1]=3; @@ -283,16 +283,16 @@ static void gent_nested_vl(hid_t loc_id) /* allocate and initialize VL dataset to write */ buf[0].len = 1; - buf[0].p = malloc( 1 * sizeof(hvl_t)); + buf[0].p = HDmalloc( 1 * sizeof(hvl_t)); tvl = (hvl_t *)buf[0].p; - tvl->p = malloc( 1 * sizeof(int) ); + tvl->p = HDmalloc( 1 * sizeof(int) ); tvl->len = 1; ((int *)tvl->p)[0]=1; buf[1].len = 1; - buf[1].p = malloc( 1 * sizeof(hvl_t)); + buf[1].p = HDmalloc( 1 * sizeof(hvl_t)); tvl = (hvl_t *)buf[1].p; - tvl->p = malloc( 2 * sizeof(int) ); + tvl->p = HDmalloc( 2 * sizeof(int) ); tvl->len = 2; ((int *)tvl->p)[0]=2; ((int *)tvl->p)[1]=3; diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c index cf46e74..59cab0d 100644 --- a/tools/h5diff/h5diff_common.c +++ b/tools/h5diff/h5diff_common.c @@ -174,7 +174,7 @@ void parse_command_line(int argc, options->exclude_path = 1; /* create linked list of excluding objects */ - if( (exclude_node = (struct exclude_path_list*) malloc(sizeof(struct exclude_path_list))) == NULL) + if( (exclude_node = (struct exclude_path_list*) HDmalloc(sizeof(struct exclude_path_list))) == NULL) { printf("Error: lack of memory!\n"); h5diff_exit(EXIT_FAILURE); diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index d7389d3..d554abd 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -4475,7 +4475,7 @@ static void test_comps_vlen (const char * fname, const char *dset, const char *a for(i=0; i<SDIM_DSET; i++) { wdata[i].i1 = i; - wdata[i].vl.p = malloc((i+1)*sizeof(cmpd2_t)); + wdata[i].vl.p = HDmalloc((i+1)*sizeof(cmpd2_t)); wdata[i].vl.len = i+1; for(j=0; j<(i+1); j++) { @@ -4600,7 +4600,7 @@ static void test_comps_array_vlen (const char * fname, const char *dset,const ch for(j=0; j < SDIM_CMPD_ARRAY; j++) { wdata[i].cmpd2[j].i2 = j*10; - wdata[i].cmpd2[j].vl.p = malloc((j+1)*sizeof(cmpd3_t)); + wdata[i].cmpd2[j].vl.p = HDmalloc((j+1)*sizeof(cmpd3_t)); wdata[i].cmpd2[j].vl.len = j+1; for(k=0; k<(j+1); k++) { @@ -4744,7 +4744,7 @@ static void test_comps_vlen_arry (const char * fname, const char *dset, const ch { /* compound 1 data */ wdata[i].i1 = i; - wdata[i].vl.p = malloc((i+1)*sizeof(cmpd2_t)); + wdata[i].vl.p = HDmalloc((i+1)*sizeof(cmpd2_t)); wdata[i].vl.len = i+1; for(j=0; j<(i+1); j++) { @@ -5456,10 +5456,10 @@ void write_attr_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ buf5[0].len = 1; - buf5[0].p = malloc( 1 * sizeof(int)); + buf5[0].p = HDmalloc( 1 * sizeof(int)); ((int *)buf5[0].p)[0]=1; buf5[1].len = 2; - buf5[1].p = malloc( 2 * sizeof(int)); + buf5[1].p = HDmalloc( 2 * sizeof(int)); ((int *)buf5[1].p)[0]=2; ((int *)buf5[1].p)[1]=3; @@ -5743,7 +5743,7 @@ void write_attr_in(hid_t loc_id, n=0; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { - buf52[i][j].p = malloc((i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); buf52[i][j].len = i + 1; for (l = 0; l < i + 1; l++) if (make_diffs)((int *)buf52[i][j].p)[l] = 0; @@ -6159,7 +6159,7 @@ void write_attr_in(hid_t loc_id, for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { for (k = 0; k < 2; k++) { - buf53[i][j][k].p = malloc((i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); buf53[i][j][k].len = i + 1; for (l = 0; l < i + 1; l++) if (make_diffs)((int *)buf53[i][j][k].p)[l] = 0; @@ -6490,10 +6490,10 @@ void write_dset_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ buf5[0].len = 1; - buf5[0].p = malloc( 1 * sizeof(int)); + buf5[0].p = HDmalloc( 1 * sizeof(int)); ((int *)buf5[0].p)[0]=1; buf5[1].len = 2; - buf5[1].p = malloc( 2 * sizeof(int)); + buf5[1].p = HDmalloc( 2 * sizeof(int)); ((int *)buf5[1].p)[0]=2; ((int *)buf5[1].p)[1]=3; @@ -6703,7 +6703,7 @@ void write_dset_in(hid_t loc_id, { for(j = 0; j < 2; j++) { - buf52[i][j].p = malloc((i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); buf52[i][j].len = i + 1; for(l = 0; l < i + 1; l++) { @@ -6916,7 +6916,7 @@ void write_dset_in(hid_t loc_id, { for(k = 0; k < 2; k++) { - buf53[i][j][k].p = malloc((i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); buf53[i][j][k].len = i + 1; for(l = 0; l < i + 1; l++) { diff --git a/tools/h5jam/getub.c b/tools/h5jam/getub.c index d84f7f2..3aff2b4 100644 --- a/tools/h5jam/getub.c +++ b/tools/h5jam/getub.c @@ -165,7 +165,7 @@ main (int argc, const char *argv[]) if (res < (long)size) { if (buf) - free (buf); + HDfree (buf); HDclose (fd); exit (EXIT_FAILURE); } @@ -173,7 +173,7 @@ main (int argc, const char *argv[]) HDwrite (1, buf, (unsigned)size); if (buf) - free (buf); + HDfree (buf); HDclose (fd); return (EXIT_SUCCESS); } diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 791e268..ba6b499 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -3333,7 +3333,7 @@ int make_big(hid_t loc_id) goto out; /* initialize buffer to 0 */ - buf=(signed char *) calloc( nelmts, size); + buf=(signed char *) HDcalloc( nelmts, size); if (H5Sselect_hyperslab (f_sid,H5S_SELECT_SET,hs_start,NULL,hs_size, NULL) < 0) goto out; @@ -3814,10 +3814,10 @@ int write_dset_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ buf5[0].len = 1; - buf5[0].p = malloc( 1 * sizeof(int)); + buf5[0].p = HDmalloc( 1 * sizeof(int)); ((int *)buf5[0].p)[0]=1; buf5[1].len = 2; - buf5[1].p = malloc( 2 * sizeof(int)); + buf5[1].p = HDmalloc( 2 * sizeof(int)); ((int *)buf5[1].p)[0] = 2; ((int *)buf5[1].p)[1] = 3; @@ -3876,7 +3876,7 @@ int write_dset_in(hid_t loc_id, /* allocate and initialize array data to write */ size = ( TEST_BUFSIZE / sizeof(double) + 1 ) * sizeof(double); - dbuf = (double*)malloc( size ); + dbuf = (double*)HDmalloc( size ); if (NULL == dbuf) { printf ("\nError: Cannot allocate memory for \"arrayd\" data buffer size %dMB.\n", (int) size / 1000000 ); @@ -4050,7 +4050,7 @@ int write_dset_in(hid_t loc_id, { int l; - buf52[i][j].p = malloc((i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for(l = 0; l < i + 1; l++) { @@ -4271,7 +4271,7 @@ int write_dset_in(hid_t loc_id, { int l; - buf53[i][j][k].p = malloc((i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)(i + 1); for(l = 0; l < i + 1; l++) { @@ -4401,8 +4401,8 @@ int make_dset_reg_ref(hid_t loc_id) int retval = -1; /* return value */ /* Allocate write & read buffers */ - wbuf = (hdset_reg_ref_t *)calloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); - dwbuf = (int *)malloc(sizeof(int) * SPACE2_DIM1 * SPACE2_DIM2); + wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1); + dwbuf = (int *)HDmalloc(sizeof(int) * SPACE2_DIM1 * SPACE2_DIM2); /* Create dataspace for datasets */ if ((sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL)) < 0) @@ -4742,10 +4742,10 @@ int write_attr_in(hid_t loc_id, /* Allocate and initialize VL dataset to write */ buf5[0].len = 1; - buf5[0].p = malloc( 1 * sizeof(int)); + buf5[0].p = HDmalloc( 1 * sizeof(int)); ((int *)buf5[0].p)[0]=1; buf5[1].len = 2; - buf5[1].p = malloc(2 * sizeof(int)); + buf5[1].p = HDmalloc(2 * sizeof(int)); ((int *)buf5[1].p)[0] = 2; ((int *)buf5[1].p)[1] = 3; @@ -5062,7 +5062,7 @@ int write_attr_in(hid_t loc_id, for (j = 0; j < 2; j++) { int l; - buf52[i][j].p = malloc((i + 1) * sizeof(int)); + buf52[i][j].p = HDmalloc((i + 1) * sizeof(int)); buf52[i][j].len = (size_t)(i + 1); for (l = 0; l < i + 1; l++) if (make_diffs)((int *)buf52[i][j].p)[l] = 0; @@ -5528,7 +5528,7 @@ int write_attr_in(hid_t loc_id, for (k = 0; k < 2; k++) { int l; - buf53[i][j][k].p = malloc((i + 1) * sizeof(int)); + buf53[i][j][k].p = HDmalloc((i + 1) * sizeof(int)); buf53[i][j][k].len = (size_t)i + 1; for (l = 0; l < i + 1; l++) if (make_diffs) @@ -6754,11 +6754,11 @@ static herr_t make_complex_attr_references(hid_t loc_id) * prepare vlen data */ vlen_objref_data[0].len = LEN0_VLEN_OBJREF; - vlen_objref_data[0].p = malloc (vlen_objref_data[0].len * sizeof(hobj_ref_t)); + vlen_objref_data[0].p = HDmalloc (vlen_objref_data[0].len * sizeof(hobj_ref_t)); vlen_objref_data[1].len = LEN1_VLEN_OBJREF; - vlen_objref_data[1].p = malloc (vlen_objref_data[1].len * sizeof(hobj_ref_t)); + vlen_objref_data[1].p = HDmalloc (vlen_objref_data[1].len * sizeof(hobj_ref_t)); vlen_objref_data[2].len = LEN2_VLEN_OBJREF; - vlen_objref_data[2].p = malloc (vlen_objref_data[2].len * sizeof(hobj_ref_t)); + vlen_objref_data[2].p = HDmalloc (vlen_objref_data[2].len * sizeof(hobj_ref_t)); /* * create obj references @@ -6823,7 +6823,7 @@ static herr_t make_complex_attr_references(hid_t loc_id) * prepare vlen data */ vlen_regref_data[0].len = LEN0_VLEN_REGREF; - vlen_regref_data[0].p = malloc (vlen_regref_data[0].len * sizeof(hdset_reg_ref_t)); + vlen_regref_data[0].p = HDmalloc (vlen_regref_data[0].len * sizeof(hdset_reg_ref_t)); /* * create region reference diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c index a5d7eef..e9fa0fa 100644 --- a/tools/h5stat/h5stat.c +++ b/tools/h5stat/h5stat.c @@ -823,7 +823,7 @@ freespace_stats(hid_t fid, iter_t *iter) } /* end for */ if(sect_info) - free(sect_info); + HDfree(sect_info); return 0; } /* end freespace_stats() */ @@ -1756,9 +1756,9 @@ main(int argc, const char *argv[]) iter.free_hdr = finfo.free.meta_size; } /* end else */ - iter.num_small_groups = (unsigned long *)calloc((size_t)sgroups_threshold, sizeof(unsigned long)); - iter.num_small_attrs = (unsigned long *)calloc((size_t)(sattrs_threshold+1), sizeof(unsigned long)); - iter.small_dset_dims = (unsigned long *)calloc((size_t)sdsets_threshold, sizeof(unsigned long)); + iter.num_small_groups = (unsigned long *)HDcalloc((size_t)sgroups_threshold, sizeof(unsigned long)); + iter.num_small_attrs = (unsigned long *)HDcalloc((size_t)(sattrs_threshold+1), sizeof(unsigned long)); + iter.small_dset_dims = (unsigned long *)HDcalloc((size_t)sdsets_threshold, sizeof(unsigned long)); if(iter.num_small_groups == NULL || iter.num_small_attrs == NULL || iter.small_dset_dims == NULL) { error_msg("Unable to allocate memory for tracking small groups/datasets/attributes\n"); diff --git a/tools/misc/h5repart.c b/tools/misc/h5repart.c index 07f6bfd..ffd52e8 100644 --- a/tools/misc/h5repart.c +++ b/tools/misc/h5repart.c @@ -290,7 +290,7 @@ main (int argc, char *argv[]) if (argno<argc) usage (prog_name); /* Now the real work, split the file */ - buf = malloc (blk_size); + buf = HDmalloc (blk_size); while (src_offset<src_size) { /* Read a block. The amount to read is the minimum of: @@ -498,6 +498,6 @@ main (int argc, char *argv[]) } /* Free resources and return */ - free (buf); + HDfree (buf); return EXIT_SUCCESS; } diff --git a/tools/misc/talign.c b/tools/misc/talign.c index 017eb55..66318bf 100644 --- a/tools/misc/talign.c +++ b/tools/misc/talign.c @@ -126,7 +126,7 @@ int main(void) H5Dclose(set); /* Now open the set, and read it back in */ - data = (char *)malloc(H5Tget_size(fix)); + data = (char *)HDmalloc(H5Tget_size(fix)); if(!data) { perror("malloc() failed"); @@ -152,7 +152,7 @@ out: mname ? mname : "(null)", (int)H5Tget_member_offset(fix,0), string5, (char *)(data + H5Tget_member_offset(fix, 0))); if(mname) - free(mname); + HDfree(mname); fptr = (float *)(data + H5Tget_member_offset(fix, 1)); mname = H5Tget_member_name(fix, 1); @@ -163,7 +163,7 @@ out: (double)fok[0], (double)fptr[0], (double)fok[1], (double)fptr[1]); if(mname) - free(mname); + HDfree(mname); fptr = (float *)(data + H5Tget_member_offset(fix, 2)); mname = H5Tget_member_name(fix, 2); @@ -173,7 +173,7 @@ out: (double)fnok[0], (double)fptr[0], (double)fnok[1], (double)fptr[1]); if(mname) - free(mname); + HDfree(mname); fptr = (float *)(data + H5Tget_member_offset(fix, 1)); printf("\n" @@ -192,7 +192,7 @@ out: } if(data) - free(data); + HDfree(data); H5Sclose(spc); H5Tclose(cmp); H5Tclose(cmp1); |