diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2011-02-06 03:30:19 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2011-02-06 03:30:19 (GMT) |
commit | 90727b65778c62d80f138496c6bf1a548ace5a23 (patch) | |
tree | 3882f921a6c69ade21cccb92310cff7ef9860c28 /c++/test/tcompound.cpp | |
parent | fceb72c657ee623aa5574208834dc38515170a72 (diff) | |
download | hdf5-90727b65778c62d80f138496c6bf1a548ace5a23.zip hdf5-90727b65778c62d80f138496c6bf1a548ace5a23.tar.gz hdf5-90727b65778c62d80f138496c6bf1a548ace5a23.tar.bz2 |
[svn-r20053] Description:
Bring r20052 from trunk to 1.8 branch:
Clean up Coverity warnings, and fix some style issues:
r19735:
Fix for memory leak in test/mf found by valgrind.
r19736:
Fix memory leak in h5repack. The buffer in copy_objects, when copying the
entire dataset at once, was not checked for the presence of a vlen, and vlen
storage was never reclaimed. Added check and call to H5D_vlen_reclaim().
r19772:
Change H5assert() to
if (H5T_VLEN != src->shared->type || H5T_VLEN != dst->shared->type)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype")
r19774:
removed unused priv.
r19775:
removed unused variables
r19778:
Fix memory leak comparing for variable length data types.
r19834:
Fixed memory leaks found by valgrind. Memory errors remain for another day.
Tested on:
Mac OS X/32 10.6.6 (amazon) w/debug & production
(h5committested on branch)
Diffstat (limited to 'c++/test/tcompound.cpp')
-rw-r--r-- | c++/test/tcompound.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index fb8bd17..fbb1219 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -115,7 +115,8 @@ static void test_compound_2() const int nelmts = NTESTELEM; const hsize_t four = 4; int i; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; + ArrayType *array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Reordering"); @@ -138,7 +139,7 @@ static void test_compound_2() memcpy(buf, orig, nelmts*sizeof(src_typ_t)); // Build hdf5 datatypes - ArrayType* array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); // Create an empty compound datatype CompType st(sizeof(src_typ_t)); @@ -148,6 +149,7 @@ static void test_compound_2() st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); array_dt->close(); + delete array_dt; array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -202,6 +204,9 @@ static void test_compound_2() cerr << "test_compound_2 in catch" << endl; issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } + + if(array_dt) + delete array_dt; } // test_compound_2() @@ -235,7 +240,8 @@ static void test_compound_3() int i; const int nelmts = NTESTELEM; const hsize_t four = 4; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; + ArrayType* array_dt = NULL; // Output message about test being performed SUBTEST("Compound Datatype Subset Conversions"); @@ -258,7 +264,7 @@ static void test_compound_3() memcpy(buf, orig, nelmts*sizeof(src_typ_t)); /* Build hdf5 datatypes */ - ArrayType* array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); // Create an empty compound datatype CompType st(sizeof(src_typ_t)); @@ -268,6 +274,7 @@ static void test_compound_3() st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); array_dt->close(); + delete array_dt; array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -319,6 +326,9 @@ static void test_compound_3() cerr << "test_compound_3 in catch" << endl; issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } + + if(array_dt) + delete array_dt; } // test_compound_3() @@ -357,7 +367,8 @@ static void test_compound_4() int i; const int nelmts = NTESTELEM; const hsize_t four = 4; - unsigned char *buf=NULL, *orig=NULL, *bkg=NULL; + unsigned char *buf = NULL, *orig = NULL, *bkg = NULL; + ArrayType* array_dt = NULL; // Output message about test being performed SUBTEST("Compound Element Shrinking & Reordering"); @@ -380,7 +391,7 @@ static void test_compound_4() memcpy(buf, orig, nelmts*sizeof(src_typ_t)); /* Build hdf5 datatypes */ - ArrayType* array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); + array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); // Create an empty compound datatype CompType st(sizeof(src_typ_t)); @@ -390,6 +401,7 @@ static void test_compound_4() st.insertMember("d", HOFFSET(src_typ_t, d), PredType::NATIVE_INT); st.insertMember("e", HOFFSET(src_typ_t, e), PredType::NATIVE_INT); array_dt->close(); + delete array_dt; array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four); @@ -446,6 +458,9 @@ static void test_compound_4() cerr << "test_compound_4 in catch" << endl; issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } + + if(array_dt) + delete array_dt; } // test_compound_4() @@ -486,16 +501,18 @@ static void test_compound_5() dst_typ_t *dst; 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 SUBTEST("Optimized Struct Converter"); try { /* Build datatypes */ - ArrayType* array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims); + array_dt = new ArrayType(PredType::NATIVE_SHORT, 1, dims); CompType short_array(4*sizeof(short)); short_array.insertMember("_", 0, *array_dt); array_dt->close(); + delete array_dt; CompType int_array(4*sizeof(int)); array_dt = new ArrayType(PredType::NATIVE_INT, 1, dims); @@ -545,6 +562,9 @@ static void test_compound_5() cerr << "test_compound_5 in catch" << endl; issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } + + if(array_dt) + delete array_dt; } // test_compound_5() |