From 451404ceeeb7bae6cad56a856d097a8ed3f69576 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 23 Jul 1998 16:28:22 -0500 Subject: [PATCH] [svn-r538] Added H5Sset_extent_none and H5Sextent_copy functions. They are wrappers around features already tested. --- src/H5S.c | 149 +++++++++++++++++++++++++++++++++++++++-------- src/H5Sprivate.h | 1 + src/H5Spublic.h | 4 +- src/H5public.h | 2 +- 4 files changed, 131 insertions(+), 25 deletions(-) diff --git a/src/H5S.c b/src/H5S.c index 524d19bfcc..3a46423593 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -166,6 +166,54 @@ done: FUNC_LEAVE(ret_value); } /* end H5Screate() */ +/*------------------------------------------------------------------------- + * Function: H5S_extent_release + * + * Purpose: Releases all memory associated with a dataspace extent. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Thursday, July 23, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5S_extent_release(H5S_t *ds) +{ + FUNC_ENTER(H5S_extent_release, FAIL); + + assert(ds); + + /* release extent */ + switch (ds->extent.type) { + case H5S_NO_CLASS: + /*nothing needed */ + break; + + case H5S_SCALAR: + /*nothing needed */ + break; + + case H5S_SIMPLE: + H5S_release_simple(&(ds->extent.u.simple)); + break; + + case H5S_COMPLEX: + /* nothing yet */ + break; + + default: + assert("unknown dataspace (extent) type" && 0); + break; + } + FUNC_LEAVE(SUCCEED); +} /* end H5S_extent_release() */ + /*------------------------------------------------------------------------- * Function: H5S_close * @@ -192,28 +240,8 @@ H5S_close(H5S_t *ds) /* Release selection (this should come before the extent release) */ H5S_select_release(ds); - /* release extent */ - switch (ds->extent.type) { - case H5S_NO_CLASS: - /*nothing needed */ - break; - - case H5S_SCALAR: - /*nothing needed */ - break; - - case H5S_SIMPLE: - H5S_release_simple(&(ds->extent.u.simple)); - break; - - case H5S_COMPLEX: - /* nothing yet */ - break; - - default: - assert("unknown dataspace (extent) type" && 0); - break; - } + /* Release extent */ + H5S_extent_release(ds); /* Release the main structure */ H5MM_xfree(ds); @@ -333,6 +361,46 @@ H5Scopy (hid_t space_id) FUNC_LEAVE (ret_value); } + +/*------------------------------------------------------------------------- + * Function: H5Sextent_copy + * + * Purpose: Copies a dataspace extent. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * Thursday, July 23, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Sextent_copy (hid_t dst_id,hid_t src_id) +{ + H5S_t *src = NULL; + H5S_t *dst = NULL; + hid_t ret_value = SUCCEED; + + FUNC_ENTER (H5Scopy, FAIL); + H5TRACE2("e","ii",dst_id,src_id); + + /* Check args */ + if (H5_DATASPACE!=H5I_group (src_id) || NULL==(src=H5I_object (src_id))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + } + if (H5_DATASPACE!=H5I_group (dst_id) || NULL==(dst=H5I_object (dst_id))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + } + + /* Copy */ + if (H5S_extent_copy(&(dst->extent),&(src->extent))<0) + HRETURN_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent"); + + FUNC_LEAVE (ret_value); +} + /*------------------------------------------------------------------------- * Function: H5S_extent_copy @@ -1472,10 +1540,45 @@ H5Sextent_class (hid_t sid) ret_value=space->extent.type; - done: FUNC_LEAVE(ret_value); } + +/*-------------------------------------------------------------------------- + NAME + H5Sset_extent_none + PURPOSE + Resets the extent of a dataspace back to "none" + USAGE + herr_t H5Sset_extent_none(space_id) + hid_t space_id; IN: Dataspace object to reset + RETURNS + SUCCEED/FAIL + DESCRIPTION + This function resets the type of a dataspace back to "none" with no + extent information stored for the dataspace. +--------------------------------------------------------------------------*/ +herr_t +H5Sset_extent_none (hid_t space_id) +{ + H5S_t *space = NULL; /* dataspace to modify */ + + FUNC_ENTER(H5Sset_extent_none, FAIL); + H5TRACE1("e","i",space_id); + + /* Check args */ + if ((space = H5I_object(space_id)) == NULL) { + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); + } + + /* Clear the previous extent from the dataspace */ + if(H5S_extent_release(space)<0) + HRETURN_ERROR(H5E_RESOURCE, H5E_CANTDELETE, FAIL, "can't release previous dataspace"); + + space->extent.type=H5S_NO_CLASS; + + FUNC_LEAVE(SUCCEED); +} /* end H5Sset_extent_none() */ /*------------------------------------------------------------------------- * Function: H5S_debug diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index eb1897f25f..611ea27824 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -220,6 +220,7 @@ intn H5S_get_hyperslab (const H5S_t *ds, hssize_t offset[]/*out*/, herr_t H5S_release_simple(H5S_simple_t *simple); herr_t H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src); herr_t H5S_select_copy (H5S_t *dst, const H5S_t *src); +herr_t H5S_extent_release (H5S_t *space); herr_t H5S_select_release (H5S_t *space); herr_t H5S_sel_iter_release (const H5S_t *space,H5S_sel_iter_t *sel_iter); hsize_t H5S_select_npoints (const H5S_t *space); diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 2554f7c1fd..ff7680e195 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -61,7 +61,9 @@ herr_t H5Sselect_hyperslab (hid_t space_id, H5S_seloper_t op, const hsize_t count[], const hsize_t _block[]); herr_t H5Sselect_elements (hid_t space_id, H5S_seloper_t op, size_t num_elemn, const hssize_t **coord); -H5S_class_t H5Sget_class (hid_t space_id); +H5S_class_t H5Sextent_class (hid_t space_id); +herr_t H5Sset_extent_none (hid_t space_id); +herr_t H5Sextent_copy (hid_t dst_id,hid_t src_id); #ifdef __cplusplus } diff --git a/src/H5public.h b/src/H5public.h index 5a10adf5f7..fe73d60c1f 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -27,7 +27,7 @@ /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 0 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 34 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 35 /* For tweaks, bug-fixes, or development */ #define H5check() H5vers_check(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE)