summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Cao <xcao@hdfgroup.org>2007-04-30 22:44:04 (GMT)
committerPeter Cao <xcao@hdfgroup.org>2007-04-30 22:44:04 (GMT)
commit37e010fbe073ce4847da28bdc8da572fa8fa1599 (patch)
tree58e0d62636abb003c7abeba64d0d6d2cf84245f3
parent90a16bb0ddb731ab3eaf6aa7b2140ebf269a6ae1 (diff)
downloadhdf5-37e010fbe073ce4847da28bdc8da572fa8fa1599.zip
hdf5-37e010fbe073ce4847da28bdc8da572fa8fa1599.tar.gz
hdf5-37e010fbe073ce4847da28bdc8da572fa8fa1599.tar.bz2
[svn-r13714] Fix memory leak on objcopy.c test
H5Premove(dcpl, H5D_CRT_EXT_FILE_LIST_NAME) causes memory leak. Use new function H5P_reset_external_file_test(dcpl) instead.
-rw-r--r--src/H5Ptest.c47
-rwxr-xr-xtest/objcopy.c6
2 files changed, 53 insertions, 0 deletions
diff --git a/src/H5Ptest.c b/src/H5Ptest.c
index 4ad0a5b..4a3bca5 100644
--- a/src/H5Ptest.c
+++ b/src/H5Ptest.c
@@ -28,6 +28,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
#include "H5Ppkg.h" /* Property lists */
+#include "H5Dprivate.h" /* Dataset */
/* Local variables */
@@ -124,3 +125,49 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
} /* H5P_open_class_path_test() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5P_reset_external_file_test
+ PURPOSE
+ Routine to reset external file list
+ USAGE
+ herr_t H5P_reset_external_file_test(plist)
+ hid_t dcpl_id; IN: the property list
+
+ RETURNS
+ Non-negative on success/Negative on failure
+
+ PROGRAMMER
+ Peter Cao
+ April 30, 2007
+--------------------------------------------------------------------------*/
+herr_t
+H5P_reset_external_file_test(hid_t dcpl_id)
+{
+ H5O_efl_t efl; /* External file list */
+ H5P_genplist_t *plist; /* Property list */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5P_reset_external_file_test, FAIL);
+
+ /* Check arguments */
+ if(NULL == (plist = H5I_object(dcpl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list")
+
+ /* get external file list */
+ if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list")
+
+ /* Clean up any values set for the external file-list */
+ if(H5O_msg_reset(H5O_EFL_ID, &efl) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release external file list info")
+
+ /* set external file list */
+ if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* H5P_reset_external_file_test() */
+
diff --git a/test/objcopy.c b/test/objcopy.c
index 8cc1027..c773440 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -1078,8 +1078,14 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf)
}
/* Remove external file information from the dcpls */
+ /* Remove default property causes memory leak
if(H5Premove(dcpl, H5D_CRT_EXT_FILE_LIST_NAME) < 0) TEST_ERROR
if(H5Premove(dcpl2, H5D_CRT_EXT_FILE_LIST_NAME) < 0) TEST_ERROR
+ */
+
+ /* reset external file information from the dcpls */
+ if (H5P_reset_external_file_test(dcpl) < 0) TEST_ERROR
+ if (H5P_reset_external_file_test(dcpl2) < 0) TEST_ERROR
}
/* Compare the rest of the dataset creation property lists */