summaryrefslogtreecommitdiffstats
path: root/src/H5Spoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Spoint.c')
-rw-r--r--src/H5Spoint.c60
1 files changed, 20 insertions, 40 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index e55834d..e6a4a39 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -41,8 +41,8 @@ static herr_t H5S_point_get_seq_list(const H5S_t *space, unsigned flags,
static herr_t H5S_point_release(H5S_t *space);
static htri_t H5S_point_is_valid(const H5S_t *space);
static hssize_t H5S_point_serial_size(const H5S_t *space);
-static herr_t H5S_point_serialize(const H5S_t *space, uint8_t *buf);
-static herr_t H5S_point_deserialize(H5S_t *space, const uint8_t *buf);
+static herr_t H5S_point_serialize(const H5S_t *space, uint8_t **p);
+static herr_t H5S_point_deserialize(H5S_t *space, const uint8_t **p);
static herr_t H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
static herr_t H5S_point_offset(const H5S_t *space, hsize_t *off);
static htri_t H5S_point_is_contiguous(const H5S_t *space);
@@ -804,9 +804,11 @@ H5S_point_serial_size (const H5S_t *space)
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- herr_t H5S_point_serialize(space, buf)
- H5S_t *space; IN: Dataspace pointer of selection to serialize
- uint8 *buf; OUT: Buffer to put serialized selection into
+ herr_t H5S_point_serialize(space, p)
+ const H5S_t *space; IN: Dataspace with selection to serialize
+ uint8_t **p; OUT: Pointer to buffer to put serialized
+ selection. Will be advanced to end of
+ serialized selection.
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -848,7 +850,7 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p)
curr=space->select.sel_info.pnt_lst->head;
while(curr!=NULL) {
/* Add 4 bytes times the rank for each element selected */
- *p+=4*space->extent.rank;
+ len+=4*space->extent.rank;
/* Encode each point */
for(u=0; u<space->extent.rank; u++)
@@ -870,9 +872,12 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p)
PURPOSE
Deserialize the current selection from a user-provided buffer.
USAGE
- herr_t H5S_point_deserialize(space, buf)
- H5S_t *space; IN/OUT: Dataspace pointer to place selection into
- uint8 *buf; IN: Buffer to retrieve serialized selection from
+ herr_t H5S_point_deserialize(space, p)
+ H5S_t *space; IN/OUT: Dataspace pointer to place
+ selection into
+ uint8 **p; OUT: Pointer to buffer holding serialized
+ selection. Will be advanced to end of
+ serialized selection.
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -884,11 +889,10 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_deserialize (H5S_t **space, const uint8_t **p)
+H5S_point_deserialize (H5S_t *space, const uint8_t **p)
{
- H5S_t *tmp_space;
H5S_seloper_t op=H5S_SELECT_SET; /* Selection operation */
- uint32_t rank; /* Rank of points */
+ unsigned rank; /* Rank of points */
size_t num_elem=0; /* Number of elements in selection */
hsize_t *coord=NULL, *tcoord; /* Pointer to array of elements */
unsigned i, j; /* local counting variables */
@@ -902,25 +906,9 @@ H5S_point_deserialize (H5S_t **space, const uint8_t **p)
HDassert(*p);
/* Deserialize points to select */
- *p += 12; /* Skip over remaining selection header */
- UINT32DECODE(*p, rank); /* decode the rank of the point selection */
- UINT32DECODE(*p, num_elem); /* decode the number of points */
-
- /* 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")
-
- /* Set rank of dataspace */
- tmp_space->extent.rank = rank;
- } /* end if */
- else {
- tmp_space = *space;
-
- /* Verify rank of dataspace */
- if(rank!=tmp_space->extent.rank)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of pointer does not match dataspace")
- } /* end else */
+ /* The header and rank have already beed decoded */
+ rank = space->extent.rank; /* Retrieve rank from space */
+ UINT32DECODE(*p, num_elem); /* decode the number of points */
/* Allocate space for the coordinates */
if(NULL == (coord = (hsize_t *)H5MM_malloc(num_elem * rank * sizeof(hsize_t))))
@@ -932,18 +920,10 @@ H5S_point_deserialize (H5S_t **space, const uint8_t **p)
UINT32DECODE(*p, *tcoord);
/* Select points */
- if(H5S_select_elements(tmp_space, op, num_elem, (const hsize_t *)coord) < 0)
+ if(H5S_select_elements(space, op, num_elem, (const hsize_t *)coord) < 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")
-
/* Free the coordinate array if necessary */
if(coord != NULL)
H5MM_xfree(coord);