diff options
author | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2016-06-28 21:48:27 (GMT) |
---|---|---|
committer | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2016-11-29 23:42:33 (GMT) |
commit | 78c3616db1cdcddd3bbfde8c6ad800b37c8e8de5 (patch) | |
tree | 6adced3fbfed834fd1498440f791527c252eb0d5 /src | |
parent | 3e91f3c1a43d676c4888bfcb645fc5657939eb54 (diff) | |
download | hdf5-78c3616db1cdcddd3bbfde8c6ad800b37c8e8de5.zip hdf5-78c3616db1cdcddd3bbfde8c6ad800b37c8e8de5.tar.gz hdf5-78c3616db1cdcddd3bbfde8c6ad800b37c8e8de5.tar.bz2 |
Modify H5R_decode to return number of decoded bytes
Diffstat (limited to 'src')
-rw-r--r-- | src/H5R.c | 10 | ||||
-rw-r--r-- | src/H5Rprivate.h | 2 |
2 files changed, 9 insertions, 3 deletions
@@ -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) diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h index 056f95f..3175328 100644 --- a/src/H5Rprivate.h +++ b/src/H5Rprivate.h @@ -40,7 +40,7 @@ H5_DLL herr_t H5R_destroy(href_t ref); H5_DLL H5R_type_t H5R_get_type(href_t ref); H5_DLL herr_t H5R_encode(href_t ref, unsigned char *buf, size_t *nalloc); -H5_DLL href_t H5R_decode(const unsigned char *buf); +H5_DLL href_t H5R_decode(const unsigned char *buf, size_t *nbytes); H5_DLL herr_t H5R_cast(href_t _ref, H5R_type_t ref_type); |