summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-08-28 15:02:54 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-08-28 15:02:54 (GMT)
commitea343ef85416b42f68f28fb1024702c6726f7eea (patch)
treed5c401bf83f7f5578df06c54f9fd9fb198732ed2 /src
parenteb16d8bc2b2f37c7a1d75fe7bf5258eba21515b2 (diff)
downloadhdf5-ea343ef85416b42f68f28fb1024702c6726f7eea.zip
hdf5-ea343ef85416b42f68f28fb1024702c6726f7eea.tar.gz
hdf5-ea343ef85416b42f68f28fb1024702c6726f7eea.tar.bz2
[svn-r14115] Description:
Remove all plain calls to H5Gopen() from source, replacing them with either H5Gopen2(). Add test for H5Gopen1(). Reformatted several pieces of code, to clean them up. 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)
Diffstat (limited to 'src')
-rw-r--r--src/H5G.c114
-rw-r--r--src/H5Gdeprec.c47
-rw-r--r--src/H5Gobj.c9
-rw-r--r--src/H5Gpkg.h2
-rw-r--r--src/H5Gpublic.h2
-rw-r--r--src/H5vers.txt1
-rw-r--r--src/H5version.h15
7 files changed, 110 insertions, 80 deletions
diff --git a/src/H5G.c b/src/H5G.c
index 160fda0..a43d49f 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -329,7 +329,7 @@ done:
* call H5Gclose() to close it and release resources.
*
* This function allows the user the pass in a Group Access
- * Property List, which H5Gopen() does not.
+ * Property List, which H5Gopen1() does not.
*
* Return: Success: Object ID of the group.
* Failure: FAIL
@@ -342,13 +342,8 @@ done:
hid_t
H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id)
{
- H5G_t *grp = NULL;
- H5G_loc_t loc;
- H5G_loc_t grp_loc; /* Location used to open group */
- H5G_name_t grp_path; /* Opened object group hier. path */
- H5O_loc_t grp_oloc; /* Opened object object location */
- H5O_type_t obj_type; /* Type of object at location */
- hbool_t loc_found = FALSE; /* Location at 'name' found */
+ H5G_t *grp = NULL; /* Group opened */
+ H5G_loc_t loc; /* Location of parent for group */
hid_t ret_value; /* Return value */
FUNC_ENTER_API(H5Gopen2, FAIL)
@@ -367,24 +362,8 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id)
if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list")
- /* Set up opened group location to fill in */
- grp_loc.oloc = &grp_oloc;
- grp_loc.path = &grp_path;
- H5G_loc_reset(&grp_loc);
-
- /* Find the group object using the gapl passed in */
- if(H5G_loc_find(&loc, name, &grp_loc/*out*/, gapl_id, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found")
- loc_found = TRUE;
-
- /* Check that the object found is the correct type */
- if(H5O_obj_type(&grp_oloc, &obj_type, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_GROUP)
- HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group")
-
/* Open the group */
- if((grp = H5G_open(&grp_loc, H5AC_dxpl_id)) == NULL)
+ if((grp = H5G_open_name(&loc, name, gapl_id, H5AC_dxpl_id)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
/* Register an atom for the group */
@@ -393,14 +372,8 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id)
done:
if(ret_value < 0) {
- if(grp) {
- if(H5G_close(grp) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
- } /* end if */
- else {
- if(loc_found && H5G_loc_free(&grp_loc) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
- } /* end else */
+ if(grp && H5G_close(grp) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
} /* end if */
FUNC_LEAVE_API(ret_value)
@@ -982,6 +955,70 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5G_open_name
+ *
+ * Purpose: Opens an existing group by name.
+ *
+ * Return: Success: Ptr to a new group.
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Monday, August 27, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+H5G_t *
+H5G_open_name(const H5G_loc_t *loc, const char *name, hid_t gapl_id,
+ hid_t dxpl_id)
+{
+ H5G_t *grp = NULL; /* Group to open */
+ H5G_loc_t grp_loc; /* Location used to open group */
+ H5G_name_t grp_path; /* Opened object group hier. path */
+ H5O_loc_t grp_oloc; /* Opened object object location */
+ H5O_type_t obj_type; /* Type of object at location */
+ hbool_t loc_found = FALSE; /* Location at 'name' found */
+ H5G_t *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5G_open_name, NULL)
+
+ /* Check args */
+ HDassert(loc);
+ HDassert(name);
+
+ /* Set up opened group location to fill in */
+ grp_loc.oloc = &grp_oloc;
+ grp_loc.path = &grp_path;
+ H5G_loc_reset(&grp_loc);
+
+ /* Find the group object using the gapl passed in */
+ if(H5G_loc_find(loc, name, &grp_loc/*out*/, gapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found")
+ loc_found = TRUE;
+
+ /* Check that the object found is the correct type */
+ if(H5O_obj_type(&grp_oloc, &obj_type, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "can't get object type")
+ if(obj_type != H5O_TYPE_GROUP)
+ HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, NULL, "not a group")
+
+ /* Open the group */
+ if((grp = H5G_open(&grp_loc, dxpl_id)) == NULL)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group")
+
+ /* Set return value */
+ ret_value = grp;
+
+done:
+ if(!ret_value) {
+ if(loc_found && H5G_loc_free(&grp_loc) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_open_name() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5G_open
*
* Purpose: Opens an existing group. The group should eventually be
@@ -999,9 +1036,9 @@ done:
H5G_t *
H5G_open(const H5G_loc_t *loc, hid_t dxpl_id)
{
- H5G_t *grp = NULL;
- H5G_shared_t *shared_fo = NULL;
- H5G_t *ret_value = NULL;
+ H5G_t *grp = NULL; /* Group opened */
+ H5G_shared_t *shared_fo; /* Shared group object */
+ H5G_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_open, NULL)
@@ -1064,12 +1101,11 @@ H5G_open(const H5G_loc_t *loc, hid_t dxpl_id)
ret_value = grp;
done:
- if (!ret_value && grp)
- {
+ if (!ret_value && grp) {
H5O_loc_free(&(grp->oloc));
H5G_name_free(&(grp->path));
H5FL_FREE(H5G_t,grp);
- }
+ } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_open() */
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c
index 613c922..3814c44 100644
--- a/src/H5Gdeprec.c
+++ b/src/H5Gdeprec.c
@@ -215,11 +215,10 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Gcreate1() */
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*-------------------------------------------------------------------------
- * Function: H5Gopen
+ * Function: H5Gopen1
*
* Purpose: Opens an existing group for modification. When finished,
* call H5Gclose() to close it and release resources.
@@ -234,18 +233,13 @@ done:
*-------------------------------------------------------------------------
*/
hid_t
-H5Gopen(hid_t loc_id, const char *name)
+H5Gopen1(hid_t loc_id, const char *name)
{
- H5G_t *grp = NULL;
- H5G_loc_t loc;
- H5G_loc_t grp_loc; /* Location used to open group */
- H5G_name_t grp_path; /* Opened object group hier. path */
- H5O_loc_t grp_oloc; /* Opened object object location */
- H5O_type_t obj_type; /* Type of object at location */
- hbool_t loc_found = FALSE; /* Location at 'name' found */
+ H5G_t *grp = NULL; /* Group opened */
+ H5G_loc_t loc; /* Location of parent for group */
hid_t ret_value; /* Return value */
- FUNC_ENTER_API(H5Gopen, FAIL)
+ FUNC_ENTER_API(H5Gopen1, FAIL)
H5TRACE2("i", "i*s", loc_id, name);
/* Check args */
@@ -254,24 +248,8 @@ H5Gopen(hid_t loc_id, const char *name)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
- /* Set up opened group location to fill in */
- grp_loc.oloc = &grp_oloc;
- grp_loc.path = &grp_path;
- H5G_loc_reset(&grp_loc);
-
- /* Find the group object */
- if(H5G_loc_find(&loc, name, &grp_loc/*out*/, H5P_DEFAULT, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found")
- loc_found = TRUE;
-
- /* Check that the object found is the correct type */
- if(H5O_obj_type(&grp_oloc, &obj_type, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_GROUP)
- HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a group")
-
/* Open the group */
- if((grp = H5G_open(&grp_loc, H5AC_dxpl_id)) == NULL)
+ if((grp = H5G_open_name(&loc, name, H5P_DEFAULT, H5AC_dxpl_id)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
/* Register an atom for the group */
@@ -280,18 +258,13 @@ H5Gopen(hid_t loc_id, const char *name)
done:
if(ret_value < 0) {
- if(grp) {
- if(H5G_close(grp) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
- } /* end if */
- else {
- if(loc_found && H5G_loc_free(&grp_loc) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
- } /* end else */
+ if(grp && H5G_close(grp) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
} /* end if */
FUNC_LEAVE_API(ret_value)
-} /* end H5Gopen() */
+} /* end H5Gopen1() */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*-------------------------------------------------------------------------
diff --git a/src/H5Gobj.c b/src/H5Gobj.c
index a3166ba..397c753 100644
--- a/src/H5Gobj.c
+++ b/src/H5Gobj.c
@@ -640,6 +640,7 @@ H5G_obj_iterate(hid_t loc_id, const char *group_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk,
H5G_link_iterate_t *lnk_op, void *op_data, hid_t dxpl_id)
{
+ H5G_loc_t loc; /* Location of parent for group */
H5O_linfo_t linfo; /* Link info message */
hid_t gid = -1; /* ID of group to iterate over */
H5G_t *grp; /* Pointer to group data structure to iterate over */
@@ -656,10 +657,12 @@ H5G_obj_iterate(hid_t loc_id, const char *group_name,
* Open the group on which to operate. We also create a group ID which
* we can pass to the application-defined operator.
*/
- if((gid = H5Gopen(loc_id, group_name)) < 0)
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if((grp = H5G_open_name(&loc, group_name, H5P_DEFAULT, dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
- if((grp = H5I_object(gid)) == NULL)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "bad group ID")
+ if((gid = H5I_register(H5I_GROUP, grp)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
/* Attempt to get the link info for this group */
if(H5G_obj_get_linfo(&(grp->oloc), &linfo, dxpl_id)) {
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index 5567782..b17a54d 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -336,6 +336,8 @@ H5_DLLVAR const H5B2_class_t H5G_BT2_CORDER[1];
H5_DLL H5G_t *H5G_create(H5F_t *file, hid_t gcpl_id, hid_t dxpl_id);
H5_DLL H5G_t *H5G_create_named(const H5G_loc_t *loc, const char *name,
hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id);
+H5_DLL H5G_t *H5G_open_name(const H5G_loc_t *loc, const char *name,
+ hid_t gapl_id, hid_t dxpl_id);
/*
* Group hierarchy traversal routines
diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h
index 912a637..8b09ea5 100644
--- a/src/H5Gpublic.h
+++ b/src/H5Gpublic.h
@@ -137,7 +137,6 @@ H5_DLL herr_t H5Gclose(hid_t group_id);
*
* Use of these functions and variables is deprecated.
*/
-H5_DLL hid_t H5Gopen(hid_t loc_id, const char *name);
H5_DLL herr_t H5Glink(hid_t cur_loc_id, H5L_type_t type, const char *cur_name,
const char *new_name);
H5_DLL herr_t H5Gmove(hid_t src_loc_id, const char *src_name,
@@ -170,6 +169,7 @@ H5_DLL herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs);
/* Function prototypes */
H5_DLL hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint);
+H5_DLL hid_t H5Gopen1(hid_t loc_id, const char *name);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/src/H5vers.txt b/src/H5vers.txt
index 4a3ee46..6267fbb 100644
--- a/src/H5vers.txt
+++ b/src/H5vers.txt
@@ -52,6 +52,7 @@ FUNCTION: H5Epush; ; v14, v18
FUNCTION: H5Eset_auto; ; v10, v18
FUNCTION: H5Ewalk; H5E_walk, H5E_error; v10, v18
FUNCTION: H5Gcreate; ; v10, v18
+FUNCTION: H5Gopen; ; v10, v18
# API typedefs
# (although not required, it's easier to compare this file with the headers
diff --git a/src/H5version.h b/src/H5version.h
index e22ea8c..e239a75 100644
--- a/src/H5version.h
+++ b/src/H5version.h
@@ -66,6 +66,10 @@
#define H5Gcreate_vers 1
#endif /* !defined(H5Gcreate_vers) */
+#if !defined(H5Gopen_vers)
+#define H5Gopen_vers 1
+#endif /* !defined(H5Gopen_vers) */
+
/************/
/* Typedefs */
/************/
@@ -168,6 +172,17 @@
#error "H5Gcreate_vers set to invalid value"
#endif /* H5Gcreate_vers */
+#if !defined(H5Gopen_vers) || H5Gopen_vers == 2
+#ifndef H5Gopen_vers
+#define H5Gopen_vers 2
+#endif /* H5Gopen_vers */
+#define H5Gopen H5Gopen2
+#elif H5Gopen_vers == 1
+#define H5Gopen H5Gopen1
+#else /* H5Gopen_vers */
+#error "H5Gopen_vers set to invalid value"
+#endif /* H5Gopen_vers */
+
/************/
/* Typedefs */
/************/