summaryrefslogtreecommitdiffstats
path: root/src/H5Snone.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Snone.c')
-rw-r--r--src/H5Snone.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/H5Snone.c b/src/H5Snone.c
index 3c5eccc..a6c870a 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -478,17 +478,17 @@ H5S_none_serial_size(const H5S_t UNUSED *space)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_serialize(const H5S_t *space, uint8_t *buf)
+H5S_none_serialize(const H5S_t *space, uint8_t **p)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(space);
/* Store the preamble information */
- UINT32ENCODE(buf, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */
- UINT32ENCODE(buf, (uint32_t)1); /* Store the version number */
- UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */
- UINT32ENCODE(buf, (uint32_t)0); /* Store the additional information length */
+ UINT32ENCODE(*p, (uint32_t)H5S_GET_SELECT_TYPE(space)); /* Store the type of selection */
+ UINT32ENCODE(*p, (uint32_t)1); /* Store the version number */
+ UINT32ENCODE(*p, (uint32_t)0); /* Store the un-used padding */
+ UINT32ENCODE(*p, (uint32_t)0); /* Store the additional information length */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5S_none_serialize() */
@@ -514,19 +514,41 @@ H5S_none_serialize(const H5S_t *space, uint8_t *buf)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_none_deserialize(H5S_t *space, const uint8_t UNUSED *buf)
+H5S_none_deserialize(H5S_t **space, const uint8_t **p)
{
+ H5S_t *tmp_space;
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_NOAPI_NOINIT
HDassert(space);
+ HDassert(p);
+ HDassert(*p);
+
+ /* 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;
+
+ /* Skip over the remainder of the header */
+ *p += 12;
/* 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")
+ 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)
} /* H5S_none_deserialize() */