summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2014-04-11 14:48:31 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2014-04-11 14:48:31 (GMT)
commit8a524752454c04a07a378b39abc929fd8948d91b (patch)
treee6ad7cc080461c68bdc7dda04df9da07026ce3a2
parent6240fb24e6e06039dada4bc7e23ca1a211a0ab2c (diff)
downloadhdf5-8a524752454c04a07a378b39abc929fd8948d91b.zip
hdf5-8a524752454c04a07a378b39abc929fd8948d91b.tar.gz
hdf5-8a524752454c04a07a378b39abc929fd8948d91b.tar.bz2
[svn-r25014] Purpose:
Merge of r24937 from the trunk Adds H5free_memory to the API. This function should be used to free memory allocated by the library (e.g., returned values from H5Tget_tag, H5Pget_class_name, etc.). This is mainly to help Windows applications deal with multiple CRT instances, but can also be helpful when a debug memory manager is being used or when the HDF5 API is being wrapped for managed languages like Python and Java. Tested on: 32-bit LE linux (jam) with fortran and C++ 64-bit BE linux (ostrich) 64-bit LE linux (koala)
-rw-r--r--c++/src/H5CompType.cpp2
-rw-r--r--c++/src/H5DataType.cpp2
-rw-r--r--c++/src/H5PropList.cpp2
-rw-r--r--fortran/src/H5Ef.c12
-rw-r--r--fortran/src/H5Pf.c2
-rw-r--r--fortran/src/H5Tf.c4
-rw-r--r--hl/src/H5LT.c6
-rw-r--r--hl/src/H5TB.c32
-rw-r--r--hl/test/test_lite.c12
-rw-r--r--release_docs/RELEASE.txt11
-rw-r--r--src/H5.c25
-rw-r--r--src/H5public.h1
-rw-r--r--test/dtypes.c13
-rw-r--r--test/err_compat.c16
-rw-r--r--test/tarray.c22
-rw-r--r--test/tattr.c2
-rw-r--r--test/tgenprop.c10
-rw-r--r--test/tunicode.c4
-rw-r--r--tools/h5dump/h5dump_xml.c9
-rw-r--r--tools/h5ls/h5ls.c6
-rw-r--r--tools/lib/h5tools_dump.c6
-rw-r--r--tools/lib/h5tools_str.c2
-rw-r--r--tools/misc/talign.c6
23 files changed, 121 insertions, 86 deletions
diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp
index 1846846..191f004 100644
--- a/c++/src/H5CompType.cpp
+++ b/c++/src/H5CompType.cpp
@@ -123,7 +123,7 @@ H5std_string CompType::getMemberName( unsigned member_num ) const
"H5Tget_member_name returns NULL for member name");
}
H5std_string member_name = H5std_string(member_name_C); // convert C string to string
- HDfree(member_name_C); // free the C string
+ H5free_memory(member_name_C); // free the C string
return( member_name ); // return the member name string
}
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 9e5b76e..c89210a 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -563,7 +563,7 @@ H5std_string DataType::getTag() const
if( tag_Cstr != NULL )
{
H5std_string tag = H5std_string(tag_Cstr); // C string to string object
- HDfree(tag_Cstr); // free the C string
+ H5free_memory(tag_Cstr); // free the C string
return (tag); // return the tag
}
else
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index a49995d..0b740d8 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -490,7 +490,7 @@ H5std_string PropList::getClassName() const
if (temp_str != NULL)
{
H5std_string class_name(temp_str);
- HDfree(temp_str);
+ H5free_memory(temp_str);
return(class_name);
}
else
diff --git a/fortran/src/H5Ef.c b/fortran/src/H5Ef.c
index 8c00ab7..4848d9e 100644
--- a/fortran/src/H5Ef.c
+++ b/fortran/src/H5Ef.c
@@ -143,8 +143,8 @@ done:
* NAME
* h5eget_major_c
* PURPOSE
- * Call H5Eget_major to get a character string
- * describing an error specified by a major error number.
+ * Get a character string describing an error specified by a
+ * major error number.
* INPUTS
* error_no - Major error number
* OUTPUTS
@@ -173,7 +173,7 @@ nh5eget_major_c(int_f* error_no, _fcd name, size_t_f* namelen)
HGOTO_DONE(FAIL)
/*
- * Call H5Eget_major function.
+ * Call H5Eget_msg function.
*/
H5Eget_msg((hid_t)*error_no, NULL, c_name, c_namelen);
HD5packFstring((char*)c_name, _fcdtocp(name), c_namelen);
@@ -191,8 +191,8 @@ done:
* NAME
* h5eget_minor_c
* PURPOSE
- * Call H5Eget_minor to get a character string
- * describing an error specified by a minor error number.
+ * Get a character string describing an error specified by a
+ * minor error number.
* INPUTS
* error_no - Major error number
* OUTPUTS
@@ -221,7 +221,7 @@ nh5eget_minor_c(int_f* error_no, _fcd name, size_t_f* namelen)
HGOTO_DONE(FAIL)
/*
- * Call H5Eget_minor function.
+ * Call H5Eget_msg function.
*/
H5Eget_msg((hid_t)*error_no, NULL, c_name, c_namelen);
HD5packFstring((char *)c_name, _fcdtocp(name), c_namelen);
diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c
index cf10efc..7a3f899 100644
--- a/fortran/src/H5Pf.c
+++ b/fortran/src/H5Pf.c
@@ -3388,7 +3388,7 @@ nh5pget_class_name_c(hid_t_f *cls, _fcd name, int_f *name_len)
HD5packFstring(c_name, _fcdtocp(name), (size_t)*name_len);
ret_value = (int_f)HDstrlen(c_name);
- HDfree(c_name);
+ H5free_memory(c_name);
DONE:
return ret_value;
diff --git a/fortran/src/H5Tf.c b/fortran/src/H5Tf.c
index c8ff6e0..df581ee 100644
--- a/fortran/src/H5Tf.c
+++ b/fortran/src/H5Tf.c
@@ -1280,7 +1280,7 @@ nh5tget_member_name_c ( hid_t_f *type_id ,int_f* idx, _fcd member_name, int_f *n
HD5packFstring(c_name, _fcdtocp(member_name), strlen(c_name));
*namelen = (int_f)strlen(c_name);
- HDfree(c_name);
+ H5free_memory(c_name);
ret_value = 0;
return ret_value;
}
@@ -1986,7 +1986,7 @@ nh5tget_tag_c(hid_t_f* type_id, _fcd tag, size_t_f* tag_size, int_f* taglen)
HD5packFstring(c_tag, _fcdtocp(tag), (size_t)*tag_size);
*taglen = (int_f)HDstrlen(c_tag);
- HDfree(c_tag);
+ H5free_memory(c_tag);
ret_value = 0;
return ret_value;
}
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c
index 96cd014..6da097c 100644
--- a/hl/src/H5LT.c
+++ b/hl/src/H5LT.c
@@ -2360,7 +2360,7 @@ print_enum(hid_t type, char* str, size_t *str_len, hbool_t no_ubuf, size_t indt)
/* Release resources */
for(i = 0; i < nmembs; i++)
- HDfree(name[i]);
+ H5free_memory(name[i]);
HDfree(name);
HDfree(value);
@@ -2745,7 +2745,7 @@ next:
if(tag) {
HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"%s\";\n", tag);
if(tag)
- HDfree(tag);
+ H5free_memory(tag);
tag = NULL;
} else
HDsnprintf(tmp_str, TMP_LEN, "OPQ_TAG \"\";\n");
@@ -2951,7 +2951,7 @@ next:
if(!(dt_str = realloc_and_append(no_user_buf, slen, dt_str, tmp_str)))
goto out;
if(mname)
- HDfree(mname);
+ H5free_memory(mname);
mname = NULL;
HDsnprintf(tmp_str, TMP_LEN, " : %lu;\n", (unsigned long)moffset);
diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c
index 0b6305b..0fa23bc 100644
--- a/hl/src/H5TB.c
+++ b/hl/src/H5TB.c
@@ -196,7 +196,7 @@ herr_t H5TBmake_table( const char *table_title,
if (H5LTset_attribute_string( loc_id, dset_name, attr_name, member_name ) < 0)
goto out;
- free( member_name );
+ H5free_memory( member_name );
}
@@ -234,7 +234,7 @@ herr_t H5TBmake_table( const char *table_title,
if (H5Aclose(attr_id) < 0)
goto out;
- free(member_name);
+ H5free_memory(member_name);
}
/* terminate access to the data space. */
@@ -570,7 +570,7 @@ herr_t H5TBwrite_fields_name( hid_t loc_id,
goto out;
}
- free( member_name );
+ H5free_memory( member_name );
}
@@ -734,7 +734,7 @@ herr_t H5TBwrite_fields_index( hid_t loc_id,
if(H5Tclose( nmtype_id ) < 0)
goto out;
- free( member_name );
+ H5free_memory( member_name );
}
@@ -1059,7 +1059,7 @@ herr_t H5TBread_fields_name( hid_t loc_id,
goto out;
j++;
}
- free( member_name );
+ H5free_memory( member_name );
}
/* get the dataspace handle */
@@ -1221,7 +1221,7 @@ herr_t H5TBread_fields_index( hid_t loc_id,
if (H5Tclose( nmtype_id ) < 0)
goto out;
- free( member_name );
+ H5free_memory( member_name );
}
/* get the dataspace handle */
@@ -2314,7 +2314,7 @@ herr_t H5TBinsert_field( hid_t loc_id,
curr_offset += member_size;
- free( member_name );
+ H5free_memory( member_name );
/* close the member type */
if(H5Tclose( member_type_id ) < 0)
@@ -2694,13 +2694,13 @@ herr_t H5TBdelete_field( hid_t loc_id,
if (H5Tclose( member_type_id ) < 0)
goto out;
- free( member_name );
+ H5free_memory( member_name );
break;
}
- free( member_name );
+ H5free_memory( member_name );
} /* i */
@@ -2742,7 +2742,7 @@ herr_t H5TBdelete_field( hid_t loc_id,
/* we want to skip the field to delete */
if (H5TB_find_field( member_name, field_name ) > 0 )
{
- free( member_name );
+ H5free_memory( member_name );
continue;
}
@@ -2780,7 +2780,7 @@ herr_t H5TBdelete_field( hid_t loc_id,
curr_offset += member_size;
- free(member_name);
+ H5free_memory(member_name);
/* close the member type */
if (H5Tclose(member_type_id) < 0)
@@ -2821,7 +2821,7 @@ herr_t H5TBdelete_field( hid_t loc_id,
/* skip the field to delete */
if (H5TB_find_field(member_name, field_name) > 0)
{
- free(member_name);
+ H5free_memory(member_name);
continue;
}
@@ -2881,8 +2881,8 @@ herr_t H5TBdelete_field( hid_t loc_id,
goto out;
/* release resources. */
- free( member_name );
- free ( tmp_buf );
+ H5free_memory( member_name );
+ HDfree ( tmp_buf );
} /* i */
@@ -3306,7 +3306,7 @@ herr_t H5TBget_field_info( hid_t loc_id,
member_name = H5Tget_member_name(tid, (unsigned)i);
strcpy(field_names[i], member_name);
- free(member_name);
+ H5free_memory(member_name);
} /* end if */
/* get the member type */
@@ -3459,7 +3459,7 @@ herr_t H5TB_attach_attributes( const char *table_title,
if (H5LTset_attribute_string( loc_id, dset_name, attr_name, member_name ) < 0)
goto out;
- free( member_name );
+ H5free_memory( member_name );
}
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index ad17206..a76f3d7 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -1551,10 +1551,10 @@ static int test_compounds(void)
if((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
goto out;
if(HDstrcmp(memb_name, "i16_field")) {
- HDfree(memb_name);
+ H5free_memory(memb_name);
goto out;
}
- HDfree(memb_name);
+ H5free_memory(memb_name);
if((memb_class = H5Tget_member_class(dtype, 2))<0)
goto out;
@@ -1619,10 +1619,10 @@ static int test_compound_bug(void)
if((memb_name = H5Tget_member_name(dtype, 2)) == NULL)
goto out;
if(HDstrcmp(memb_name, "sub")) {
- HDfree(memb_name);
+ H5free_memory(memb_name);
goto out;
}
- HDfree(memb_name);
+ H5free_memory(memb_name);
if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
goto out;
@@ -1656,10 +1656,10 @@ static int test_compound_bug(void)
if((memb_name = H5Tget_member_name(dtype, 1)) == NULL)
goto out;
if(HDstrcmp(memb_name, "desc_________________________________________________________________________________________")) {
- HDfree(memb_name);
+ H5free_memory(memb_name);
goto out;
}
- HDfree(memb_name);
+ H5free_memory(memb_name);
if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
goto out;
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 367d62d..c64dd55 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -63,7 +63,16 @@ New Features
Library
-------
- - None
+ - Added an H5free_memory API call. This should be used to free memory that
+ has been allocated by HDF5 API calls (e.g., H5Tget_member_name,
+ H5Pget_class_name, etc.). The main motivation for this call is Windows,
+ where it is common for application code and the HDF5 library to be using
+ different C run-time libraries. Using the new call ensures that the same
+ CRT handles both the allocation and free. This new function can also be
+ useful in any case where the library uses a different memory manager
+ than the application, such as when a debug memory manager is in use or
+ when the HDF5 library is wrapped for use in a managed language like
+ Python or Java. Fixes HDFFV-7710, 8519, and 8851. (DER - 2014/04/11)
Parallel Library
----------------
diff --git a/src/H5.c b/src/H5.c
index 1c6cae1..6354ad0 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -804,3 +804,28 @@ H5close(void)
FUNC_LEAVE_API_NOFS(SUCCEED)
} /* end H5close() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5free_memory
+ *
+ * Purpose: Frees memory allocated by the library that it is the user's
+ * responsibility to free. Ensures that the same library
+ * that was used to allocate the memory frees it. Passing
+ * NULL pointers is allowed.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5free_memory(void *mem)
+{
+ FUNC_ENTER_API_NOINIT
+ H5TRACE1("e", "*x", mem);
+
+ /* At this time, it is impossible for this to fail. */
+ HDfree(mem);
+
+ FUNC_LEAVE_API(SUCCEED)
+} /* end H5free_memory() */
+
diff --git a/src/H5public.h b/src/H5public.h
index 39427ed..4f7e7f7 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -334,6 +334,7 @@ H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum,
unsigned *relnum);
H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum,
unsigned relnum);
+H5_DLL herr_t H5free_memory(void *mem);
#ifdef __cplusplus
}
diff --git a/test/dtypes.c b/test/dtypes.c
index ae74202..de81bd5 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -651,7 +651,7 @@ test_compound_1(void)
error:
if(tag)
- HDfree(tag);
+ H5free_memory(tag);
return retval;
}
@@ -4423,7 +4423,7 @@ error:
if(buf)
HDfree(buf);
if(tag)
- HDfree(tag);
+ H5free_memory(tag); /* Technically allocated by API call */
reset_hdf5();
return ret_value; /* Number of errors */
@@ -4791,8 +4791,7 @@ test_bitfield_funcs(void)
error:
if (retval == -1) retval = 1;
-
- HDfree(tag);
+ H5free_memory(tag);
H5Tclose(ntype);
H5Tclose(type);
if (retval == 0) PASSED();
@@ -6474,7 +6473,7 @@ test_named_indirect_reopen(hid_t fapl)
if(dt_size != H5Tget_size(type)) TEST_ERROR
if(NULL == (tag_ret = H5Tget_tag(type))) TEST_ERROR
if(HDstrcmp(tag, tag_ret)) TEST_ERROR
- HDfree(tag_ret);
+ H5free_memory(tag_ret);
tag_ret = NULL;
/* Create dataset with opaque type */
@@ -6485,7 +6484,7 @@ test_named_indirect_reopen(hid_t fapl)
if(dt_size != H5Tget_size(reopened_type)) TEST_ERROR
if(NULL == (tag_ret = H5Tget_tag(type))) TEST_ERROR
if(HDstrcmp(tag, tag_ret)) TEST_ERROR
- HDfree(tag_ret);
+ H5free_memory(tag_ret);
tag_ret = NULL;
/* Close types and dataset */
@@ -6535,7 +6534,7 @@ error:
H5Fclose(file);
} H5E_END_TRY;
if(tag_ret)
- HDfree(tag_ret);
+ H5free_memory(tag_ret);
return 1;
} /* end test_named_indirect_reopen() */
diff --git a/test/err_compat.c b/test/err_compat.c
index c08e259..346d397 100644
--- a/test/err_compat.c
+++ b/test/err_compat.c
@@ -144,16 +144,16 @@ custom_print_cb1(int n, H5E_error1_t *err_desc, void* client_data)
fprintf(stream, "%*smajor: %s\n", indent * 2, "", maj);
fprintf(stream, "%*sminor: %s\n", indent * 2, "", min);
- HDfree(maj);
- HDfree(min);
+ H5free_memory(maj);
+ H5free_memory(min);
return 0;
error:
if(maj)
- HDfree(maj);
+ H5free_memory(maj);
if(min)
- HDfree(min);
+ H5free_memory(min);
return -1;
}
@@ -197,16 +197,16 @@ custom_print_cb2(int n, H5E_error2_t *err_desc, void* client_data)
fprintf(stream, "%*smajor: %s\n", indent * 2, "", maj);
fprintf(stream, "%*sminor: %s\n", indent * 2, "", min);
- HDfree(maj);
- HDfree(min);
+ H5free_memory(maj);
+ H5free_memory(min);
return 0;
error:
if(maj)
- HDfree(maj);
+ H5free_memory(maj);
if(min)
- HDfree(min);
+ H5free_memory(min);
return -1;
}
diff --git a/test/tarray.c b/test/tarray.c
index 2f0b002..2d6581b 100644
--- a/test/tarray.c
+++ b/test/tarray.c
@@ -637,7 +637,7 @@ test_array_compound_atomic(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(HDstrcmp(mname, "i") != 0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname);
- free(mname);
+ H5free_memory(mname);
/* Check the 1st field's offset */
off = H5Tget_member_offset(tid2, 0);
@@ -656,7 +656,7 @@ test_array_compound_atomic(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(HDstrcmp(mname, "f") != 0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n", mname);
- free(mname);
+ H5free_memory(mname);
/* Check the 2nd field's offset */
off = H5Tget_member_offset(tid2, 1);
@@ -849,7 +849,7 @@ test_array_compound_array(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(HDstrcmp(mname,"i")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- free(mname);
+ H5free_memory(mname);
/* Check the 1st field's offset */
off=H5Tget_member_offset(tid2,0);
@@ -868,7 +868,7 @@ test_array_compound_array(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(HDstrcmp(mname,"f")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- free(mname);
+ H5free_memory(mname);
/* Check the 2nd field's offset */
off=H5Tget_member_offset(tid2,1);
@@ -1855,7 +1855,7 @@ test_compat(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(HDstrcmp(mname,"i")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- free(mname);
+ H5free_memory(mname);
/* Check the 1st field's offset */
off=H5Tget_member_offset(tid1,0);
@@ -1874,7 +1874,7 @@ test_compat(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(HDstrcmp(mname,"f")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- free(mname);
+ H5free_memory(mname);
/* Check the 2nd field's offset */
off=H5Tget_member_offset(tid1,1);
@@ -1893,7 +1893,7 @@ test_compat(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(HDstrcmp(mname,"l")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- free(mname);
+ H5free_memory(mname);
/* Check the 3rd field's offset */
off=H5Tget_member_offset(tid1,2);
@@ -1937,7 +1937,7 @@ test_compat(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(mname && HDstrcmp(mname,"i")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- if(mname) free(mname);
+ if(mname) H5free_memory(mname);
/* Check the 1st field's offset */
off=H5Tget_member_offset(tid1,0);
@@ -1956,7 +1956,7 @@ test_compat(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(mname && HDstrcmp(mname,"f")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- if(mname) free(mname);
+ if(mname) H5free_memory(mname);
/* Check the 2nd field's offset */
off=H5Tget_member_offset(tid1,1);
@@ -2001,7 +2001,7 @@ test_compat(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(mname && HDstrcmp(mname,"l")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- if(mname) free(mname);
+ if(mname) H5free_memory(mname);
/* Check the 3rd field's offset */
off=H5Tget_member_offset(tid1,2);
@@ -2046,7 +2046,7 @@ test_compat(void)
CHECK(mname, NULL, "H5Tget_member_name");
if(mname && HDstrcmp(mname,"d")!=0)
TestErrPrintf("Compound field name doesn't match!, mname=%s\n",mname);
- if(mname) free(mname);
+ if(mname) H5free_memory(mname);
/* Check the 4th field's offset */
off=H5Tget_member_offset(tid1,3);
diff --git a/test/tattr.c b/test/tattr.c
index b23080c..e9430fe 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -829,7 +829,7 @@ test_attr_compound_read(hid_t fapl)
HDstrcmp(fieldname, ATTR4_FIELDNAME2) ||
HDstrcmp(fieldname, ATTR4_FIELDNAME3)))
TestErrPrintf("invalid field name for field #%d: %s\n", i, fieldname);
- free(fieldname);
+ H5free_memory(fieldname);
} /* end for */
offset = H5Tget_member_offset(type, 0);
VERIFY(offset, attr4_field1_off, "H5Tget_member_offset");
diff --git a/test/tgenprop.c b/test/tgenprop.c
index f304f11..4e93dd5 100644
--- a/test/tgenprop.c
+++ b/test/tgenprop.c
@@ -88,7 +88,7 @@ test_genprop_basic_class(void)
CHECK_PTR(name, "H5Pget_class_name");
if(HDstrcmp(name,CLASS1_NAME)!=0)
TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME);
- free(name);
+ H5free_memory(name);
/* Check class parent */
cid2 = H5Pget_class_parent(cid1);
@@ -119,7 +119,7 @@ test_genprop_basic_class(void)
CHECK_PTR(name, "H5Pget_class_name");
if(HDstrcmp(name,CLASS2_NAME)!=0)
TestErrPrintf("Class names don't match!, name=%s, CLASS2_NAME=%s\n",name,CLASS2_NAME);
- free(name);
+ H5free_memory(name);
/* Check class parent */
cid2 = H5Pget_class_parent(cid1);
@@ -1868,7 +1868,7 @@ test_genprop_refcount(void)
CHECK_PTR(name, "H5Pget_class_name");
if(HDstrcmp(name,CLASS1_NAME)!=0)
TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME);
- HDfree(name);
+ H5free_memory(name);
/* Close class */
ret = H5Pclose_class(cid1);
@@ -1887,7 +1887,7 @@ test_genprop_refcount(void)
CHECK_PTR(name, "H5Pget_class_name");
if(HDstrcmp(name,CLASS1_NAME)!=0)
TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME);
- HDfree(name);
+ H5free_memory(name);
/* Close list */
ret = H5Pclose(lid1);
@@ -1898,7 +1898,7 @@ test_genprop_refcount(void)
CHECK_PTR(name, "H5Pget_class_name");
if(HDstrcmp(name,CLASS1_NAME)!=0)
TestErrPrintf("Class names don't match!, name=%s, CLASS1_NAME=%s\n",name,CLASS1_NAME);
- HDfree(name);
+ H5free_memory(name);
/* Close class */
ret = H5Pclose_class(cid1);
diff --git a/test/tunicode.c b/test/tunicode.c
index 9725a9b..6f3e3a9 100644
--- a/test/tunicode.c
+++ b/test/tunicode.c
@@ -602,7 +602,7 @@ void test_compound(hid_t fid, const char * string)
readbuf = H5Tget_member_name(s1_tid, 0);
ret = HDstrcmp(readbuf, string);
VERIFY(ret, 0, "strcmp");
- free(readbuf);
+ H5free_memory(readbuf);
/* Add the other fields to the datatype */
ret = H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE);
@@ -715,7 +715,7 @@ void test_opaque(hid_t UNUSED fid, const char * string)
read_buf = H5Tget_tag(type_id);
ret = strcmp(read_buf, string);
VERIFY(ret, 0, "H5Tget_tag");
- free(read_buf);
+ H5free_memory(read_buf);
ret = H5Tclose(type_id);
CHECK(ret, FAIL, "H5Tclose");
diff --git a/tools/h5dump/h5dump_xml.c b/tools/h5dump/h5dump_xml.c
index b94879c..c081ee0 100644
--- a/tools/h5dump/h5dump_xml.c
+++ b/tools/h5dump/h5dump_xml.c
@@ -1216,7 +1216,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* Render the element */
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, mname);
- HDfree(mname);
+ H5free_memory(mname);
size = H5Tget_size(type);
h5tools_str_append(&buffer, "Size=\"%lu\"/>", (unsigned long)size);
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
@@ -1265,7 +1265,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
h5tools_str_append(&buffer, "<%sField FieldName=\"%s\">",xmlnsprefix, t_fname);
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
- HDfree(mname);
+ H5free_memory(mname);
HDfree(t_fname);
dump_indent += COL;
ctx.indent_level++;
@@ -3623,7 +3623,8 @@ xml_dump_fill_value(hid_t dcpl, hid_t type)
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\"%s\"", name);
h5tools_render_element(rawoutstream, outputformat, &ctx, &buffer, &curr_pos, (size_t)outputformat->line_ncols, (hsize_t)0, (hsize_t)0);
-
+ if(name)
+ H5free_memory(name);
ctx.need_prefix = TRUE;
h5tools_simple_prefix(rawoutstream, outputformat, &ctx, (hsize_t)0, 0);
@@ -4526,7 +4527,7 @@ xml_print_enum(hid_t type)
/* Release resources */
for (i = 0; i < nmembs; i++)
- HDfree(name[i]);
+ H5free_memory(name[i]);
HDfree(name);
HDfree(value);
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index f8933c6..257d4d1 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -849,7 +849,7 @@ print_cmpd_type(h5tools_str_t *buffer, hid_t type, int ind)
n = print_string(buffer, name, FALSE);
h5tools_str_append(buffer, "\"%*s +%-4lu ", MAX(0, 16-n), "",
(unsigned long)H5Tget_member_offset(type, i));
- HDfree(name);
+ H5free_memory(name);
/* Member's type */
subtype = H5Tget_member_type(type, i);
@@ -931,7 +931,7 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind)
if(H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) {
/* Release resources */
for(i = 0; i < (unsigned)nmembs; i++)
- HDfree(name[i]);
+ H5free_memory(name[i]);
HDfree(name);
HDfree(value);
@@ -1158,7 +1158,7 @@ print_opaque_type(h5tools_str_t *buffer, hid_t type, int ind)
h5tools_str_append(buffer, "\n%*s(tag = \"", ind, "");
print_string(buffer, tag, FALSE);
h5tools_str_append(buffer, "\")");
- HDfree(tag);
+ H5free_memory(tag);
}
return TRUE;
}
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 7492d8a..f11065c 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -2340,7 +2340,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
h5tools_str_append(buffer, "OPAQUE_TAG \"%s\";", ttag);
h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
- HDfree(ttag);
+ H5free_memory(ttag);
}
ctx->indent_level--;
@@ -2376,7 +2376,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
}
else
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_member_type failed");
- HDfree(mname);
+ H5free_memory(mname);
}
ctx->indent_level--;
@@ -2692,7 +2692,7 @@ CATCH
/* Release resources */
for(i = 0; i < nmembs; i++)
if(name[i])
- HDfree(name[i]);
+ H5free_memory(name[i]);
HDfree(name);
} /* end if */
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 9202925..d43fc33 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -991,7 +991,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
/* The name */
name = H5Tget_member_name(type, j);
h5tools_str_append(str, OPT(info->cmpd_name, ""), name);
- HDfree(name);
+ H5free_memory(name);
/* The value */
offset = H5Tget_member_offset(type, j);
diff --git a/tools/misc/talign.c b/tools/misc/talign.c
index 017eb55..3fd1694 100644
--- a/tools/misc/talign.c
+++ b/tools/misc/talign.c
@@ -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);
+ H5free_memory(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);
+ H5free_memory(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);
+ H5free_memory(mname);
fptr = (float *)(data + H5Tget_member_offset(fix, 1));
printf("\n"