summaryrefslogtreecommitdiffstats
path: root/src/H5R.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5R.c')
-rw-r--r--src/H5R.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/H5R.c b/src/H5R.c
index d335fce..ada2269 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -309,7 +309,7 @@ herr_t
H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id)
{
H5G_loc_t loc; /* File location */
- H5S_t *space; /* Pointer to dataspace containing region */
+ H5S_t *space = NULL; /* Pointer to dataspace containing region */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(H5Rcreate, FAIL)
@@ -326,6 +326,8 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
if(ref_type != H5R_OBJECT && ref_type != H5R_DATASET_REGION)
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported")
+ if(space_id == (-1) && ref_type == H5R_DATASET_REGION)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid")
if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
@@ -366,8 +368,9 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re
H5O_loc_t oloc; /* Object location */
H5G_name_t path; /* Path of object */
H5G_loc_t loc; /* Group location */
+ unsigned rc; /* Reference count of object */
H5O_type_t obj_type; /* Type of object */
- hid_t ret_value;
+ hid_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5R_dereference)
@@ -415,8 +418,9 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re
HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
} /* end switch */
- /* Check to make certain that this object hasn't been deleted since the reference was created */
- if(H5O_link(&oloc, 0, dxpl_id) <= 0)
+ /* Get the # of links for object, and its type */
+ /* (To check to make certain that this object hasn't been deleted since the reference was created) */
+ if(H5O_get_rc_and_type(&oloc, dxpl_id, &rc, &obj_type) < 0 || 0 == rc)
HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object")
/* Construct a group location for opening the object */
@@ -424,10 +428,6 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re
loc.oloc = &oloc;
loc.path = &path;
- /* Get the type of the object */
- if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get object type")
-
/* Open the object */
switch(obj_type) {
case H5O_TYPE_GROUP:
@@ -688,6 +688,7 @@ H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type,
const void *_ref, H5O_type_t *obj_type)
{
H5O_loc_t oloc; /* Object location */
+ unsigned rc; /* Reference count of object */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5R_get_obj_type)
@@ -736,14 +737,11 @@ H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type,
HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
} /* end switch */
- /* Check to make certain that this object hasn't been deleted since the reference was created */
- if(H5O_link(&oloc, 0, dxpl_id) <= 0)
+ /* Get the # of links for object, and its type */
+ /* (To check to make certain that this object hasn't been deleted since the reference was created) */
+ if(H5O_get_rc_and_type(&oloc, dxpl_id, &rc, obj_type) < 0 || 0 == rc)
HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object")
- /* Get the object type */
- if(H5O_obj_type(&oloc, obj_type, dxpl_id) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get object type")
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5R_get_obj_type() */