summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2010-11-17 22:11:02 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2010-11-17 22:11:02 (GMT)
commit4810a3d3190603448697cdaa91ed5dc666b22df9 (patch)
tree893e31f7e54a745a88f3705a246352364ce325b9
parentd54a8334e1e66aa0e231db456a084870afe4aa9a (diff)
downloadhdf5-4810a3d3190603448697cdaa91ed5dc666b22df9.zip
hdf5-4810a3d3190603448697cdaa91ed5dc666b22df9.tar.gz
hdf5-4810a3d3190603448697cdaa91ed5dc666b22df9.tar.bz2
[svn-r19813] 1. Correct mistake for previous checkin rev #19781:
file name listed for DISTCLEANFILES should be testlinks_env.sh 2. Add comments to test_4() in test/external.c about the link name "/ link". 3. Fix memory leak as reported by valgrind in src/H5Lexternal.c: free memory pointed to by tmp_env_prefix for HDF5_EXT_PREFIX case.
-rw-r--r--src/H5Lexternal.c12
-rw-r--r--test/Makefile.am2
-rw-r--r--test/external.c2
3 files changed, 11 insertions, 5 deletions
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c
index 9cab8cf..eb2ffe5 100644
--- a/src/H5Lexternal.c
+++ b/src/H5Lexternal.c
@@ -188,6 +188,9 @@ done:
* Otherwise, the file access property retrieved from H5Pget_elink_fapl()
* is used to H5F_open() the target file.
*
+ * Vailin Choi; Nov 2010
+ * Free memory pointed to by tmp_env_prefix for HDF5_EXT_PREFIX case.
+ *
*-------------------------------------------------------------------------
*/
static hid_t
@@ -343,9 +346,9 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
char *env_prefix;
if(NULL != (env_prefix = HDgetenv("HDF5_EXT_PREFIX"))) {
- char *tmp_env_prefix;
+ char *tmp_env_prefix, *saved_env;
- if(NULL == (tmp_env_prefix = H5MM_strdup(env_prefix)))
+ if(NULL == (saved_env = tmp_env_prefix = H5MM_strdup(env_prefix)))
HGOTO_ERROR(H5E_LINK, H5E_NOSPACE, FAIL, "memory allocation failed")
while((tmp_env_prefix) && (*tmp_env_prefix)) {
@@ -353,8 +356,10 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
out_prefix_name = H5L_getenv_prefix_name(&tmp_env_prefix/*in,out*/);
if(out_prefix_name && (*out_prefix_name)) {
- if(H5L_build_name(out_prefix_name, temp_file_name, &full_name/*out*/) < 0)
+ if(H5L_build_name(out_prefix_name, temp_file_name, &full_name/*out*/) < 0) {
+ saved_env = (char *)H5MM_xfree(saved_env);
HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename")
+ }
ext_file = H5F_open(full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id);
full_name = (char *)H5MM_xfree(full_name);
@@ -363,6 +368,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
H5E_clear_stack(NULL);
} /* end if */
} /* end while */
+ saved_env = (char *)H5MM_xfree(saved_env);
} /* end if */
} /* end if */
diff --git a/test/Makefile.am b/test/Makefile.am
index 6993a35..06c56f8 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -134,6 +134,6 @@ testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \
tvlstr.c tvltypes.c
# Temporary files.
-DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks.sh
+DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh
include $(top_srcdir)/config/conclude.am
diff --git a/test/external.c b/test/external.c
index 7fd344e..3e1388c 100644
--- a/test/external.c
+++ b/test/external.c
@@ -879,7 +879,7 @@ test_4 (hid_t fapl)
if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0)
goto error;
- /* Open the external link */
+ /* Open the external link which is "/ link" as created previously via H5Lcreate_external() */
if((xid = H5Gopen2(fid, "/ link", H5P_DEFAULT)) < 0)
goto error;