summaryrefslogtreecommitdiffstats
path: root/src/H5Rint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Rint.c')
-rw-r--r--src/H5Rint.c326
1 files changed, 179 insertions, 147 deletions
diff --git a/src/H5Rint.c b/src/H5Rint.c
index cef1f0a..33ebe53 100644
--- a/src/H5Rint.c
+++ b/src/H5Rint.c
@@ -35,6 +35,8 @@
#include "H5Sprivate.h" /* Dataspaces */
#include "H5Tprivate.h" /* Datatypes */
+#include "H5VLnative_private.h" /* Native VOL connector */
+
/****************/
/* Local Macros */
/****************/
@@ -93,9 +95,29 @@
HDfflush(stdout); \
} while (0)
static const char *
-H5R__print_token(const H5VL_token_t token) {
+H5R__print_token(const H5O_token_t token) {
static char string[64];
- HDsnprintf(string, 64, "%zu", *(haddr_t *)token);
+
+ /* Print the raw token. */
+ HDsnprintf(string, 64, "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
+ (unsigned char)token.__data[15],
+ (unsigned char)token.__data[14],
+ (unsigned char)token.__data[13],
+ (unsigned char)token.__data[12],
+ (unsigned char)token.__data[11],
+ (unsigned char)token.__data[10],
+ (unsigned char)token.__data[9],
+ (unsigned char)token.__data[8],
+ (unsigned char)token.__data[7],
+ (unsigned char)token.__data[6],
+ (unsigned char)token.__data[5],
+ (unsigned char)token.__data[4],
+ (unsigned char)token.__data[3],
+ (unsigned char)token.__data[2],
+ (unsigned char)token.__data[1],
+ (unsigned char)token.__data[0]
+ );
+
return string;
}
#else
@@ -110,8 +132,8 @@ H5R__print_token(const H5VL_token_t token) {
/* Local Prototypes */
/********************/
-static herr_t H5R__encode_obj_token(const H5VL_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc);
-static herr_t H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5VL_token_t *obj_token, uint8_t *token_size);
+static herr_t H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc);
+static herr_t H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes, H5O_token_t *obj_token, uint8_t *token_size);
static herr_t H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc);
static herr_t H5R__decode_region(const unsigned char *buf, size_t *nbytes, H5S_t **space_ptr);
static herr_t H5R__encode_string(const char *string, unsigned char *buf, size_t *nalloc);
@@ -240,14 +262,14 @@ H5R_term_package(void)
/*-------------------------------------------------------------------------
* Function: H5R__create_object
*
- * Purpose: Creates an object reference.
+ * Purpose: Creates an object reference
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5R__create_object(const H5VL_token_t *obj_token, size_t token_size,
+H5R__create_object(const H5O_token_t *obj_token, size_t token_size,
H5R_ref_priv_t *ref)
{
size_t encode_size;
@@ -258,11 +280,11 @@ H5R__create_object(const H5VL_token_t *obj_token, size_t token_size,
HDassert(ref);
/* Create new reference */
- H5MM_memcpy(&ref->ref.obj.token, obj_token, token_size);
- ref->ref.obj.filename = NULL;
+ ref->info.obj.filename = NULL;
ref->loc_id = H5I_INVALID_HID;
ref->type = (uint8_t)H5R_OBJECT2;
- ref->token_size = (uint8_t)token_size;
+ if(H5R__set_obj_token(ref, obj_token, token_size) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token")
/* Cache encoding size (assume no external reference) */
if(H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0)
@@ -270,7 +292,7 @@ H5R__create_object(const H5VL_token_t *obj_token, size_t token_size,
ref->encode_size = (uint32_t)encode_size;
H5R_LOG_DEBUG("Created object reference, %d, filename=%s, obj_addr=%s, encode size=%u",
- (int)sizeof(H5R_ref_priv_t), ref->ref.obj.filename, H5R__print_token(ref->ref.obj.token),
+ (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token),
ref->encode_size);
done:
@@ -281,14 +303,14 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__create_region
*
- * Purpose: Creates a region reference.
+ * Purpose: Creates a region reference
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5R__create_region(const H5VL_token_t *obj_token, size_t token_size,
+H5R__create_region(const H5O_token_t *obj_token, size_t token_size,
H5S_t *space, H5R_ref_priv_t *ref)
{
size_t encode_size;
@@ -300,14 +322,14 @@ H5R__create_region(const H5VL_token_t *obj_token, size_t token_size,
HDassert(ref);
/* Create new reference */
- H5MM_memcpy(&ref->ref.obj.token, obj_token, token_size);
- ref->ref.obj.filename = NULL;
- if(NULL == (ref->ref.reg.space = H5S_copy(space, FALSE, TRUE)))
+ ref->info.obj.filename = NULL;
+ if(NULL == (ref->info.reg.space = H5S_copy(space, FALSE, TRUE)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy dataspace")
ref->loc_id = H5I_INVALID_HID;
ref->type = (uint8_t)H5R_DATASET_REGION2;
- ref->token_size = (uint8_t)token_size;
+ if(H5R__set_obj_token(ref, obj_token, token_size) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token")
/* Cache encoding size (assume no external reference) */
if(H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0)
@@ -315,14 +337,14 @@ H5R__create_region(const H5VL_token_t *obj_token, size_t token_size,
ref->encode_size = (uint32_t)encode_size;
H5R_LOG_DEBUG("Created region reference, %d, filename=%s, obj_addr=%s, encode size=%u",
- (int)sizeof(H5R_ref_priv_t), ref->ref.obj.filename, H5R__print_token(ref->ref.obj.token),
+ (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token),
ref->encode_size);
done:
if(ret_value < 0)
- if(ref->ref.reg.space) {
- H5S_close(ref->ref.reg.space);
- ref->ref.reg.space = NULL;
+ if(ref->info.reg.space) {
+ H5S_close(ref->info.reg.space);
+ ref->info.reg.space = NULL;
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -332,14 +354,14 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__create_attr
*
- * Purpose: Creates an attribute reference.
+ * Purpose: Creates an attribute reference
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5R__create_attr(const H5VL_token_t *obj_token, size_t token_size,
+H5R__create_attr(const H5O_token_t *obj_token, size_t token_size,
const char *attr_name, H5R_ref_priv_t *ref)
{
size_t encode_size;
@@ -355,14 +377,14 @@ H5R__create_attr(const H5VL_token_t *obj_token, size_t token_size,
HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, FAIL, "attribute name too long (%d > %d)", (int)HDstrlen(attr_name), H5R_MAX_STRING_LEN)
/* Create new reference */
- H5MM_memcpy(&ref->ref.obj.token, obj_token, token_size);
- ref->ref.obj.filename = NULL;
- if(NULL == (ref->ref.attr.name = HDstrdup(attr_name)))
+ ref->info.obj.filename = NULL;
+ if(NULL == (ref->info.attr.name = HDstrdup(attr_name)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy attribute name")
ref->loc_id = H5I_INVALID_HID;
ref->type = (uint8_t)H5R_ATTR;
- ref->token_size = (uint8_t)token_size;
+ if(H5R__set_obj_token(ref, obj_token, token_size) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "unable to set object token")
/* Cache encoding size (assume no external reference) */
if(H5R__encode(NULL, ref, NULL, &encode_size, 0) < 0)
@@ -370,13 +392,13 @@ H5R__create_attr(const H5VL_token_t *obj_token, size_t token_size,
ref->encode_size = (uint32_t)encode_size;
H5R_LOG_DEBUG("Created attribute reference, %d, filename=%s, obj_addr=%s, attr name=%s, encode size=%u",
- (int)sizeof(H5R_ref_priv_t), ref->ref.obj.filename, H5R__print_token(ref->ref.obj.token),
- ref->ref.attr.name, ref->encode_size);
+ (int)sizeof(H5R_ref_priv_t), ref->info.obj.filename, H5R__print_token(ref->info.obj.token),
+ ref->info.attr.name, ref->encode_size);
done:
if(ret_value < 0) {
- H5MM_xfree(ref->ref.attr.name);
- ref->ref.attr.name = NULL;
+ H5MM_xfree(ref->info.attr.name);
+ ref->info.attr.name = NULL;
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@@ -386,9 +408,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__destroy
*
- * Purpose: Destroy reference.
+ * Purpose: Destroy a reference
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -401,22 +423,22 @@ H5R__destroy(H5R_ref_priv_t *ref)
HDassert(ref != NULL);
- H5MM_xfree(ref->ref.obj.filename);
- ref->ref.obj.filename = NULL;
+ H5MM_xfree(ref->info.obj.filename);
+ ref->info.obj.filename = NULL;
switch(ref->type) {
case H5R_OBJECT2:
break;
case H5R_DATASET_REGION2:
- if(H5S_close(ref->ref.reg.space) < 0)
+ if(H5S_close(ref->info.reg.space) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTFREE, FAIL, "Cannot close dataspace")
- ref->ref.reg.space = NULL;
+ ref->info.reg.space = NULL;
break;
case H5R_ATTR:
- H5MM_xfree(ref->ref.attr.name);
- ref->ref.attr.name = NULL;
+ H5MM_xfree(ref->info.attr.name);
+ ref->info.attr.name = NULL;
break;
case H5R_OBJECT1:
@@ -451,9 +473,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__set_loc_id
*
- * Purpose: Attach location ID to reference and increment location refcount.
+ * Purpose: Attach location ID to reference and increment location refcount.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -496,9 +518,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__get_loc_id
*
- * Purpose: Retrieve location ID attached to existing reference.
+ * Purpose: Retrieve location ID attached to existing reference.
*
- * Return: Valid ID on success/Negative on failure
+ * Return: Valid ID on success / H5I_INVALID_HID on failure
*
*-------------------------------------------------------------------------
*/
@@ -520,9 +542,9 @@ H5R__get_loc_id(const H5R_ref_priv_t *ref)
/*-------------------------------------------------------------------------
* Function: H5R__reopen_file
*
- * Purpose: Re-open referenced file using file access property list.
+ * Purpose: Re-open referenced file using file access property list.
*
- * Return: Valid ID on success/Negative on failure
+ * Return: Valid ID on success / H5I_INVALID_HID on failure
*
*-------------------------------------------------------------------------
*/
@@ -589,9 +611,10 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__get_type
*
- * Purpose: Given a reference to some object, return the type of that reference.
+ * Purpose: Given a reference to some object, return the type of that
+ * reference.
*
- * Return: Type of the reference
+ * Return: Type of the reference
*
*-------------------------------------------------------------------------
*/
@@ -612,9 +635,9 @@ H5R__get_type(const H5R_ref_priv_t *ref)
/*-------------------------------------------------------------------------
* Function: H5R__equal
*
- * Purpose: Compare two references
+ * Purpose: Compare two references
*
- * Return: TRUE if equal, FALSE if unequal, FAIL if error
+ * Return: TRUE if equal, FALSE if unequal, FAIL if error
*
*-------------------------------------------------------------------------
*/
@@ -635,27 +658,27 @@ H5R__equal(const H5R_ref_priv_t *ref1, const H5R_ref_priv_t *ref2)
/* Compare object addresses */
if(ref1->token_size != ref2->token_size)
HGOTO_DONE(FALSE);
- if(0 != HDmemcmp(&ref1->ref.obj.token, &ref2->ref.obj.token, ref1->token_size))
+ if(0 != HDmemcmp(&ref1->info.obj.token, &ref2->info.obj.token, ref1->token_size))
HGOTO_DONE(FALSE);
/* Compare filenames */
- if((ref1->ref.obj.filename && (NULL == ref2->ref.obj.filename))
- || ((NULL == ref1->ref.obj.filename) && ref2->ref.obj.filename))
+ if((ref1->info.obj.filename && (NULL == ref2->info.obj.filename))
+ || ((NULL == ref1->info.obj.filename) && ref2->info.obj.filename))
HGOTO_DONE(FALSE);
- if(ref1->ref.obj.filename && ref1->ref.obj.filename
- && (0 != HDstrcmp(ref1->ref.obj.filename, ref2->ref.obj.filename)))
+ if(ref1->info.obj.filename && ref1->info.obj.filename
+ && (0 != HDstrcmp(ref1->info.obj.filename, ref2->info.obj.filename)))
HGOTO_DONE(FALSE);
switch(ref1->type) {
case H5R_OBJECT2:
break;
case H5R_DATASET_REGION2:
- if((ret_value = H5S_extent_equal(ref1->ref.reg.space, ref2->ref.reg.space)) < 0)
+ if((ret_value = H5S_extent_equal(ref1->info.reg.space, ref2->info.reg.space)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, FAIL, "cannot compare dataspace extents")
break;
case H5R_ATTR:
- HDassert(ref1->ref.attr.name && ref2->ref.attr.name);
- if(0 != HDstrcmp(ref1->ref.attr.name, ref2->ref.attr.name))
+ HDassert(ref1->info.attr.name && ref2->info.attr.name);
+ if(0 != HDstrcmp(ref1->info.attr.name, ref2->info.attr.name))
HGOTO_DONE(FALSE);
break;
case H5R_OBJECT1:
@@ -677,9 +700,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__copy
*
- * Purpose: Copy a reference
+ * Purpose: Copy a reference
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -692,7 +715,7 @@ H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref)
HDassert((src_ref != NULL) && (dst_ref != NULL));
- H5MM_memcpy(&dst_ref->ref.obj.token, &src_ref->ref.obj.token, src_ref->token_size);
+ H5MM_memcpy(&dst_ref->info.obj.token, &src_ref->info.obj.token, sizeof(H5O_token_t));
dst_ref->encode_size = src_ref->encode_size;
dst_ref->type = src_ref->type;
dst_ref->token_size = src_ref->token_size;
@@ -701,11 +724,11 @@ H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref)
case H5R_OBJECT2:
break;
case H5R_DATASET_REGION2:
- if(NULL == (dst_ref->ref.reg.space = H5S_copy(src_ref->ref.reg.space, FALSE, TRUE)))
+ if(NULL == (dst_ref->info.reg.space = H5S_copy(src_ref->info.reg.space, FALSE, TRUE)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy dataspace")
break;
case H5R_ATTR:
- if(NULL == (dst_ref->ref.attr.name = HDstrdup(src_ref->ref.attr.name)))
+ if(NULL == (dst_ref->info.attr.name = HDstrdup(src_ref->info.attr.name)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy attribute name")
break;
case H5R_OBJECT1:
@@ -721,13 +744,14 @@ H5R__copy(const H5R_ref_priv_t *src_ref, H5R_ref_priv_t *dst_ref)
/* We only need to keep a copy of the filename if we don't have the loc_id */
if(src_ref->loc_id == H5I_INVALID_HID) {
- HDassert(src_ref->ref.obj.filename);
+ HDassert(src_ref->info.obj.filename);
- if(NULL == (dst_ref->ref.obj.filename = HDstrdup(src_ref->ref.obj.filename)))
+ if(NULL == (dst_ref->info.obj.filename = HDstrdup(src_ref->info.obj.filename)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Cannot copy filename")
dst_ref->loc_id = H5I_INVALID_HID;
- } else {
- dst_ref->ref.obj.filename = NULL;
+ }
+ else {
+ dst_ref->info.obj.filename = NULL;
/* Set location ID and hold reference to it */
if(H5R__set_loc_id(dst_ref, src_ref->loc_id, TRUE, TRUE) < 0)
@@ -742,14 +766,14 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__get_obj_token
*
- * Purpose: Given a reference to some object, get the encoded object addr.
+ * Purpose: Given a reference to some object, get the encoded token.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5R__get_obj_token(const H5R_ref_priv_t *ref, H5VL_token_t *obj_token,
+H5R__get_obj_token(const H5R_ref_priv_t *ref, H5O_token_t *obj_token,
size_t *token_size)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -757,12 +781,12 @@ H5R__get_obj_token(const H5R_ref_priv_t *ref, H5VL_token_t *obj_token,
FUNC_ENTER_PACKAGE
HDassert(ref != NULL);
- HDassert(ref->token_size <= H5VL_MAX_TOKEN_SIZE);
+ HDassert(ref->token_size <= H5O_MAX_TOKEN_SIZE);
if(obj_token) {
if(0 == ref->token_size)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "NULL token size")
- H5MM_memcpy(obj_token, &ref->ref.obj.token, ref->token_size);
+ H5MM_memcpy(obj_token, &ref->info.obj.token, sizeof(H5O_token_t));
}
if(token_size)
*token_size = ref->token_size;
@@ -775,14 +799,14 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__set_obj_token
*
- * Purpose: Given a reference to some object, set the encoded object addr.
+ * Purpose: Given a reference to some object, set the encoded token.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5R__set_obj_token(H5R_ref_priv_t *ref, const H5VL_token_t *obj_token,
+H5R__set_obj_token(H5R_ref_priv_t *ref, const H5O_token_t *obj_token,
size_t token_size)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -792,9 +816,9 @@ H5R__set_obj_token(H5R_ref_priv_t *ref, const H5VL_token_t *obj_token,
HDassert(ref != NULL);
HDassert(obj_token);
HDassert(token_size);
- HDassert(token_size <= H5VL_MAX_TOKEN_SIZE);
+ HDassert(token_size <= H5O_MAX_TOKEN_SIZE);
- H5MM_memcpy(&ref->ref.obj.token, obj_token, ref->token_size);
+ H5MM_memcpy(&ref->info.obj.token, obj_token, sizeof(H5O_token_t));
ref->token_size = (uint8_t)token_size;
FUNC_LEAVE_NOAPI(ret_value)
@@ -804,11 +828,11 @@ H5R__set_obj_token(H5R_ref_priv_t *ref, const H5VL_token_t *obj_token,
/*-------------------------------------------------------------------------
* Function: H5R__get_region
*
- * Purpose: Given a reference to some object, creates a copy of the dataset
- * pointed to's dataspace and defines a selection in the copy which is the
- * region pointed to.
+ * Purpose: Given a reference to some object, creates a copy of the
+ * dataset pointed to's dataspace and defines a selection in
+ * the copy which is the region pointed to.
*
- * Return: Pointer to the dataspace on success/NULL on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -824,7 +848,7 @@ H5R__get_region(const H5R_ref_priv_t *ref, H5S_t *space)
HDassert(space);
/* Copy reference selection to destination */
- if(H5S_select_copy(space, ref->ref.reg.space, FALSE) < 0)
+ if(H5S_select_copy(space, ref->info.reg.space, FALSE) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "unable to copy selection")
done:
@@ -835,10 +859,10 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__get_file_name
*
- * Purpose: Given a reference to some object, determine a file name of the
- * object located into.
+ * Purpose: Given a reference to some object, determine a file name of
+ * the object located into.
*
- * Return: Non-negative length of the path on success/Negative on failure
+ * Return: Non-negative length of the path on success / -1 on failure
*
*-------------------------------------------------------------------------
*/
@@ -854,17 +878,17 @@ H5R__get_file_name(const H5R_ref_priv_t *ref, char *buf, size_t size)
HDassert(ref != NULL);
/* Return if that reference has no filename set */
- if(!ref->ref.obj.filename)
+ if(!ref->info.obj.filename)
HGOTO_ERROR(H5E_REFERENCE, H5E_ARGS, (-1), "no filename available for that reference")
/* Get the file name length */
- copy_len = HDstrlen(ref->ref.obj.filename);
+ copy_len = HDstrlen(ref->info.obj.filename);
HDassert(copy_len <= H5R_MAX_STRING_LEN);
/* Copy the file name */
if(buf) {
copy_len = MIN(copy_len, size - 1);
- H5MM_memcpy(buf, ref->ref.obj.filename, copy_len);
+ H5MM_memcpy(buf, ref->info.obj.filename, copy_len);
buf[copy_len] = '\0';
}
ret_value = (ssize_t)(copy_len + 1);
@@ -877,9 +901,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__get_attr_name
*
- * Purpose: Given a reference to some attribute, determine its name.
+ * Purpose: Given a reference to some attribute, determine its name.
*
- * Return: Non-negative length of the path on success/Negative on failure
+ * Return: Non-negative length of the path on success / -1 on failure
*
*-------------------------------------------------------------------------
*/
@@ -896,13 +920,13 @@ H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size)
HDassert(ref->type == H5R_ATTR);
/* Get the attribute name length */
- attr_name_len = HDstrlen(ref->ref.attr.name);
+ attr_name_len = HDstrlen(ref->info.attr.name);
HDassert(attr_name_len <= H5R_MAX_STRING_LEN);
/* Get the attribute name */
if(buf) {
size_t copy_len = MIN(attr_name_len, size - 1);
- H5MM_memcpy(buf, ref->ref.attr.name, copy_len);
+ H5MM_memcpy(buf, ref->info.attr.name, copy_len);
buf[copy_len] = '\0';
}
@@ -915,9 +939,9 @@ H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size)
/*-------------------------------------------------------------------------
* Function: H5R__encode
*
- * Purpose: Private function for H5Rencode.
+ * Purpose: Private function for H5Rencode
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -959,7 +983,7 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf,
encode_size += H5R_ENCODE_HEADER_SIZE;
/* Encode object token */
- H5R_ENCODE_VAR(H5R__encode_obj_token, &ref->ref.obj.token, ref->token_size,
+ H5R_ENCODE_VAR(H5R__encode_obj_token, &ref->info.obj.token, ref->token_size,
p, buf_size, encode_size, "Cannot encode object address");
/**
@@ -981,13 +1005,13 @@ H5R__encode(const char *filename, const H5R_ref_priv_t *ref, unsigned char *buf,
case H5R_DATASET_REGION2:
/* Encode dataspace */
- H5R_ENCODE(H5R__encode_region, ref->ref.reg.space, p, buf_size,
+ H5R_ENCODE(H5R__encode_region, ref->info.reg.space, p, buf_size,
encode_size, "Cannot encode region");
break;
case H5R_ATTR:
/* Encode attribute name */
- H5R_ENCODE(H5R__encode_string, ref->ref.attr.name, p, buf_size,
+ H5R_ENCODE(H5R__encode_string, ref->info.attr.name, p, buf_size,
encode_size, "Cannot encode attribute name");
break;
@@ -1013,9 +1037,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__decode
*
- * Purpose: Private function for H5Rdecode.
+ * Purpose: Private function for H5Rdecode
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1050,28 +1074,29 @@ H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref)
decode_size += H5R_ENCODE_HEADER_SIZE;
/* Decode object token */
- H5R_DECODE_VAR(H5R__decode_obj_token, &ref->ref.obj.token, &ref->token_size,
+ H5R_DECODE_VAR(H5R__decode_obj_token, &ref->info.obj.token, &ref->token_size,
p, buf_size, decode_size, "Cannot decode object address");
/* We do not need to store the filename if the reference is internal */
if(flags & H5R_IS_EXTERNAL) {
/* Decode file name */
- H5R_DECODE(H5R__decode_string, &ref->ref.obj.filename, p, buf_size,
+ H5R_DECODE(H5R__decode_string, &ref->info.obj.filename, p, buf_size,
decode_size, "Cannot decode filename");
- } else
- ref->ref.obj.filename = NULL;
+ }
+ else
+ ref->info.obj.filename = NULL;
switch(ref->type) {
case H5R_OBJECT2:
break;
case H5R_DATASET_REGION2:
/* Decode dataspace */
- H5R_DECODE(H5R__decode_region, &ref->ref.reg.space, p, buf_size,
+ H5R_DECODE(H5R__decode_region, &ref->info.reg.space, p, buf_size,
decode_size, "Cannot decode region");
break;
case H5R_ATTR:
/* Decode attribute name */
- H5R_DECODE(H5R__decode_string, &ref->ref.attr.name, p, buf_size,
+ H5R_DECODE(H5R__decode_string, &ref->info.attr.name, p, buf_size,
decode_size, "Cannot decode attribute name");
break;
case H5R_OBJECT1:
@@ -1092,7 +1117,7 @@ H5R__decode(const unsigned char *buf, size_t *nbytes, H5R_ref_priv_t *ref)
ref->encode_size = (uint32_t)decode_size;
H5R_LOG_DEBUG("Decoded reference, filename=%s, obj_addr=%s, encode size=%u",
- ref->ref.obj.filename, H5R__print_token(ref->ref.obj.token),
+ ref->info.obj.filename, H5R__print_token(ref->info.obj.token),
ref->encode_size);
*nbytes = decode_size;
@@ -1105,14 +1130,14 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__encode_obj_token
*
- * Purpose: Encode an object address.
+ * Purpose: Encode an object address.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5R__encode_obj_token(const H5VL_token_t *obj_token, size_t token_size,
+H5R__encode_obj_token(const H5O_token_t *obj_token, size_t token_size,
unsigned char *buf, size_t *nalloc)
{
herr_t ret_value = SUCCEED;
@@ -1140,15 +1165,15 @@ H5R__encode_obj_token(const H5VL_token_t *obj_token, size_t token_size,
/*-------------------------------------------------------------------------
* Function: H5R__decode_obj_token
*
- * Purpose: Decode an object address.
+ * Purpose: Decode an object address.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes,
- H5VL_token_t *obj_token, uint8_t *token_size)
+ H5O_token_t *obj_token, uint8_t *token_size)
{
const uint8_t *p = (const uint8_t *)buf;
herr_t ret_value = SUCCEED;
@@ -1166,9 +1191,12 @@ H5R__decode_obj_token(const unsigned char *buf, size_t *nbytes,
/* Get token size */
*token_size = *p++;
- if(*token_size > sizeof(H5VL_token_t))
+ if(*token_size > sizeof(H5O_token_t))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Invalid token size (%u)", *token_size)
+ /* Make sure that token is initialized */
+ HDmemset(obj_token, 0, sizeof(H5O_token_t));
+
/* Decode token */
H5MM_memcpy(obj_token, p, *token_size);
@@ -1182,9 +1210,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__encode_region
*
- * Purpose: Encode a selection.
+ * Purpose: Encode a selection.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1231,9 +1259,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__decode_region
*
- * Purpose: Decode a selection.
+ * Purpose: Decode a selection.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1287,9 +1315,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__encode_string
*
- * Purpose: Encode a string.
+ * Purpose: Encode a string.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1329,9 +1357,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__decode_string
*
- * Purpose: Decode a string.
+ * Purpose: Decode a string.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1376,9 +1404,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__encode_heap
*
- * Purpose: Encode data and insert into heap (native only).
+ * Purpose: Encode data and insert into heap (native only).
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1417,9 +1445,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__decode_heap
*
- * Purpose: Decode data inserted into heap (native only).
+ * Purpose: Decode data inserted into heap (native only).
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1464,9 +1492,9 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__free_heap
*
- * Purpose: Remove data previously inserted into heap (native only).
+ * Purpose: Remove data previously inserted into heap (native only).
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -1509,15 +1537,15 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__decode_token_compat
*
- * Purpose: Decode an object token. (native only)
+ * Purpose: Decode an object token. (native only)
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5R__decode_token_compat(H5VL_object_t *vol_obj, H5I_type_t type, H5R_type_t ref_type,
- const unsigned char *buf, H5VL_token_t *obj_token)
+ const unsigned char *buf, H5O_token_t *obj_token)
{
hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */
H5VL_object_t *vol_obj_file = NULL;
@@ -1581,14 +1609,14 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__encode_token_obj_compat
*
- * Purpose: Encode an object token. (native only)
+ * Purpose: Encode an object token. (native only)
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5R__encode_token_obj_compat(const H5VL_token_t *obj_token, size_t token_size,
+H5R__encode_token_obj_compat(const H5O_token_t *obj_token, size_t token_size,
unsigned char *buf, size_t *nalloc)
{
herr_t ret_value = SUCCEED;
@@ -1612,15 +1640,15 @@ H5R__encode_token_obj_compat(const H5VL_token_t *obj_token, size_t token_size,
/*-------------------------------------------------------------------------
* Function: H5R__decode_token_obj_compat
*
- * Purpose: Decode an object token. (native only)
+ * Purpose: Decode an object token. (native only)
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes,
- H5VL_token_t *obj_token, size_t token_size)
+ H5O_token_t *obj_token, size_t token_size)
{
herr_t ret_value = SUCCEED;
@@ -1647,14 +1675,15 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__encode_token_region_compat
*
- * Purpose: Encode dataset selection and insert data into heap (native only).
+ * Purpose: Encode dataset selection and insert data into heap
+ * (native only).
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5R__encode_token_region_compat(H5F_t *f, const H5VL_token_t *obj_token,
+H5R__encode_token_region_compat(H5F_t *f, const H5O_token_t *obj_token,
size_t token_size, H5S_t *space, unsigned char *buf, size_t *nalloc)
{
size_t buf_size;
@@ -1722,19 +1751,20 @@ done:
/*-------------------------------------------------------------------------
* Function: H5R__decode_token_region_compat
*
- * Purpose: Decode dataset selection from data inserted into heap (native only).
+ * Purpose: Decode dataset selection from data inserted into heap
+ * (native only).
*
- * Return: Non-negative on success/Negative on failure
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf,
- size_t *nbytes, H5VL_token_t *obj_token, size_t token_size,
+ size_t *nbytes, H5O_token_t *obj_token, size_t token_size,
H5S_t **space_ptr)
{
unsigned char *data = NULL;
- H5VL_token_t token = { 0 };
+ H5O_token_t token = { 0 };
size_t data_size;
const uint8_t *p;
herr_t ret_value = SUCCEED;
@@ -1758,12 +1788,13 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf,
if(space_ptr) {
H5O_loc_t oloc; /* Object location */
H5S_t *space = NULL;
- const uint8_t *q = (const uint8_t *)&token;
/* Initialize the object location */
H5O_loc_reset(&oloc);
oloc.file = f;
- H5F_addr_decode(f, &q, &oloc.addr);
+
+ if(H5VL_native_token_to_addr(f, H5I_FILE, token, &oloc.addr) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address")
/* Open and copy the dataset's dataspace */
if(NULL == (space = H5S_read(&oloc)))
@@ -1776,9 +1807,10 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf,
*space_ptr = space;
}
if(obj_token)
- H5MM_memcpy(obj_token, &token, token_size);
+ H5MM_memcpy(obj_token, &token, sizeof(H5O_token_t));
done:
H5MM_free(data);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5R__decode_token_region_compat() */
+