From bc07e61d2937d1e62e0fc1fec10f54ed9647fa3b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 28 Aug 2007 17:45:23 -0500 Subject: [svn-r14123] Description: Move H5Gmove2() to deprecated code section, replacing it with H5Lmove() in the source code. Tested on: FreeBSD/32 6.2 (duty) FreeBSD/64 6.2 (liberty) Linux/32 2.6 (kagiso) Linux/64 2.6 (smirom) Solaris/32 5.10 (linew) Mac OS X/32 10.4.10 (amazon) --- fortran/src/H5Gf.c | 53 +++++++++++++++++++++++------------------------------ src/H5Gdeprec.c | 4 ++-- src/H5Gpublic.h | 4 ++-- test/getname.c | 4 ++-- test/links.c | 2 +- test/unlink.c | 26 +++++++++++++------------- 6 files changed, 43 insertions(+), 50 deletions(-) diff --git a/fortran/src/H5Gf.c b/fortran/src/H5Gf.c index 1f45a94..0ca7e38 100644 --- a/fortran/src/H5Gf.c +++ b/fortran/src/H5Gf.c @@ -462,7 +462,7 @@ DONE: HDfree(c_src_name); if(c_dst_name) HDfree(c_dst_name); - return ret_value ; + return ret_value; } /*---------------------------------------------------------------------------- @@ -483,38 +483,31 @@ DONE: int_f nh5gmove2_c(hid_t_f *src_loc_id, _fcd src_name, int_f *src_namelen, hid_t_f *dst_loc_id, _fcd dst_name, int_f*dst_namelen) { - int ret_value = -1; - hid_t c_src_loc_id; - hid_t c_dst_loc_id; - char *c_src_name, *c_dst_name; - size_t c_src_namelen, c_dst_namelen; - herr_t c_ret_value; - /* - * Convert Fortran name to C name - */ - c_src_namelen = *src_namelen; - c_dst_namelen = *dst_namelen; - c_src_name = (char *)HD5f2cstring(src_name, c_src_namelen); - if(c_src_name == NULL) return ret_value; - - c_dst_name = (char *)HD5f2cstring(dst_name, c_dst_namelen); - if(c_dst_name == NULL) { HDfree(c_src_name); - return ret_value; - } - /* - * Call H5Gmove2 function - */ - c_src_loc_id = (hid_t)*src_loc_id; - c_dst_loc_id = (hid_t)*dst_loc_id; - c_ret_value = H5Gmove2(c_src_loc_id, c_src_name, c_dst_loc_id, c_dst_name); - if(c_ret_value < 0) goto DONE; + char *c_src_name = NULL, *c_dst_name = NULL; + int ret_value = -1; - ret_value = 0; + /* + * Convert Fortran name to C name + */ + if(NULL == (c_src_name = (char *)HD5f2cstring(src_name, (size_t)*src_namelen))) + goto DONE; + if(NULL == (c_dst_name = (char *)HD5f2cstring(dst_name, (size_t)*dst_namelen))) + goto DONE; + + /* + * Call H5Gmove2 function + */ + if(H5Lmove((hid_t)*src_loc_id, c_src_name, (hid_t)*dst_loc_id, c_dst_name, H5P_DEFAULT, H5P_DEFAULT) < 0) + goto DONE; + + ret_value = 0; DONE: - HDfree(c_src_name); - HDfree(c_dst_name); - return ret_value ; + if(c_src_name) + HDfree(c_src_name); + if(c_dst_name) + HDfree(c_dst_name); + return ret_value; } /*---------------------------------------------------------------------------- diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index a6f072a..34baef3 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -78,9 +78,9 @@ typedef struct { #ifndef H5_NO_DEPRECATED_SYMBOLS static herr_t H5G_link_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, const char *new_name); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ static herr_t H5G_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ static herr_t H5G_set_comment(H5G_loc_t *loc, const char *name, const char *buf, hid_t dxpl_id); static int H5G_get_comment(H5G_loc_t *loc, const char *name, @@ -440,7 +440,6 @@ H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) done: FUNC_LEAVE_API(ret_value) } /* end H5Gmove() */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ /*------------------------------------------------------------------------- @@ -523,6 +522,7 @@ H5G_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_move() */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /*------------------------------------------------------------------------- diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index 8cddbce..5a40f97 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -137,8 +137,6 @@ H5_DLL herr_t H5Gclose(hid_t group_id); * * Use of these functions and variables is deprecated. */ -H5_DLL herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name); H5_DLL herr_t H5Gunlink(hid_t loc_id, const char *name); H5_DLL herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/); @@ -170,6 +168,8 @@ H5_DLL herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5L_type_t type, hid_t new_loc_id, const char *new_name); H5_DLL herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name); +H5_DLL herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, + const char *dst_name); #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/test/getname.c b/test/getname.c index 51934fe..2012d57 100644 --- a/test/getname.c +++ b/test/getname.c @@ -475,13 +475,13 @@ test_main(hid_t file_id, hid_t fapl) if(check_name(group3_id, "/g5/C/D", "/g5/C/D") < 0) TEST_ERROR /* Move group "/g5/C/D" back to "/g4/A/B" using relative name */ - if(H5Gmove2(group5_id, "D", group2_id, "B") < 0) FAIL_STACK_ERROR + if(H5Lmove(group5_id, "D", group2_id, "B", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify */ if(check_name(group3_id, "/g4/A/B", "/g4/A/B") < 0) TEST_ERROR /* Move group "/g4/A/B" to "/g4/F/B" using relative name */ - if(H5Gmove2(group_id, "A", group_id, "F") < 0) FAIL_STACK_ERROR + if(H5Lmove(group_id, "A", group_id, "F", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Verify */ if(check_name(group3_id, "/g4/F/B", "/g4/F/B") < 0) TEST_ERROR diff --git a/test/links.c b/test/links.c index 9427ac9..11a5e9e 100644 --- a/test/links.c +++ b/test/links.c @@ -3027,7 +3027,7 @@ external_link_move(hid_t fapl, hbool_t new_format) if((gid = H5Gcreate2(fid, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Move external link to different group */ - if(H5Gmove2(fid, "src2", gid, "src3") < 0) FAIL_STACK_ERROR + if(H5Lmove(fid, "src2", gid, "src3", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Close new group */ if(H5Gclose(gid) < 0) FAIL_STACK_ERROR diff --git a/test/unlink.c b/test/unlink.c index d87c39b..c4f1dab 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -340,7 +340,7 @@ error: /*------------------------------------------------------------------------- * Function: test_new_move * - * Purpose: Tests H5Gmove2() + * Purpose: Tests H5Lmove() with different locations * * Return: Success: 0 * @@ -364,9 +364,9 @@ test_new_move(hid_t fapl) /* Create a second file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if((file_a = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((file_a = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if((file_b = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((file_b = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Create groups in first file */ if((grp_1 = H5Gcreate2(file_a, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -380,26 +380,26 @@ test_new_move(hid_t fapl) /* Move a group within the file. Both of source and destination use * H5G_SAME_LOC. Should fail. */ H5E_BEGIN_TRY { - if(H5Gmove2(H5G_SAME_LOC, "group_move", H5G_SAME_LOC, "group_new_name") !=FAIL) TEST_ERROR + if(H5Lmove(H5G_SAME_LOC, "group_move", H5G_SAME_LOC, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != FAIL) TEST_ERROR } H5E_END_TRY; /* Move a group across files. Should fail. */ H5E_BEGIN_TRY { - if(H5Gmove2(grp_1, "group_move", file_b, "group_new_name")!=FAIL) TEST_ERROR + if(H5Lmove(grp_1, "group_move", file_b, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) != FAIL) TEST_ERROR } H5E_END_TRY; /* Move a group across groups in the same file. */ - if(H5Gmove2(grp_1, "group_move", grp_2, "group_new_name") < 0) TEST_ERROR + if(H5Lmove(grp_1, "group_move", grp_2, "group_new_name", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Open the group just moved to the new location. */ if((moved_grp = H5Gopen2(grp_2, "group_new_name", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Gclose(grp_1) < 0) TEST_ERROR - if(H5Gclose(grp_2) < 0) TEST_ERROR - if(H5Gclose(grp_move) < 0) TEST_ERROR - if(H5Gclose(moved_grp) < 0) TEST_ERROR - if(H5Fclose(file_a) < 0) TEST_ERROR - if(H5Fclose(file_b) < 0) TEST_ERROR + if(H5Gclose(grp_1) < 0) FAIL_STACK_ERROR + if(H5Gclose(grp_2) < 0) FAIL_STACK_ERROR + if(H5Gclose(grp_move) < 0) FAIL_STACK_ERROR + if(H5Gclose(moved_grp) < 0) FAIL_STACK_ERROR + if(H5Fclose(file_a) < 0) FAIL_STACK_ERROR + if(H5Fclose(file_b) < 0) FAIL_STACK_ERROR PASSED(); return 0; @@ -420,7 +420,7 @@ test_new_move(hid_t fapl) /*------------------------------------------------------------------------- * Function: check_new_move * - * Purpose: Checks result of H5Gmove2() + * Purpose: Checks result of H5Lmove() with different locations * * Return: Success: 0 * -- cgit v0.12