summaryrefslogtreecommitdiffstats
path: root/src/H5G.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1999-03-18 00:07:50 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1999-03-18 00:07:50 (GMT)
commitb0138a0cb0a7a327600ab57affb754ff1167d44b (patch)
treea1fe26467646e4f702d29577b3667292358259d1 /src/H5G.c
parente433e6c4a977a977ed460670b3fb4c7214849488 (diff)
downloadhdf5-b0138a0cb0a7a327600ab57affb754ff1167d44b.zip
hdf5-b0138a0cb0a7a327600ab57affb754ff1167d44b.tar.gz
hdf5-b0138a0cb0a7a327600ab57affb754ff1167d44b.tar.bz2
[svn-r1144] Added support for object references to groups.
Diffstat (limited to 'src/H5G.c')
-rw-r--r--src/H5G.c73
1 files changed, 61 insertions, 12 deletions
diff --git a/src/H5G.c b/src/H5G.c
index b75f20f..ad87ccb 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -1348,6 +1348,7 @@ H5G_isa(H5G_entry_t *ent)
* Monday, January 5, 1998
*
* Modifications:
+ * Modified to call H5G_open_oid - QAK - 3/17/99
*
*-------------------------------------------------------------------------
*/
@@ -1356,7 +1357,7 @@ H5G_open(H5G_entry_t *loc, const char *name)
{
H5G_t *grp = NULL;
H5G_t *ret_value = NULL;
- H5O_stab_t mesg;
+ H5G_entry_t ent; /*dataset symbol table entry */
FUNC_ENTER(H5G_open, NULL);
@@ -1365,29 +1366,77 @@ H5G_open(H5G_entry_t *loc, const char *name)
assert(name && *name);
/* Open the object, making sure it's a group */
- if (NULL==(grp = H5MM_calloc(sizeof(H5G_t)))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
+ if (H5G_find(loc, name, NULL, &ent/*out*/) < 0) {
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found");
+ }
+ /* Open the group object */
+ if ((grp=H5G_open_oid(&ent)) ==NULL) {
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found");
}
- if (H5G_find(loc, name, NULL, &(grp->ent)/*out*/) < 0) {
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found");
+ ret_value = grp;
+
+done:
+ if (!ret_value && grp) {
+ H5MM_xfree(grp);
}
+ FUNC_LEAVE(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_open_oid
+ *
+ * Purpose: Opens an existing group. The group should eventually be
+ * closed by calling H5G_close().
+ *
+ * Return: Success: Ptr to a new group.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Wednesday, March 17, 1999
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5G_t *
+H5G_open_oid(H5G_entry_t *ent)
+{
+ H5G_t *grp = NULL;
+ H5G_t *ret_value = NULL;
+ H5O_stab_t mesg;
+
+ FUNC_ENTER(H5G_open_oid, NULL);
+
+ /* Check args */
+ assert(ent);
+
+ /* Open the object, making sure it's a group */
+ if (NULL==(grp = H5MM_calloc(sizeof(H5G_t)))) {
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ }
+
+ /* Copy over the symbol table information if it's provided */
+ HDmemcpy(&(grp->ent),ent,sizeof(H5G_entry_t));
+
+ /* Grab the object header */
if (H5O_open(&(grp->ent)) < 0) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group");
}
if (NULL==H5O_read (&(grp->ent), H5O_STAB, 0, &mesg)) {
- H5O_close(&(grp->ent));
- HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, NULL, "not a group");
+ H5O_close(&(grp->ent));
+ HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, NULL, "not a group");
}
grp->nref = 1;
ret_value = grp;
- done:
+done:
if (!ret_value && grp) {
- H5MM_xfree(grp);
+ H5MM_xfree(grp);
}
FUNC_LEAVE(ret_value);
-}
+} /* end H5G_open_oid() */
/*-------------------------------------------------------------------------