Code improvement

Description:
    - Removed memory leaks caused by accidentally invoking p_get_member_type
    - Added the call to test_lcpl, missed previously
Platforms tested:
    Linux/64 (jelly)
    Linux/ppc64 (ostrich)
    Darwin (osx1010test)
This commit is contained in:
Binh-Minh Ribler 2018-03-12 00:53:16 -05:00
parent 5a0d8d0d16
commit b638bbd74b
2 changed files with 26 additions and 25 deletions

View File

@ -304,7 +304,7 @@ DataType CompType::getMemberDataType(unsigned member_num) const
ArrayType CompType::getMemberArrayType(unsigned member_num) const
{
try {
ArrayType arraytype(p_get_member_type(member_num));
ArrayType arraytype;
f_DataType_setId(&arraytype, p_get_member_type(member_num));
return(arraytype);
}
@ -324,10 +324,10 @@ ArrayType CompType::getMemberArrayType(unsigned member_num) const
//--------------------------------------------------------------------------
CompType CompType::getMemberCompType(unsigned member_num) const
{
try {
CompType comptype(p_get_member_type(member_num));
try {
CompType comptype;
f_DataType_setId(&comptype, p_get_member_type(member_num));
return(comptype);
return(comptype);
}
catch (DataTypeIException& E) {
throw DataTypeIException("CompType::getMemberCompType", E.getDetailMsg());
@ -345,10 +345,10 @@ CompType CompType::getMemberCompType(unsigned member_num) const
//--------------------------------------------------------------------------
EnumType CompType::getMemberEnumType(unsigned member_num) const
{
try {
EnumType enumtype(p_get_member_type(member_num));
try {
EnumType enumtype;
f_DataType_setId(&enumtype, p_get_member_type(member_num));
return(enumtype);
return(enumtype);
}
catch (DataTypeIException& E) {
throw DataTypeIException("CompType::getMemberEnumType", E.getDetailMsg());
@ -366,10 +366,10 @@ EnumType CompType::getMemberEnumType(unsigned member_num) const
//--------------------------------------------------------------------------
IntType CompType::getMemberIntType(unsigned member_num) const
{
try {
IntType inttype(p_get_member_type(member_num));
try {
IntType inttype;
f_DataType_setId(&inttype, p_get_member_type(member_num));
return(inttype);
return(inttype);
}
catch (DataTypeIException& E) {
throw DataTypeIException("CompType::getMemberIntType", E.getDetailMsg());
@ -387,10 +387,10 @@ IntType CompType::getMemberIntType(unsigned member_num) const
//--------------------------------------------------------------------------
FloatType CompType::getMemberFloatType(unsigned member_num) const
{
try {
FloatType floatype(p_get_member_type(member_num));
try {
FloatType floatype;
f_DataType_setId(&floatype, p_get_member_type(member_num));
return(floatype);
return(floatype);
}
catch (DataTypeIException& E) {
throw DataTypeIException("CompType::getMemberFloatType", E.getDetailMsg());
@ -408,10 +408,10 @@ FloatType CompType::getMemberFloatType(unsigned member_num) const
//--------------------------------------------------------------------------
StrType CompType::getMemberStrType(unsigned member_num) const
{
try {
StrType strtype(p_get_member_type(member_num));
try {
StrType strtype;
f_DataType_setId(&strtype, p_get_member_type(member_num));
return(strtype);
return(strtype);
}
catch (DataTypeIException& E) {
throw DataTypeIException("CompType::getMemberStrType", E.getDetailMsg());
@ -429,10 +429,10 @@ StrType CompType::getMemberStrType(unsigned member_num) const
//--------------------------------------------------------------------------
VarLenType CompType::getMemberVarLenType(unsigned member_num) const
{
try {
VarLenType varlentype(p_get_member_type(member_num));
try {
VarLenType varlentype;
f_DataType_setId(&varlentype, p_get_member_type(member_num));
return(varlentype);
return(varlentype);
}
catch (DataTypeIException& E) {
throw DataTypeIException("CompType::getMemberVarLenType", E.getDetailMsg());

View File

@ -448,7 +448,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format)
*/
const H5std_string GROUP1NAME("First_group");
const H5std_string GROUP2NAME("Second_group");
static int
static void
test_lcpl(hid_t fapl_id, hbool_t new_format)
{
H5L_info_t linfo;
@ -456,9 +456,9 @@ test_lcpl(hid_t fapl_id, hbool_t new_format)
hsize_t dims[2];
if(new_format)
TESTING("link creation property lists (w/new group format)")
SUBTEST("Link creation property lists (w/new group format)")
else
TESTING("link creation property lists")
SUBTEST("Link creation property lists")
try
{
@ -466,7 +466,7 @@ test_lcpl(hid_t fapl_id, hbool_t new_format)
// Create a new file.
h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename);
H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl_id);
H5File file(filename, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl);
// Create and link a group with the default LCPL.
Group grp_1(file.createGroup(GROUP1NAME));
@ -478,12 +478,12 @@ test_lcpl(hid_t fapl_id, hbool_t new_format)
throw InvalidActionException("H5Lget_info", "Character encoding is not default");
// Create and commit a datatype with the default LCPL.
IntType dtype;
IntType dtype(PredType::NATIVE_INT);
dtype.commit(file, "/type");
dtype.close();
// Check that its character encoding is the default.
linfo = file.getLinkInfo("type");
linfo = file.getLinkInfo("/type");
verify_val(linfo.cset, H5T_CSET_ASCII, "Character encoding is not default", __LINE__, __FILE__);
// Create a simple dataspace.
@ -894,6 +894,7 @@ void test_links()
test_basic_links(my_fapl_id, new_format);
test_move(my_fapl_id, new_format);
test_copy(my_fapl_id, new_format);
test_lcpl(my_fapl_id, new_format);
} /* end for */
/* Close 2nd FAPL */