summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2011-04-04 04:23:12 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2011-04-04 04:23:12 (GMT)
commitb035e980f01b19b4c25c7c1764f795e8f1939ae6 (patch)
tree99c6208e1489d76f66433260d28737027f9ad88d /src
parente9e713869c2a59477e77faf0aa3f7545e9858e06 (diff)
downloadhdf5-b035e980f01b19b4c25c7c1764f795e8f1939ae6.zip
hdf5-b035e980f01b19b4c25c7c1764f795e8f1939ae6.tar.gz
hdf5-b035e980f01b19b4c25c7c1764f795e8f1939ae6.tar.bz2
[svn-r20406] Description:
Refactor root group routines to centralize and simplify them some. Also patch root group's file pointer when it doesn't match the querying file, from H5G_rootof. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode Mac OS X/32 10.6.6 (amazon) in debug mode Mac OS X/32 10.6.6 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.6.6 (amazon) w/parallel, in debug mode
Diffstat (limited to 'src')
-rw-r--r--src/H5F.c9
-rw-r--r--src/H5G.c66
-rw-r--r--src/H5Gloc.c52
-rw-r--r--src/H5Gpkg.h6
-rw-r--r--src/H5Gprivate.h5
-rw-r--r--src/H5Groot.c100
-rw-r--r--src/H5Lexternal.c2
7 files changed, 111 insertions, 129 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 21b9a19..2cec64d 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1053,13 +1053,8 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush)
* the memory associated with it.
*/
if(f->shared->root_grp) {
- /* Free the ID to name buffer */
- if(H5G_free_grp_name(f->shared->root_grp) < 0)
- /* Push error, but keep going*/
- HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file")
-
- /* Free the memory for the root group */
- if(H5G_free(f->shared->root_grp) < 0)
+ /* Free the root group */
+ if(H5G_root_free(f->shared->root_grp) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "problems closing file")
f->shared->root_grp = NULL;
diff --git a/src/H5G.c b/src/H5G.c
index 6da8ec6..2093329 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -1211,38 +1211,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5G_free
- *
- * Purpose: Free memory used by an H5G_t struct (and its H5G_shared_t).
- * Does not close the group or decrement the reference count.
- * Used to free memory used by the root group.
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: James Laird
- * Tuesday, September 7, 2004
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5G_free(H5G_t *grp)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5G_free, FAIL)
-
- HDassert(grp && grp->shared);
-
- grp->shared = H5FL_FREE(H5G_shared_t, grp->shared);
- grp = H5FL_FREE(H5G_t, grp);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_free() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5G_oloc
*
* Purpose: Returns a pointer to the object location for a group.
@@ -1315,40 +1283,6 @@ H5G_fileof(H5G_t *grp)
/*-------------------------------------------------------------------------
- * Function: H5G_free_grp_name
- *
- * Purpose: Free the 'ID to name' buffers.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: August 22, 2002
- *
- * Comments: Used now only on the root group close, in H5F_close()
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5G_free_grp_name(H5G_t *grp)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5G_free_grp_name, FAIL)
-
- /* Check args */
- HDassert(grp && grp->shared);
- HDassert(grp->shared->fo_count > 0);
-
- /* Free the path */
- H5G_name_free(&(grp->path));
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_free_grp_name() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5G_get_shared_count
*
* Purpose: Queries the group object's "shared count"
diff --git a/src/H5Gloc.c b/src/H5Gloc.c
index cfa4f44..23db587 100644
--- a/src/H5Gloc.c
+++ b/src/H5Gloc.c
@@ -173,7 +173,7 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file ID")
/* Construct a group location for root group of the file */
- if(H5G_loc_root(f, loc) < 0)
+ if(H5G_root_loc(f, loc) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file")
} /* end case */
break;
@@ -259,56 +259,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5G_loc_root
- *
- * Purpose: Construct a "group location" for the root group of a file
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Mar 5 2007
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5G_loc_root(H5F_t *f, H5G_loc_t *loc)
-{
- H5G_t *root_grp; /* Pointer to root group's info */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5G_loc_root, FAIL)
-
- HDassert(f);
- HDassert(loc);
-
- /* Retrieve the root group for the file */
- root_grp = H5G_rootof(f);
- HDassert(root_grp);
-
- /* Build the group location for the root group */
- if(NULL == (loc->oloc = H5G_oloc(root_grp)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group")
- if(NULL == (loc->path = H5G_nameof(root_grp)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group")
-
- /* Patch up root group's object location to reflect this file */
- /* (Since the root group info is only stored once for files which
- * share an underlying low-level file)
- */
- /* (but only for non-mounted files) */
- if(!H5F_is_mount(f)) {
- loc->oloc->file = f;
- loc->oloc->holding_file = FALSE;
- } /* end if */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_loc_root() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5G_loc_copy
*
* Purpose: Copy over information for a location
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index f9bc41e..78e66d0 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -590,11 +590,15 @@ H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char
/*
* These functions operate on group "locations"
*/
-H5_DLL herr_t H5G_loc_root(H5F_t *f, H5G_loc_t *loc);
H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth);
H5_DLL herr_t H5G_loc_insert(H5G_loc_t *grp_loc, const char *name,
H5G_loc_t *obj_loc, H5O_type_t obj_type, const void *crt_info, hid_t dxpl_id);
+/*
+ * These functions operate on the root group
+ */
+H5_DLL herr_t H5G_root_loc(H5F_t *f, H5G_loc_t *loc);
+
/* Testing functions */
#ifdef H5G_TESTING
H5_DLL htri_t H5G_is_empty_test(hid_t gid);
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index 05de2ba..140e22f 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -149,15 +149,14 @@ typedef struct H5G_entry_t H5G_entry_t;
* Library prototypes... These are the ones that other packages routinely
* call.
*/
-H5_DLL herr_t H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root);
H5_DLL struct H5O_loc_t *H5G_oloc(H5G_t *grp);
+H5_DLL herr_t H5G_mkroot(H5F_t *f, hid_t dxpl_id, hbool_t create_root);
+H5_DLL herr_t H5G_root_free(H5G_t *grp);
H5_DLL H5G_t *H5G_rootof(H5F_t *f);
H5_DLL H5G_name_t * H5G_nameof(H5G_t *grp);
H5_DLL H5F_t *H5G_fileof(H5G_t *grp);
-H5_DLL herr_t H5G_free(H5G_t *grp);
H5_DLL H5G_t *H5G_open(const H5G_loc_t *loc, hid_t dxpl_id);
H5_DLL herr_t H5G_close(H5G_t *grp);
-H5_DLL herr_t H5G_free_grp_name(H5G_t *grp);
H5_DLL herr_t H5G_get_shared_count(H5G_t *grp);
H5_DLL herr_t H5G_mount(H5G_t *grp);
H5_DLL hbool_t H5G_mounted(H5G_t *grp);
diff --git a/src/H5Groot.c b/src/H5Groot.c
index ff4a8c4..a7d7e29 100644
--- a/src/H5Groot.c
+++ b/src/H5Groot.c
@@ -68,9 +68,25 @@ H5G_rootof(H5F_t *f)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_rootof)
+ /* Sanity check */
+ HDassert(f);
+ HDassert(f->shared);
+
+ /* Walk to top of mounted files */
while(f->parent)
f = f->parent;
+ /* Sanity check */
+ HDassert(f);
+ HDassert(f->shared);
+ HDassert(f->shared->root_grp);
+
+ /* Check to see if the root group was opened through a different
+ * "top" file, and switch it to point at the current "top" file.
+ */
+ if(f->shared->root_grp->oloc.file != f)
+ f->shared->root_grp->oloc.file = f;
+
FUNC_LEAVE_NOAPI(f->shared->root_grp)
} /* end H5G_rootof() */
@@ -277,3 +293,87 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_mkroot() */
+
+/*-------------------------------------------------------------------------
+* Function: H5G_root_free
+*
+* Purpose: Free memory used by an H5G_t struct (and its H5G_shared_t).
+* Does not close the group or decrement the reference count.
+* Used to free memory used by the root group.
+*
+* Return: Success: Non-negative
+* Failure: Negative
+*
+* Programmer: James Laird
+* Tuesday, September 7, 2004
+*
+*-------------------------------------------------------------------------
+*/
+herr_t
+H5G_root_free(H5G_t *grp)
+{
+ FUNC_ENTER_NOAPI_NOFUNC(H5G_root_free)
+
+ /* Check args */
+ HDassert(grp && grp->shared);
+ HDassert(grp->shared->fo_count > 0);
+
+ /* Free the path */
+ H5G_name_free(&(grp->path));
+
+ grp->shared = H5FL_FREE(H5G_shared_t, grp->shared);
+ grp = H5FL_FREE(H5G_t, grp);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5G_root_free() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_root_loc
+ *
+ * Purpose: Construct a "group location" for the root group of a file
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Mar 5 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5G_root_loc(H5F_t *f, H5G_loc_t *loc)
+{
+ H5G_t *root_grp; /* Pointer to root group's info */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5G_root_loc, FAIL)
+
+ HDassert(f);
+ HDassert(loc);
+
+ /* Retrieve the root group for the file */
+ root_grp = H5G_rootof(f);
+ HDassert(root_grp);
+
+ /* Build the group location for the root group */
+ if(NULL == (loc->oloc = H5G_oloc(root_grp)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location for root group")
+ if(NULL == (loc->path = H5G_nameof(root_grp)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group")
+
+ /* Patch up root group's object location to reflect this file */
+ /* (Since the root group info is only stored once for files which
+ * share an underlying low-level file)
+ */
+ /* (but only for non-mounted files) */
+ if(!H5F_is_mount(f)) {
+ loc->oloc->file = f;
+ loc->oloc->holding_file = FALSE;
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_root_loc() */
+
diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c
index 1b49568..d3ae271 100644
--- a/src/H5Lexternal.c
+++ b/src/H5Lexternal.c
@@ -434,7 +434,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
/* Retrieve the "group location" for the file's root group */
- if(H5G_loc_root(ext_file, &root_loc) < 0)
+ if(H5G_root_loc(ext_file, &root_loc) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file")
/* Open the object referenced in the external file */