summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2023-06-28 22:48:12 (GMT)
committerGitHub <noreply@github.com>2023-06-28 22:48:12 (GMT)
commitaebac33a1f290fa5065bce96bb0512317a34c283 (patch)
treecdbae6dbd65a2eb4e6f786921ee907cec92c92d3 /c++
parent605cea4af60cfcbe03a54f697de392eec75e5a85 (diff)
downloadhdf5-aebac33a1f290fa5065bce96bb0512317a34c283.zip
hdf5-aebac33a1f290fa5065bce96bb0512317a34c283.tar.gz
hdf5-aebac33a1f290fa5065bce96bb0512317a34c283.tar.bz2
Remove HD from memory allocate/free calls (#3195)
* HDcalloc * HDfree * HDmalloc * HDrealloc
Diffstat (limited to 'c++')
-rw-r--r--c++/test/tattr.cpp2
-rw-r--r--c++/test/tcompound.cpp56
-rw-r--r--c++/test/tdspl.cpp12
-rw-r--r--c++/test/titerate.cpp2
-rw-r--r--c++/test/trefer.cpp48
-rw-r--r--c++/test/tvlstr.cpp40
6 files changed, 80 insertions, 80 deletions
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp
index 4a35763..fe27cb5 100644
--- a/c++/test/tattr.cpp
+++ b/c++/test/tattr.cpp
@@ -1663,7 +1663,7 @@ test_string_attr(FileAccPropList &fapl)
if (HDstrcmp(string_att_check, ATTRSTR_DATA.c_str()) != 0)
TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",
__LINE__, ATTRSTR_DATA.c_str(), string_att_check);
- HDfree(string_att_check);
+ free(string_att_check);
/* Test Attribute::read(...,H5std_string& strg) with VL string */
// Read and verify the attribute string as an std::string.
diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp
index 96073d6..b59f59c 100644
--- a/c++/test/tcompound.cpp
+++ b/c++/test/tcompound.cpp
@@ -100,9 +100,9 @@ test_compound_2()
SUBTEST("Compound Element Reordering");
try {
// Sizes should be the same, but be careful just in case
- buf = static_cast<unsigned char *>(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
- bkg = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(dst_typ_t)));
- orig = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(src_typ_t)));
+ buf = static_cast<unsigned char *>(malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
+ bkg = static_cast<unsigned char *>(malloc(nelmts * sizeof(dst_typ_t)));
+ orig = static_cast<unsigned char *>(malloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
s_ptr->a = i * 8 + 0;
@@ -161,9 +161,9 @@ test_compound_2()
}
}
// Release resources
- HDfree(buf);
- HDfree(bkg);
- HDfree(orig);
+ free(buf);
+ free(bkg);
+ free(orig);
s_ptr = NULL;
d_ptr = NULL;
st.close();
@@ -213,9 +213,9 @@ test_compound_3()
SUBTEST("Compound Datatype Subset Conversions");
try {
/* Initialize */
- buf = static_cast<unsigned char *>(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
- bkg = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(dst_typ_t)));
- orig = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(src_typ_t)));
+ buf = static_cast<unsigned char *>(malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
+ bkg = static_cast<unsigned char *>(malloc(nelmts * sizeof(dst_typ_t)));
+ orig = static_cast<unsigned char *>(malloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
s_ptr->a = i * 8 + 0;
@@ -271,9 +271,9 @@ test_compound_3()
}
/* Release resources */
- HDfree(buf);
- HDfree(bkg);
- HDfree(orig);
+ free(buf);
+ free(bkg);
+ free(orig);
s_ptr = NULL;
d_ptr = NULL;
st.close();
@@ -328,9 +328,9 @@ test_compound_4()
SUBTEST("Compound Element Shrinking & Reordering");
try {
/* Sizes should be the same, but be careful just in case */
- buf = static_cast<unsigned char *>(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
- bkg = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(dst_typ_t)));
- orig = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(src_typ_t)));
+ buf = static_cast<unsigned char *>(malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
+ bkg = static_cast<unsigned char *>(malloc(nelmts * sizeof(dst_typ_t)));
+ orig = static_cast<unsigned char *>(malloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
s_ptr->a = i * 8 + 0;
@@ -390,9 +390,9 @@ test_compound_4()
} // for
/* Release resources */
- HDfree(buf);
- HDfree(bkg);
- HDfree(orig);
+ free(buf);
+ free(bkg);
+ free(orig);
s_ptr = NULL;
d_ptr = NULL;
st.close();
@@ -439,8 +439,8 @@ test_compound_5()
hsize_t dims[1] = {4};
src_typ_t src[2] = {{"one", 102, {104, 105, 106, 107}}, {"two", 202, {204, 205, 206, 207}}};
dst_typ_t *dst;
- void *buf = HDcalloc(2, sizeof(dst_typ_t));
- void *bkg = HDcalloc(2, sizeof(dst_typ_t));
+ void *buf = calloc(2, sizeof(dst_typ_t));
+ void *bkg = calloc(2, sizeof(dst_typ_t));
ArrayType *array_dt = NULL;
// Output message about test being performed
@@ -490,8 +490,8 @@ test_compound_5()
}
/* Free memory buffers */
- HDfree(buf);
- HDfree(bkg);
+ free(buf);
+ free(bkg);
dst = NULL;
PASSED();
} // end of try block
@@ -539,9 +539,9 @@ test_compound_6()
SUBTEST("Compound Element Growing");
try {
/* Sizes should be the same, but be careful just in case */
- buf = static_cast<unsigned char *>(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
- bkg = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(dst_typ_t)));
- orig = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(src_typ_t)));
+ buf = static_cast<unsigned char *>(malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
+ bkg = static_cast<unsigned char *>(malloc(nelmts * sizeof(dst_typ_t)));
+ orig = static_cast<unsigned char *>(malloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
s_ptr->b = (i * 8 + 1) & 0x7fff;
@@ -574,9 +574,9 @@ test_compound_6()
}
/* Release resources */
- HDfree(buf);
- HDfree(bkg);
- HDfree(orig);
+ free(buf);
+ free(bkg);
+ free(orig);
s_ptr = NULL;
d_ptr = NULL;
st.close();
diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp
index 308285f..e076c5a 100644
--- a/c++/test/tdspl.cpp
+++ b/c++/test/tdspl.cpp
@@ -60,12 +60,12 @@ test_transfplist()
// Find out the length of the transform expression, allocate the buffer
// for it, then read and verify the expression from the copied plist
size_t tran_len = static_cast<size_t>(dxpl_c_to_f_copy.getDataTransform(NULL));
- char *c_to_f_read = static_cast<char *>(HDmalloc(tran_len + 1));
+ char *c_to_f_read = static_cast<char *>(malloc(tran_len + 1));
HDmemset(c_to_f_read, 0, tran_len + 1);
dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len + 1);
verify_val(const_cast<const char *>(c_to_f_read), const_cast<const char *>(c_to_f),
"DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
- HDfree(c_to_f_read);
+ free(c_to_f_read);
//
// Read the expression of each of the prop lists and verify the read
@@ -75,12 +75,12 @@ test_transfplist()
// Get and verify the expression with:
// ssize_t getDataTransform(char* exp, const size_t buf_size [default=0])
tran_len = static_cast<size_t>(dxpl_c_to_f.getDataTransform(NULL));
- c_to_f_read = static_cast<char *>(HDmalloc(tran_len + 1));
+ c_to_f_read = static_cast<char *>(malloc(tran_len + 1));
HDmemset(c_to_f_read, 0, tran_len + 1);
dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len + 1);
verify_val(const_cast<const char *>(c_to_f_read), const_cast<const char *>(c_to_f),
"DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
- HDfree(c_to_f_read);
+ free(c_to_f_read);
// Get and verify the expression with:
// H5std_string DSetMemXferPropList::getDataTransform()
@@ -91,12 +91,12 @@ test_transfplist()
// Get and verify the expression with:
// ssize_t getDataTransform(char* exp, const size_t buf_size)
tran_len = static_cast<size_t>(dxpl_utrans_inv.getDataTransform(NULL, 0));
- char *utrans_inv_read = static_cast<char *>(HDmalloc(tran_len + 1));
+ char *utrans_inv_read = static_cast<char *>(malloc(tran_len + 1));
HDmemset(utrans_inv_read, 0, tran_len + 1);
dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len + 1);
verify_val(const_cast<const char *>(utrans_inv_read), const_cast<const char *>(utrans_inv),
"DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
- HDfree(utrans_inv_read);
+ free(utrans_inv_read);
PASSED();
}
diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp
index 70eb25f..a360595 100644
--- a/c++/test/titerate.cpp
+++ b/c++/test/titerate.cpp
@@ -267,7 +267,7 @@ test_iter_group(FileAccPropList &fapl)
/* Free the dataset names */
for (int i = 0; i < NDATASETS + 2; i++)
- HDfree(lnames[i]);
+ free(lnames[i]);
// Everything will be closed as they go out of scope
diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp
index fc7931f..f207eb7 100644
--- a/c++/test/trefer.cpp
+++ b/c++/test/trefer.cpp
@@ -80,9 +80,9 @@ test_reference_params()
// Allocate write & read buffers
size_t temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t));
- wbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
- rbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
- tbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
+ wbuf = static_cast<hobj_ref_t *>(malloc(temp_size * SPACE1_DIM1));
+ rbuf = static_cast<hobj_ref_t *>(malloc(temp_size * SPACE1_DIM1));
+ tbuf = static_cast<hobj_ref_t *>(malloc(temp_size * SPACE1_DIM1));
// Create file FILE1
file1 = new H5File(FILE1, H5F_ACC_TRUNC);
@@ -168,9 +168,9 @@ test_reference_params()
// Let sid1 go out of scope
// Free memory buffers
- HDfree(wbuf);
- HDfree(rbuf);
- HDfree(tbuf);
+ free(wbuf);
+ free(rbuf);
+ free(tbuf);
PASSED();
} // end try
@@ -206,9 +206,9 @@ test_reference_obj()
// Allocate write & read buffers
size_t temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t));
- wbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
- rbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
- tbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
+ wbuf = static_cast<hobj_ref_t *>(malloc(temp_size * SPACE1_DIM1));
+ rbuf = static_cast<hobj_ref_t *>(malloc(temp_size * SPACE1_DIM1));
+ tbuf = static_cast<hobj_ref_t *>(malloc(temp_size * SPACE1_DIM1));
// Create file FILE1
file1 = new H5File(FILE1, H5F_ACC_TRUNC);
@@ -368,9 +368,9 @@ test_reference_obj()
file1->close();
// Free allocated buffers
- HDfree(wbuf);
- HDfree(rbuf);
- HDfree(tbuf);
+ free(wbuf);
+ free(rbuf);
+ free(tbuf);
PASSED();
} // end try
@@ -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 *>(HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1));
- rbuf = static_cast<hdset_reg_ref_t *>(HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1));
- dwbuf = static_cast<uint8_t *>(HDmalloc(sizeof(uint8_t) * SPACE3_DIM1));
- drbuf = static_cast<uint8_t *>(HDcalloc(sizeof(uint8_t), SPACE3_DIM1));
+ 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));
// Create file FILE1
H5File file1(FILE2, H5F_ACC_TRUNC);
@@ -714,7 +714,7 @@ test_reference_region_1D()
/* Allocate space for the hyperslab blocks */
coords =
- static_cast<hsize_t *>(HDmalloc(static_cast<size_t>(nelms) * SPACE3_RANK * sizeof(hsize_t) * 2));
+ static_cast<hsize_t *>(malloc(static_cast<size_t>(nelms) * SPACE3_RANK * sizeof(hsize_t) * 2));
// Get the list of hyperslab blocks currently selected
reg_sp.getSelectHyperBlocklist(0, static_cast<hsize_t>(nelms), coords);
@@ -751,7 +751,7 @@ test_reference_region_1D()
verify_val(static_cast<long>(coords[28]), 72, "Hyperslab Coordinates", __LINE__, __FILE__);
verify_val(static_cast<long>(coords[29]), 73, "Hyperslab Coordinates", __LINE__, __FILE__);
- HDfree(coords);
+ free(coords);
// Check boundaries
reg_sp.getSelectBounds(low, high);
@@ -774,7 +774,7 @@ test_reference_region_1D()
/* Allocate space for the hyperslab blocks */
coords =
- static_cast<hsize_t *>(HDmalloc(static_cast<size_t>(nelmspts) * SPACE3_RANK * sizeof(hsize_t)));
+ static_cast<hsize_t *>(malloc(static_cast<size_t>(nelmspts) * SPACE3_RANK * sizeof(hsize_t)));
// Get the list of element points currently selected
elm_sp.getSelectElemPointlist(0, static_cast<hsize_t>(nelmspts), coords);
@@ -791,7 +791,7 @@ test_reference_region_1D()
verify_val(coords[8], coord1[8][0], "Element Coordinates", __LINE__, __FILE__);
verify_val(coords[9], coord1[9][0], "Element Coordinates", __LINE__, __FILE__);
- HDfree(coords);
+ free(coords);
// Check boundaries
elm_sp.getSelectBounds(low, high);
@@ -808,10 +808,10 @@ test_reference_region_1D()
file1.close();
// Free memory buffers
- HDfree(wbuf);
- HDfree(rbuf);
- HDfree(dwbuf);
- HDfree(drbuf);
+ free(wbuf);
+ free(rbuf);
+ free(dwbuf);
+ free(drbuf);
PASSED();
} // end try
diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp
index 1cde7f1..3f5848e 100644
--- a/c++/test/tvlstr.cpp
+++ b/c++/test/tvlstr.cpp
@@ -65,7 +65,7 @@ static void *test_vlstr_alloc_custom(size_t size, void *info)
extra=MAX(sizeof(void *),sizeof(size_t));
- if((ret_value=HDmalloc(extra+size))!=NULL) {
+ if((ret_value=malloc(extra+size))!=NULL) {
*(size_t *)ret_value=size;
*mem_used+=size;
} // end if
@@ -108,7 +108,7 @@ static void test_vlstr_free_custom(void *_mem, void *info)
if(_mem!=NULL) {
mem=((unsigned char *)_mem)-extra;
*mem_used-=*(size_t *)mem;
- HDfree(mem);
+ free(mem);
} // end if
}
#endif
@@ -166,7 +166,7 @@ test_vlstring_dataset()
TestErrPrintf("Line %d: Attribute data different: DSET1_DATA=%s,string_ds_check=%s\n", __LINE__,
DSET1_DATA.c_str(), string_ds_check);
- HDfree(string_ds_check); // note: no need for std::string test
+ free(string_ds_check); // note: no need for std::string test
string_ds_check = NULL;
// Read and verify the dataset string as an std::string.
@@ -182,7 +182,7 @@ test_vlstring_dataset()
// Test scalar type dataset with 1 value.
dset1 = root.createDataSet("test_scalar_small", vlst, ds_space);
- dynstring_ds_write = static_cast<char *>(HDcalloc(2, sizeof(char)));
+ dynstring_ds_write = static_cast<char *>(calloc(2, sizeof(char)));
HDmemset(dynstring_ds_write, 'A', 1);
// Write data to the dataset, then read it back.
@@ -193,7 +193,7 @@ test_vlstring_dataset()
if (HDstrcmp(string_ds_check, dynstring_ds_write) != 0)
TestErrPrintf("VL string datasets don't match!, dynstring_ds_write=%s, string_ds_check=%s\n",
dynstring_ds_write, string_ds_check);
- HDfree(string_ds_check);
+ free(string_ds_check);
string_ds_check = NULL;
dset1.close();
@@ -213,9 +213,9 @@ test_vlstring_dataset()
}
if (dynstring_ds_write)
- HDfree(dynstring_ds_write);
+ free(dynstring_ds_write);
if (string_ds_check)
- HDfree(string_ds_check);
+ free(string_ds_check);
} // test_vlstring_dataset()
/*-------------------------------------------------------------------------
@@ -268,7 +268,7 @@ test_vlstring_array_dataset()
TestErrPrintf("Line %d: Dataset data different: written=%s,read=%s\n", __LINE__,
string_ds_array[ii], string_ds_check[ii]);
- HDfree(string_ds_check[ii]);
+ free(string_ds_check[ii]);
}
// Close objects that are no longer needed.
@@ -284,7 +284,7 @@ test_vlstring_array_dataset()
// Create and write another dataset.
DataSet dataset2(file1->createDataSet("Dataset2", vlst, scalar_space));
- char *wdata2 = static_cast<char *>(HDcalloc(65534, sizeof(char)));
+ char *wdata2 = static_cast<char *>(calloc(65534, sizeof(char)));
HDmemset(wdata2, 'A', 65533);
dataset2.write(&wdata2, vlst);
@@ -296,8 +296,8 @@ test_vlstring_array_dataset()
// Release resources from second dataset operation.
scalar_space.close();
dataset2.close();
- HDfree(wdata2);
- HDfree(rdata2);
+ free(wdata2);
+ free(rdata2);
// Close objects and file.
dataset2.close();
@@ -662,7 +662,7 @@ test_vlstring_attribute()
TestErrPrintf("Line %d: Attribute data different: ATTRSTR_DATA=%s,string_att_check=%s\n",
__LINE__, ATTRSTR_DATA.c_str(), string_att_check);
- HDfree(string_att_check); // note: no need for std::string test
+ free(string_att_check); // note: no need for std::string test
// Read and verify the attribute string as an std::string.
H5std_string read_str;
@@ -677,7 +677,7 @@ test_vlstring_attribute()
// Test creating a "large" sized string attribute
gr_attr = root.createAttribute("test_scalar_large", vlst, att_space);
- string_att_write = static_cast<char *>(HDcalloc(8192, sizeof(char)));
+ string_att_write = static_cast<char *>(calloc(8192, sizeof(char)));
HDmemset(string_att_write, 'A', 8191);
// Write data to the attribute, then read it back.
@@ -690,8 +690,8 @@ test_vlstring_attribute()
string_att_write, string_att_check);
// Release resources.
- HDfree(string_att_check);
- HDfree(string_att_write);
+ free(string_att_check);
+ free(string_att_write);
gr_attr.close();
file1.close();
@@ -739,7 +739,7 @@ static void test_read_vl_string_attribute()
att.read(vlst, &string_att_check);
if(HDstrcmp(string_att_check,ATTRSTR_DATA.c_str())!=0)
TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",ATTRSTR_DATA.c_str(),string_att_check);
- HDfree(string_att_check);
+ free(string_att_check);
att.close();
// Test reading "large" sized string attribute
@@ -747,8 +747,8 @@ static void test_read_vl_string_attribute()
att.read(vlst, &string_att_check);
if(HDstrcmp(string_att_check,string_att_write)!=0)
TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check);
- HDfree(string_att_check);
- HDfree(string_att_write); // Free string allocated in test_write_vl_string_attribute
+ free(string_att_check);
+ free(string_att_write); // Free string allocated in test_write_vl_string_attribute
// Close objects and file.
att.close();
@@ -821,7 +821,7 @@ test_vlstring_array_attribute()
TestErrPrintf("Line %d: Attribute data different: written=%s,read=%s\n", __LINE__,
string_att_check[ii], string_att_check[ii]);
- HDfree(string_att_check[ii]); // note: no need for std::string test
+ free(string_att_check[ii]); // note: no need for std::string test
}
// Close group's attribute.
@@ -869,7 +869,7 @@ read_scalar_dset(H5File &file, DataType &type, DataSpace &space, char *name, cha
if (HDstrcmp(data, data_read) != 0)
TestErrPrintf("Expected %s for dataset %s but read %s\n", data, name, data_read);
- HDfree(data_read);
+ free(data_read);
} // end try
catch (FileIException &ferr) {
throw;