diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2019-04-06 03:08:24 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2019-04-06 03:08:24 (GMT) |
commit | 227b7131d1e4b5edce1c3eecc9a7e7f560363093 (patch) | |
tree | 092dd023f9d401e0c0d1c73588d3f6b836a64c8f /src/H5Snone.c | |
parent | 9e934e75fa9a66bdd95fd3656ca0c19f910123c7 (diff) | |
parent | 4142d8b7d4ac48cffcc2b92af4a54352b329865b (diff) | |
download | hdf5-227b7131d1e4b5edce1c3eecc9a7e7f560363093.zip hdf5-227b7131d1e4b5edce1c3eecc9a7e7f560363093.tar.gz hdf5-227b7131d1e4b5edce1c3eecc9a7e7f560363093.tar.bz2 |
Merge pull request #1642 in HDFFV/hdf5 from ~VCHOI/my_third_fork:bugfix/separate_selection_specific to develop
* commit '4142d8b7d4ac48cffcc2b92af4a54352b329865b':
Move dataspace selection-specific coding to the callbacks as preparation for the H5Sencode changes.
Diffstat (limited to 'src/H5Snone.c')
-rw-r--r-- | src/H5Snone.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/H5Snone.c b/src/H5Snone.c index 86994dd..cae9a67 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -58,8 +58,7 @@ static herr_t H5S__none_release(H5S_t *space); static htri_t H5S__none_is_valid(const H5S_t *space); static hssize_t H5S__none_serial_size(const H5S_t *space); static herr_t H5S__none_serialize(const H5S_t *space, uint8_t **p); -static herr_t H5S__none_deserialize(H5S_t *space, uint32_t version, uint8_t flags, - const uint8_t **p); +static herr_t H5S__none_deserialize(H5S_t **space, const uint8_t **p); static herr_t H5S__none_bounds(const H5S_t *space, hsize_t *start, hsize_t *end); static herr_t H5S__none_offset(const H5S_t *space, hsize_t *off); static int H5S__none_unlim_dim(const H5S_t *space); @@ -602,10 +601,8 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) Deserialize the current selection from a user-provided buffer. USAGE herr_t H5S__none_deserialize(space, version, flags, p) - H5S_t *space; IN/OUT: Dataspace pointer to place + H5S_t **space; IN/OUT: Dataspace pointer to place selection into - uint32_t version IN: Selection version - uint8_t flags IN: Selection flags uint8 **p; OUT: Pointer to buffer holding serialized selection. Will be advanced to end of serialized selection. @@ -620,22 +617,50 @@ H5S__none_serialize(const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S__none_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, - uint8_t H5_ATTR_UNUSED flags, const uint8_t H5_ATTR_UNUSED **p) +H5S__none_deserialize(H5S_t **space, const uint8_t **p) { - herr_t ret_value = SUCCEED; /* return value */ + H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use, + either *space or a newly allocated one */ + uint32_t version; /* Version number */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_STATIC - HDassert(space); HDassert(p); HDassert(*p); + /* As part of the efforts to push all selection-type specific coding + to the callbacks, the coding for the allocation of a null dataspace + is moved from H5S_select_deserialize() in H5Sselect.c to here. + This is needed for decoding virtual layout in H5O__layout_decode() */ + /* Allocate space if not provided */ + if(!*space) { + if(NULL == (tmp_space = H5S_create(H5S_SIMPLE))) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") + } /* end if */ + else + tmp_space = *space; + + /* Decode version */ + UINT32DECODE(*p, version); + + /* Skip over the remainder of the header */ + *p += 8; + /* Change to "none" selection */ - if(H5S_select_none(space) < 0) + if(H5S_select_none(tmp_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") + /* Return space to the caller if allocated */ + if(!*space) + *space = tmp_space; + done: + /* Free temporary space if not passed to caller (only happens on error) */ + if(!*space && tmp_space) + if(H5S_close(tmp_space) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S__none_deserialize() */ |