summaryrefslogtreecommitdiffstats
path: root/src/H5Spoint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1998-11-25 00:29:09 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1998-11-25 00:29:09 (GMT)
commit5d0938aba6d4b99640f57abc41441e7af68a1c2c (patch)
tree813480254a0f728a6eb75ac1478320af1524de00 /src/H5Spoint.c
parent0dfd13d13b2587cbdc3388a205159c25eb83588f (diff)
downloadhdf5-5d0938aba6d4b99640f57abc41441e7af68a1c2c.zip
hdf5-5d0938aba6d4b99640f57abc41441e7af68a1c2c.tar.gz
hdf5-5d0938aba6d4b99640f57abc41441e7af68a1c2c.tar.bz2
[svn-r947] Lots of patches to enable dataset region references. The testing for these
need to be finished and checked in still.
Diffstat (limited to 'src/H5Spoint.c')
-rw-r--r--src/H5Spoint.c66
1 files changed, 65 insertions, 1 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index ae4a217..a68b9b5 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -918,7 +918,7 @@ H5S_point_select_serialize (const H5S_t *space, uint8_t *buf)
buf+=4; /* skip over space for length */
/* Encode number of dimensions */
- UINT32ENCODE(buf, (uint32_t)space->extent.u.simple.rank);
+ INT32ENCODE(buf, (uint32_t)space->extent.u.simple.rank);
len+=4;
/* Encode number of elements */
@@ -946,3 +946,67 @@ H5S_point_select_serialize (const H5S_t *space, uint8_t *buf)
FUNC_LEAVE (ret_value);
} /* H5S_point_select_serialize() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_point_select_deserialize
+ PURPOSE
+ Deserialize the current selection from a user-provided buffer.
+ USAGE
+ herr_t H5S_point_select_deserialize(space, buf)
+ H5S_t *space; IN/OUT: Dataspace pointer to place selection into
+ uint8 *buf; IN: Buffer to retrieve serialized selection from
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ Deserializes the current selection into a buffer. (Primarily for retrieving
+ from disk).
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_point_select_deserialize (H5S_t *space, const uint8_t *buf)
+{
+ H5S_seloper_t op=H5S_SELECT_SET; /* Selection operation */
+ int32_t rank; /* Rank of points */
+ size_t num_elem=0; /* Number of elements in selection */
+ hssize_t *coord=NULL, *tcoord; /* Pointer to array of elements */
+ uintn i,j; /* local counting variables */
+ herr_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5S_point_select_deserialize, FAIL);
+
+ /* Check args */
+ assert(space);
+ assert(buf);
+
+ /* Deserialize points to select */
+ buf+=16; /* Skip over selection header */
+ INT32DECODE(buf,rank); /* decode the rank of the point selection */
+ if(rank!=space->extent.u.simple.rank)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of pointer does not match dataspace");
+ UINT32DECODE(buf,num_elem); /* decode the number of points */
+
+ /* Allocate space for the coordinates */
+ if((coord = H5MM_malloc(num_elem*rank*sizeof(hssize_t)))==NULL)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information");
+
+ /* Retrieve the coordinates from the buffer */
+ for(tcoord=coord,i=0; i<num_elem; i++)
+ for(j=0; j<(unsigned)rank; j++,tcoord++)
+ UINT32DECODE(buf, *tcoord);
+
+ /* Select points */
+ if((ret_value=H5S_select_elements(space,op,num_elem,(const hssize_t **)coord))<0) {
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
+ } /* end if */
+
+done:
+ /* Free the coordinate array if necessary */
+ if(coord!=NULL)
+ H5MM_xfree(coord);
+
+ FUNC_LEAVE (ret_value);
+} /* H5S_point_select_deserialize() */