diff options
Diffstat (limited to 'src/H5Sselect.c')
-rw-r--r-- | src/H5Sselect.c | 116 |
1 files changed, 55 insertions, 61 deletions
diff --git a/src/H5Sselect.c b/src/H5Sselect.c index dbbc927..873f555 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -112,7 +112,7 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5S_select_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) +H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) { herr_t ret_value = FAIL; /* Return value */ @@ -123,10 +123,10 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) HDassert(src); /* Copy regular fields */ - dst->select=src->select; + dst->select = src->select; /* Perform correct type of copy based on the type of selection */ - if((ret_value=(*src->select.type->copy)(dst,src,share_selection))<0) + if((ret_value = (*src->select.type->copy)(dst,src,share_selection)) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy selection specific information") done: @@ -148,8 +148,6 @@ done: * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -157,13 +155,15 @@ H5S_select_release(H5S_t *ds) { herr_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_NOAPI_NOINIT HDassert(ds); /* Call the selection type's release function */ - ret_value=(*ds->select.type->release)(ds); + if((ret_value = (*ds->select.type->release)(ds)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection") +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_release() */ @@ -183,8 +183,6 @@ H5S_select_release(H5S_t *ds) * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -194,13 +192,15 @@ H5S_select_get_seq_list(const H5S_t *space, unsigned flags, { herr_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_NOAPI_NOINIT HDassert(space); /* Call the selection type's get_seq_list function */ - ret_value = (*space->select.type->get_seq_list)(space, flags, iter, maxseq, maxbytes, nseq, nbytes, off, len); + if((ret_value = (*space->select.type->get_seq_list)(space, flags, iter, maxseq, maxbytes, nseq, nbytes, off, len)) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get selection sequence list") +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_select_get_seq_list() */ @@ -220,8 +220,6 @@ H5S_select_get_seq_list(const H5S_t *space, unsigned flags, * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * - * Modifications: - * *------------------------------------------------------------------------- */ hssize_t @@ -896,11 +894,11 @@ H5S_select_is_regular(const H5S_t *space) PURPOSE Adjust a selection by subtracting an offset USAGE - herr_t H5S_select_adjust_u(space, offset) + void H5S_select_adjust_u(space, offset) H5S_t *space; IN/OUT: Pointer to dataspace to adjust const hsize_t *offset; IN: Offset to subtract RETURNS - Non-negative on success, negative on failure + None DESCRIPTION Moves a selection by subtracting an offset from it. GLOBAL VARIABLES @@ -911,19 +909,18 @@ H5S_select_is_regular(const H5S_t *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t +void H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) { - herr_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(space); + HDassert(offset); - ret_value = (*space->select.type->adjust_u)(space, offset); + (*space->select.type->adjust_u)(space, offset); - FUNC_LEAVE_NOAPI(ret_value) + FUNC_LEAVE_NOAPI_VOID } /* H5S_select_adjust_u() */ @@ -1611,8 +1608,8 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) { H5S_sel_iter_t *iter_a = NULL; /* Selection a iteration info */ H5S_sel_iter_t *iter_b = NULL; /* Selection b iteration info */ - hbool_t iter_a_init = 0; /* Selection a iteration info has been initialized */ - hbool_t iter_b_init = 0; /* Selection b iteration info has been initialized */ + hbool_t iter_a_init = FALSE; /* Selection a iteration info has been initialized */ + hbool_t iter_b_init = FALSE; /* Selection b iteration info has been initialized */ htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1621,13 +1618,13 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) HDassert(space1); HDassert(space2); - /* Special case for one or both dataspaces being scalar */ - if(space1->extent.rank == 0 || space2->extent.rank == 0) { - /* Check for different number of elements selected */ - if(H5S_GET_SELECT_NPOINTS(space1) != H5S_GET_SELECT_NPOINTS(space2)) - HGOTO_DONE(FALSE) - } /* end if */ - else { + /* Check for different number of elements selected */ + if(H5S_GET_SELECT_NPOINTS(space1) != H5S_GET_SELECT_NPOINTS(space2)) + HGOTO_DONE(FALSE) + + /* Check special cases if both dataspaces aren't scalar */ + /* (If only one is, the number of selected points check is sufficient) */ + if(space1->extent.rank > 0 && space2->extent.rank > 0) { const H5S_t *space_a; /* Dataspace with larger rank */ const H5S_t *space_b; /* Dataspace with smaller rank */ unsigned space_a_rank; /* Number of dimensions of dataspace A */ @@ -1697,7 +1694,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) space_b_dim--; } /* end while */ - /* Since we are selecting the entire spaces, we must also verify that space_a + /* Since we are selecting the entire space, we must also verify that space_a * has size 1 in all dimensions that it does not share with space_b. */ while(space_a_dim >= 0) { @@ -1708,6 +1705,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end while */ } /* end if */ else if((H5S_GET_SELECT_TYPE(space1) == H5S_SEL_NONE) || (H5S_GET_SELECT_TYPE(space2) == H5S_SEL_NONE)) { + /* (Both must be, at this point, if one is) */ HGOTO_DONE(TRUE) } /* end if */ else if((H5S_GET_SELECT_TYPE(space_a) == H5S_SEL_HYPERSLABS && space_a->select.sel_info.hslab->diminfo_valid) @@ -1747,13 +1745,13 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end if */ /* Iterate through all the blocks in the selection */ else { - hsize_t start_a[H5O_LAYOUT_NDIMS]; /* Start point of selection block in dataspace a */ - hsize_t start_b[H5O_LAYOUT_NDIMS]; /* Start point of selection block in dataspace b */ - hsize_t end_a[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace a */ - hsize_t end_b[H5O_LAYOUT_NDIMS]; /* End point of selection block in dataspace b */ - hsize_t off_a[H5O_LAYOUT_NDIMS]; /* Offset of selection a blocks */ - hsize_t off_b[H5O_LAYOUT_NDIMS]; /* Offset of selection b blocks */ - hbool_t first_block = TRUE; /* Flag to indicate the first block */ + hsize_t start_a[H5S_MAX_RANK]; /* Start point of selection block in dataspace a */ + hsize_t start_b[H5S_MAX_RANK]; /* Start point of selection block in dataspace b */ + hsize_t end_a[H5S_MAX_RANK]; /* End point of selection block in dataspace a */ + hsize_t end_b[H5S_MAX_RANK]; /* End point of selection block in dataspace b */ + hsize_t off_a[H5S_MAX_RANK]; /* Offset of selection a blocks */ + hsize_t off_b[H5S_MAX_RANK]; /* Offset of selection b blocks */ + hbool_t first_block = TRUE; /* Flag to indicate the first block */ /* Allocate the selection iterators */ if(NULL == (iter_a = H5FL_MALLOC(H5S_sel_iter_t))) @@ -1768,10 +1766,10 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) */ if(H5S_select_iter_init(iter_a, space_a, (size_t)0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator a") - iter_a_init = 1; + iter_a_init = TRUE; if(H5S_select_iter_init(iter_b, space_b, (size_t)0) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator b") - iter_b_init = 1; + iter_b_init = TRUE; /* Iterate over all the blocks in each selection */ while(1) { @@ -1874,7 +1872,7 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) } /* end else */ } /* end while */ } /* end else */ - } /* end else */ + } /* end if */ done: if(iter_a_init && H5S_SELECT_ITER_RELEASE(iter_a) < 0) @@ -1900,7 +1898,7 @@ done: topologically identical to that in b (as verified by H5S_select_shape_same(). - This function exists, as some I/O code chokes of topologically + This function exists, as some I/O code chokes on topologically identical selections with different ranks. At least to begin with, we will deal with the issue by constructing projections of the memory dataspace with ranks equaling those of the file @@ -2150,10 +2148,9 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, done: /* Cleanup on error */ - if(ret_value < 0) { + if(ret_value < 0) if(new_space && H5S_close(new_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5S_select_construct_projection() */ @@ -2281,7 +2278,7 @@ done: H5S_t *src_space; IN: Selection that is mapped to dst_space, and intersected with src_intersect_space H5S_t *dst_space; IN: Selection that is mapped to src_space, and which contains the result H5S_t *src_intersect_space; IN: Selection whose intersection with src_space is projected to dst_space to obtain the result - H5S_t *proj_space; OUT: Will contain the result (intersection of src_intersect_space and src_space projected from src_space to dst_space) after the operation + H5S_t **new_space_ptr; OUT: Will contain the result (intersection of src_intersect_space and src_space projected from src_space to dst_space) after the operation RETURNS Non-negative on success/Negative on failure. @@ -2290,7 +2287,7 @@ done: Projects the intersection of of the selections of src_space and src_intersect_space within the selection of src_space as a selection within the selection of dst_space. The result is placed in the - selection of proj_space. + selection of new_space_ptr. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS @@ -2352,10 +2349,9 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, done: /* Cleanup on error */ - if(ret_value < 0) { + if(ret_value < 0) if(new_space && H5S_close(new_space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5S_select_project_intersection() */ @@ -2408,28 +2404,26 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") } /* end if */ else { - /* Check for point selection in subtract_space, convert to - * hyperslab */ + /* Check for point selection in subtract_space, convert to hyperslab */ if(subtract_space->select.type->type == H5S_SEL_POINTS) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported") - /* Check for point or all selection in space, convert to hyperslab - */ + /* Check for point or all selection in space, convert to hyperslab */ if(space->select.type->type == H5S_SEL_ALL) { /* Convert current "all" selection to "real" hyperslab selection */ /* Then allow operation to proceed */ - hsize_t tmp_start[H5O_LAYOUT_NDIMS]; /* Temporary start information */ - hsize_t tmp_stride[H5O_LAYOUT_NDIMS]; /* Temporary stride information */ - hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary count information */ - hsize_t tmp_block[H5O_LAYOUT_NDIMS]; /* Temporary block information */ - unsigned i; /* Local index variable */ + hsize_t tmp_start[H5S_MAX_RANK]; /* Temporary start information */ + hsize_t tmp_stride[H5S_MAX_RANK]; /* Temporary stride information */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary count information */ + hsize_t tmp_block[H5S_MAX_RANK]; /* Temporary block information */ + unsigned u; /* Local index variable */ /* Fill in temporary information for the dimensions */ - for(i = 0; i < space->extent.rank; i++) { - tmp_start[i] = 0; - tmp_stride[i] = 1; - tmp_count[i] = 1; - tmp_block[i] = space->extent.size[i]; + for(u = 0; u < space->extent.rank; u++) { + tmp_start[u] = 0; + tmp_stride[u] = 1; + tmp_count[u] = 1; + tmp_block[u] = space->extent.size[u]; } /* end for */ /* Convert to hyperslab selection */ |