summaryrefslogtreecommitdiffstats
path: root/src/H5Spoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Spoint.c')
-rw-r--r--src/H5Spoint.c72
1 files changed, 39 insertions, 33 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 4970321..b824875 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -45,15 +45,15 @@ 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_bounds(const H5S_t *space, hssize_t *start, hssize_t *end);
+static herr_t H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
static htri_t H5S_point_is_contiguous(const H5S_t *space);
static htri_t H5S_point_is_single(const H5S_t *space);
static htri_t H5S_point_is_regular(const H5S_t *space);
static herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
/* Selection iteration callbacks */
-static herr_t H5S_point_iter_coords(const H5S_sel_iter_t *iter, hssize_t *coords);
-static herr_t H5S_point_iter_block(const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end);
+static herr_t H5S_point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
+static herr_t H5S_point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end);
static hsize_t H5S_point_iter_nelmts(const H5S_sel_iter_t *iter);
static htri_t H5S_point_iter_has_next_block(const H5S_sel_iter_t *iter);
static herr_t H5S_point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
@@ -152,7 +152,7 @@ H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space)
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_point_iter_coords (const H5S_sel_iter_t *iter, hssize_t *coords)
+H5S_point_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_coords);
@@ -161,7 +161,7 @@ H5S_point_iter_coords (const H5S_sel_iter_t *iter, hssize_t *coords)
assert (coords);
/* Copy the offset of the current point */
- HDmemcpy(coords,iter->u.pnt.curr->pnt,sizeof(hssize_t)*iter->rank);
+ HDmemcpy(coords,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank);
FUNC_LEAVE_NOAPI(SUCCEED);
} /* H5S_point_iter_coords() */
@@ -183,7 +183,7 @@ H5S_point_iter_coords (const H5S_sel_iter_t *iter, hssize_t *coords)
*-------------------------------------------------------------------------
*/
static herr_t
-H5S_point_iter_block (const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end)
+H5S_point_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_iter_block);
@@ -193,8 +193,8 @@ H5S_point_iter_block (const H5S_sel_iter_t *iter, hssize_t *start, hssize_t *end
assert (end);
/* Copy the current point as a block */
- HDmemcpy(start,iter->u.pnt.curr->pnt,sizeof(hssize_t)*iter->rank);
- HDmemcpy(end,iter->u.pnt.curr->pnt,sizeof(hssize_t)*iter->rank);
+ HDmemcpy(start,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank);
+ HDmemcpy(end,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank);
FUNC_LEAVE_NOAPI(SUCCEED);
} /* H5S_point_iter_block() */
@@ -369,7 +369,7 @@ H5S_point_iter_release (H5S_sel_iter_t UNUSED * iter)
herr_t H5S_point_add(space, num_elem, coord)
H5S_t *space; IN: Dataspace of selection to modify
size_t num_elem; IN: Number of elements in COORD array.
- const hssize_t *coord[]; IN: The location of each element selected
+ const hsize_t *coord[]; IN: The location of each element selected
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -380,10 +380,10 @@ H5S_point_iter_release (H5S_sel_iter_t UNUSED * iter)
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hssize_t **_coord)
+H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t **_coord)
{
H5S_pnt_node_t *top, *curr, *new_node; /* Point selection nodes */
- const hssize_t *coord=(const hssize_t *)_coord; /* Pointer to the actual coordinates */
+ const hsize_t *coord=(const hsize_t *)_coord; /* Pointer to the actual coordinates */
unsigned i; /* Counter */
herr_t ret_value=SUCCEED; /* Return value */
@@ -400,11 +400,11 @@ H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hssize_t *
if((new_node = H5FL_MALLOC(H5S_pnt_node_t))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node");
- if((new_node->pnt = H5MM_malloc(space->extent.rank*sizeof(hssize_t)))==NULL)
+ if((new_node->pnt = H5MM_malloc(space->extent.rank*sizeof(hsize_t)))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information");
/* Copy over the coordinates */
- HDmemcpy(new_node->pnt,coord+(i*space->extent.rank),(space->extent.rank*sizeof(hssize_t)));
+ HDmemcpy(new_node->pnt,coord+(i*space->extent.rank),(space->extent.rank*sizeof(hsize_t)));
/* Link into list */
new_node->next=NULL;
@@ -505,7 +505,7 @@ H5S_point_release (H5S_t *space)
hid_t dsid; IN: Dataspace ID of selection to modify
H5S_seloper_t op; IN: Operation to perform on current selection
size_t num_elem; IN: Number of elements in COORD array.
- const hssize_t **coord; IN: The location of each element selected
+ const hsize_t **coord; IN: The location of each element selected
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -527,7 +527,7 @@ H5S_point_release (H5S_t *space)
--------------------------------------------------------------------------*/
herr_t
H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem,
- const hssize_t **coord)
+ const hsize_t **coord)
{
herr_t ret_value=SUCCEED; /* return value */
@@ -603,9 +603,9 @@ H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t UNUSED share_selection)
/* Create each point */
if((new_node=H5FL_MALLOC(H5S_pnt_node_t))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node");
- if((new_node->pnt = H5MM_malloc(src->extent.rank*sizeof(hssize_t)))==NULL)
+ if((new_node->pnt = H5MM_malloc(src->extent.rank*sizeof(hsize_t)))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information");
- HDmemcpy(new_node->pnt,curr->pnt,(src->extent.rank*sizeof(hssize_t)));
+ HDmemcpy(new_node->pnt,curr->pnt,(src->extent.rank*sizeof(hsize_t)));
new_node->next=NULL;
/* Keep the order the same when copying */
@@ -662,8 +662,8 @@ H5S_point_is_valid (const H5S_t *space)
for(u=0; u<space->extent.rank; u++) {
/* Check if an offset has been defined */
/* Bounds check the selected point + offset against the extent */
- if(((curr->pnt[u]+space->select.offset[u])>(hssize_t)space->extent.size[u])
- || ((curr->pnt[u]+space->select.offset[u])<0))
+ if(((curr->pnt[u]+space->select.offset[u])>space->extent.size[u])
+ || (((hssize_t)curr->pnt[u]+space->select.offset[u])<0))
HGOTO_DONE(FALSE)
} /* end for */
@@ -852,7 +852,7 @@ H5S_point_deserialize (H5S_t *space, const uint8_t *buf)
H5S_seloper_t op=H5S_SELECT_SET; /* Selection operation */
uint32_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 */
+ hsize_t *coord=NULL, *tcoord; /* Pointer to array of elements */
unsigned i,j; /* local counting variables */
herr_t ret_value; /* return value */
@@ -870,7 +870,7 @@ H5S_point_deserialize (H5S_t *space, const uint8_t *buf)
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)
+ if((coord = H5MM_malloc(num_elem*rank*sizeof(hsize_t)))==NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information");
/* Retrieve the coordinates from the buffer */
@@ -879,7 +879,7 @@ H5S_point_deserialize (H5S_t *space, const uint8_t *buf)
UINT32DECODE(buf, *tcoord);
/* Select points */
- if((ret_value=H5S_select_elements(space,op,num_elem,(const hssize_t **)coord))<0)
+ if((ret_value=H5S_select_elements(space,op,num_elem,(const hsize_t **)coord))<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
done:
@@ -945,7 +945,7 @@ H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoint
/* Iterate through the node, copying each hyperslab's information */
while(node!=NULL && numpoints>0) {
- HDmemcpy(buf,node->pnt,sizeof(hssize_t)*rank);
+ HDmemcpy(buf,node->pnt,sizeof(hsize_t)*rank);
buf+=rank;
numpoints--;
node=node->next;
@@ -1016,8 +1016,8 @@ done:
USAGE
herr_t H5S_point_bounds(space, start, end)
H5S_t *space; IN: Dataspace pointer of selection to query
- hssize_t *start; OUT: Starting coordinate of bounding box
- hssize_t *end; OUT: Opposite coordinate of bounding box
+ hsize_t *start; OUT: Starting coordinate of bounding box
+ hsize_t *end; OUT: Opposite coordinate of bounding box
RETURNS
Non-negative on success, negative on failure
DESCRIPTION
@@ -1035,13 +1035,14 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_bounds(const H5S_t *space, hssize_t *start, hssize_t *end)
+H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
{
H5S_pnt_node_t *node; /* Point node */
int rank; /* Dataspace rank */
int i; /* index variable */
+ herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_point_bounds);
+ FUNC_ENTER_NOAPI_NOINIT(H5S_point_bounds);
assert(space);
assert(start);
@@ -1052,14 +1053,18 @@ H5S_point_bounds(const H5S_t *space, hssize_t *start, hssize_t *end)
/* Set the start and end arrays up */
for(i=0; i<rank; i++) {
- start[i]=HSSIZET_MAX;
- end[i]=HSSIZET_MIN;
+ start[i]=HSIZET_MAX;
+ end[i]=0;
} /* end for */
/* Iterate through the node, checking the bounds on each element */
node=space->select.sel_info.pnt_lst->head;
while(node!=NULL) {
for(i=0; i<rank; i++) {
+ /* Check for offset moving selection negative */
+ if(((hssize_t)node->pnt[i]+space->select.offset[i])<0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
+
if(start[i]>(node->pnt[i]+space->select.offset[i]))
start[i]=node->pnt[i]+space->select.offset[i];
if(end[i]<(node->pnt[i]+space->select.offset[i]))
@@ -1068,7 +1073,8 @@ H5S_point_bounds(const H5S_t *space, hssize_t *start, hssize_t *end)
node=node->next;
} /* end while */
- FUNC_LEAVE_NOAPI(SUCCEED);
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
} /* H5S_point_bounds() */
@@ -1200,7 +1206,7 @@ H5S_point_is_regular(const H5S_t *space)
hid_t dsid; IN: Dataspace ID of selection to modify
H5S_seloper_t op; IN: Operation to perform on current selection
size_t num_elem; IN: Number of elements in COORD array.
- const hssize_t **coord; IN: The location of each element selected
+ const hsize_t **coord; IN: The location of each element selected
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -1222,13 +1228,13 @@ H5S_point_is_regular(const H5S_t *space)
--------------------------------------------------------------------------*/
herr_t
H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem,
- const hssize_t **coord)
+ const hsize_t **coord)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Sselect_elements, FAIL);
- H5TRACE4("e","iSsz**Hs",spaceid,op,num_elem,coord);
+ H5TRACE4("e","iSsz**h",spaceid,op,num_elem,coord);
/* Check args */
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))