summaryrefslogtreecommitdiffstats
path: root/src/H5R.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5R.c')
-rw-r--r--src/H5R.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/H5R.c b/src/H5R.c
index 7ee472b..5358dfa 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -2207,7 +2207,7 @@ H5Rdecode(const void *buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "empty buffer")
/* Create datatype by decoding buffer */
- if(NULL == (ret_value = H5R_decode((const unsigned char *)buf)))
+ if(NULL == (ret_value = H5R_decode((const unsigned char *)buf, NULL)))
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't decode reference")
done:
@@ -2225,10 +2225,11 @@ done:
*-------------------------------------------------------------------------
*/
href_t
-H5R_decode(const unsigned char *buf)
+H5R_decode(const unsigned char *buf, size_t *_nbytes)
{
struct href *ret_value = NULL;
size_t buf_size;
+ size_t nbytes = 0;
FUNC_ENTER_NOAPI_NOINIT
@@ -2238,10 +2239,12 @@ H5R_decode(const unsigned char *buf)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Cannot allocate memory for reference")
ret_value->ref_type = (H5R_type_t)*buf++;
+ nbytes++;
if(ret_value->ref_type <= H5R_BADTYPE || ret_value->ref_type >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid reference type");
UINT64DECODE(buf, buf_size);
+ nbytes += sizeof(uint64_t);
if (!buf_size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid reference size");
if (ret_value->ref_type == H5R_OBJECT)
@@ -2252,6 +2255,9 @@ H5R_decode(const unsigned char *buf)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Cannot allocate memory for reference")
HDmemcpy(ret_value->ref.serial.buf, buf, buf_size);
}
+ nbytes += buf_size;
+
+ if (_nbytes) *_nbytes = nbytes;
done:
FUNC_LEAVE_NOAPI(ret_value)