diff options
Diffstat (limited to 'src/H5S.c')
-rw-r--r-- | src/H5S.c | 684 |
1 files changed, 292 insertions, 392 deletions
@@ -27,16 +27,16 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Spkg.h" /* Dataspaces */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Spkg.h" /* Dataspaces */ /****************/ /* Local Macros */ /****************/ -/* Version of datatype encoding */ +/* Version of dataspace encoding */ #define H5S_ENCODE_VERSION 0 /******************/ @@ -55,14 +55,6 @@ static H5S_t *H5S_decode(const unsigned char *buf); /* Package Variables */ /*********************/ -/*****************************/ -/* Library Private Variables */ -/*****************************/ - -/*******************/ -/* Local Variables */ -/*******************/ - /* Declare a free list to manage the H5S_extent_t struct */ H5FL_DEFINE(H5S_extent_t); @@ -72,6 +64,10 @@ H5FL_DEFINE(H5S_t); /* Declare a free list to manage the array's of hsize_t's */ H5FL_ARR_DEFINE(hsize_t, H5S_MAX_RANK); +/*******************/ +/* Local Variables */ +/*******************/ + /* Dataspace ID class */ static const H5I_class_t H5I_DATASPACE_CLS[1] = {{ H5I_DATASPACE, /* ID class value */ @@ -90,7 +86,6 @@ RETURNS Non-negative on success/Negative on failure DESCRIPTION Initializes any interface-specific data or routines. - --------------------------------------------------------------------------*/ static herr_t H5S_init_interface(void) @@ -99,7 +94,7 @@ H5S_init_interface(void) FUNC_ENTER_NOAPI_NOINIT - /* Initialize the atom group for the file IDs */ + /* Initialize the atom group for the dataspace IDs */ if (H5I_register_type(H5I_DATASPACE_CLS) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface") @@ -170,8 +165,8 @@ H5S_term_interface(void) H5S_t * H5S_create(H5S_class_t type) { - H5S_t *new_ds = NULL; /* New dataspace created */ - H5S_t *ret_value; /* Return value */ + H5S_t *new_ds = NULL; /* New dataspace created */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -219,10 +214,9 @@ H5S_create(H5S_class_t type) ret_value = new_ds; done: - if (ret_value == NULL) { + if (ret_value == NULL) if (new_ds && H5S_close(new_ds) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace") - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_create() */ @@ -266,25 +260,22 @@ H5Screate(H5S_class_t type) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: - if (ret_value < 0) { + if (ret_value < 0) if (new_ds && H5S_close(new_ds) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Screate() */ /*------------------------------------------------------------------------- - * Function: H5S_extent_release + * Function: H5S_extent_release * - * Purpose: Releases all memory associated with a dataspace extent. + * Purpose: Releases all memory associated with a dataspace extent. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, July 23, 1998 - * - * Modifications: + * Programmer: Quincey Koziol + * Thursday, July 23, 1998 * *------------------------------------------------------------------------- */ @@ -310,14 +301,14 @@ done: } /* end H5S_extent_release() */ /*------------------------------------------------------------------------- - * Function: H5S_close + * Function: H5S_close * - * Purpose: Releases all memory associated with a dataspace. + * Purpose: Releases all memory associated with a dataspace. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ @@ -346,18 +337,14 @@ done: } /* end H5S_close() */ /*------------------------------------------------------------------------- - * Function: H5Sclose + * Function: H5Sclose * - * Purpose: Release access to a dataspace object. + * Purpose: Release access to a dataspace object. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Errors: - * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 - * - * Modifications: + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ @@ -382,63 +369,58 @@ done: } /* end H5Sclose() */ /*------------------------------------------------------------------------- - * Function: H5Scopy + * Function: H5Scopy * - * Purpose: Copies a dataspace. + * Purpose: Copies a dataspace. * - * Return: Success: ID of the new dataspace + * Return: Success: ID of the new dataspace * - * Failure: Negative - * - * Programmer: Robb Matzke - * Friday, January 30, 1998 + * Failure: H5I_INVALID_HID * - * Modifications: + * Programmer: Robb Matzke + * Friday, January 30, 1998 * *------------------------------------------------------------------------- */ hid_t H5Scopy(hid_t space_id) { - H5S_t *src; - H5S_t *dst = NULL; - hid_t ret_value; + H5S_t *src = NULL; + H5S_t *dst = NULL; + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", space_id); /* Check args */ if (NULL == (src = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") /* Copy */ if (NULL == (dst = H5S_copy(src, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy dataspace") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy dataspace") /* Atomize */ if ((ret_value = H5I_register(H5I_DATASPACE, dst, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") done: - if (ret_value < 0) { + if (H5I_INVALID_HID == ret_value) if (dst && H5S_close(dst) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - } /* end if */ + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Scopy() */ /*------------------------------------------------------------------------- - * Function: H5Sextent_copy + * Function: H5Sextent_copy * - * Purpose: Copies a dataspace extent. + * Purpose: Copies a dataspace extent. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, July 23, 1998 - * - * Modifications: + * Programmer: Quincey Koziol + * Thursday, July 23, 1998 * *------------------------------------------------------------------------- */ @@ -447,7 +429,7 @@ H5Sextent_copy(hid_t dst_id, hid_t src_id) { H5S_t *src; H5S_t *dst; - hid_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "ii", dst_id, src_id); @@ -473,16 +455,14 @@ done: } /* end H5Sextent_copy() */ /*------------------------------------------------------------------------- - * Function: H5S_extent_copy - * - * Purpose: Copies a dataspace extent + * Function: H5S_extent_copy * - * Return: Non-negative on success/Negative on failure + * Purpose: Copies a dataspace extent * - * Programmer: Quincey Koziol - * Wednesday, June 3, 1998 + * Return: Non-negative on success/Negative on failure * - * Modifications: + * Programmer: Neil Fortner + * Monday, February 23, 2015 * *------------------------------------------------------------------------- */ @@ -543,31 +523,29 @@ done: } /* end H5S_extent_copy() */ /*------------------------------------------------------------------------- - * Function: H5S_copy + * Function: H5S_copy * - * Purpose: Copies a dataspace, by copying the extent and selection through - * H5S_extent_copy and H5S_select_copy. If the SHARE_SELECTION flag - * is set, then the selection can be shared between the source and - * destination dataspaces. (This should only occur in situations - * where the destination dataspace will immediately change to a new - * selection) + * Purpose: Copies a dataspace, by copying the extent and selection through + * H5S_extent_copy and H5S_select_copy. If the SHARE_SELECTION flag + * is set, then the selection can be shared between the source and + * destination dataspaces. (This should only occur in situations + * where the destination dataspace will immediately change to a new + * selection) * - * Return: Success: A pointer to a new copy of SRC + * Return: Success: A pointer to a new copy of SRC * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 - * - * Modifications: + * Programmer: Robb Matzke + * Thursday, December 4, 1997 * *------------------------------------------------------------------------- */ H5S_t * H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max) { - H5S_t *dst = NULL; - H5S_t *ret_value; /* Return value */ + H5S_t *dst = NULL; + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -594,30 +572,27 @@ done: } /* end H5S_copy() */ /*------------------------------------------------------------------------- - * Function: H5S_get_simple_extent_npoints + * Function: H5S_get_simple_extent_npoints * - * Purpose: Determines how many data points a dataset extent has. + * Purpose: Determines how many data points a dataset extent has. * - * Return: Success: Number of data points in the dataset extent. + * Return: Success: Number of data points in the dataset extent. * - * Failure: negative + * Failure: Negative * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * - * Modifications: - * Changed Name - QAK 7/7/98 - * *------------------------------------------------------------------------- */ hssize_t H5S_get_simple_extent_npoints(const H5S_t *ds) { - hssize_t ret_value; + hssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(-1) @@ -632,19 +607,15 @@ done: } /* end H5S_get_simple_extent_npoints() */ /*------------------------------------------------------------------------- - * Function: H5Sget_simple_extent_npoints - * - * Purpose: Determines how many data points a dataset extent has. + * Function: H5Sget_simple_extent_npoints * - * Return: Success: Number of data points in the dataset. + * Purpose: Determines how many data points a dataset extent has. * - * Failure: negative - * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Return: Success: Number of data points in the dataset. + * Failure: Negative * - * Modifications: - * Changed Name - QAK 7/7/98 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ @@ -668,31 +639,28 @@ done: } /* end H5Sget_simple_extent_npoints() */ /*------------------------------------------------------------------------- - * Function: H5S_get_npoints_max + * Function: H5S_get_npoints_max * - * Purpose: Determines the maximum number of data points a dataspace may - * have. If the `max' array is null then the maximum number of - * data points is the same as the current number of data points - * without regard to the hyperslab. If any element of the `max' - * array is zero then the maximum possible size is returned. + * Purpose: Determines the maximum number of data points a dataspace may + * have. If the `max' array is null then the maximum number of + * data points is the same as the current number of data points + * without regard to the hyperslab. If any element of the `max' + * array is zero then the maximum possible size is returned. * - * Return: Success: Maximum number of data points the dataspace - * may have. - * - * Failure: 0 - * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Return: Success: Maximum number of data points the dataspace + * may have. + * Failure: 0 * - * Modifications: + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ hsize_t H5S_get_npoints_max(const H5S_t *ds) { - hsize_t ret_value; unsigned u; + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(0) @@ -719,10 +687,9 @@ H5S_get_npoints_max(const H5S_t *ds) ret_value *= ds->extent.max[u]; } } - else { + else for (ret_value = 1, u = 0; u < ds->extent.rank; u++) ret_value *= ds->extent.size[u]; - } break; case H5S_NO_CLASS: @@ -733,21 +700,18 @@ H5S_get_npoints_max(const H5S_t *ds) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5S_get_npoints_max() */ /*------------------------------------------------------------------------- - * Function: H5Sget_simple_extent_ndims - * - * Purpose: Determines the dimensionality of a dataspace. + * Function: H5Sget_simple_extent_ndims * - * Return: Success: The number of dimensions in a dataspace. + * Purpose: Determines the dimensionality of a dataspace. * - * Failure: Negative - * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Return: Success: The number of dimensions in a dataspace. + * Failure: Negative * - * Modifications: + * Programmer: Robb Matzke + * Thursday, December 11, 1997 * *------------------------------------------------------------------------- */ @@ -755,14 +719,14 @@ int H5Sget_simple_extent_ndims(hid_t space_id) { H5S_t *ds; - int ret_value; + int ret_value = -1; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", space_id); /* Check args */ if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a dataspace") ret_value = (int)H5S_GET_EXTENT_NDIMS(ds); @@ -771,30 +735,28 @@ done: } /* end H5Sget_simple_extent_ndims() */ /*------------------------------------------------------------------------- - * Function: H5S_get_simple_extent_ndims + * Function: H5S_get_simple_extent_ndims * - * Purpose: Returns the number of dimensions in a dataspace. + * Purpose: Returns the number of dimensions in a dataspace. * - * Return: Success: Non-negative number of dimensions. Zero - * implies a scalar. + * Return: Success: Non-negative number of dimensions. + * Zero implies a scalar. * - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 + * Programmer: Robb Matzke + * hursday, December 11, 1997 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * - * Modifications: - * *------------------------------------------------------------------------- */ int H5S_get_simple_extent_ndims(const H5S_t *ds) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -819,24 +781,18 @@ done: } /* end H5S_get_simple_extent_ndims() */ /*------------------------------------------------------------------------- - * Function: H5Sget_simple_extent_dims + * Function: H5Sget_simple_extent_dims * - * Purpose: Returns the size and maximum sizes in each dimension of - * a dataspace DS through the DIMS and MAXDIMS arguments. + * Purpose: Returns the size and maximum sizes in each dimension of + * a dataspace DS through the DIMS and MAXDIMS arguments. * - * Return: Success: Number of dimensions, the same value as - * returned by H5Sget_simple_extent_ndims(). + * Return: Success: Number of dimensions, the same value as + * returned by H5Sget_simple_extent_ndims(). * - * Failure: Negative + * Failure: Negative * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 - * - * Modifications: - * June 18, 1998 Albert Cheng - * Added maxdims argument. Removed dims argument check - * since it can still return ndims even if both dims and - * maxdims are NULLs. + * Programmer: Robb Matzke + * Thursday, December 11, 1997 * *------------------------------------------------------------------------- */ @@ -844,40 +800,40 @@ int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[] /*out*/, hsize_t maxdims[] /*out*/) { H5S_t *ds; - int ret_value; + int ret_value = -1; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE3("Is", "ixx", space_id, dims, maxdims); /* Check args */ if (NULL == (ds = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a dataspace") ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims); done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Sget_simple_extent_dims() */ /*------------------------------------------------------------------------- - * Function: H5S_extent_get_dims + * Function: H5S_extent_get_dims * - * Purpose: Returns the size in each dimension of a dataspace. This - * function may not be meaningful for all types of dataspaces. + * Purpose: Returns the size in each dimension of a dataspace. This + * function may not be meaningful for all types of dataspaces. * - * Return: Success: Number of dimensions. Zero implies scalar. - * Failure: Negative + * Return: Success: Number of dimensions. Zero implies scalar. + * Failure: Negative * - * Programmer: Quincey Koziol - * Tuesday, June 30, 2009 + * Programmer: Quincey Koziol + * Tuesday, June 30, 2009 * *------------------------------------------------------------------------- */ int H5S_extent_get_dims(const H5S_extent_t *ext, hsize_t dims[], hsize_t max_dims[]) { - int i; /* Local index variable */ - int ret_value; /* Return value */ + int i; /* Local index variable */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -915,26 +871,23 @@ done: } /* end H5S_extent_get_dims() */ /*------------------------------------------------------------------------- - * Function: H5S_get_simple_extent_dims + * Function: H5S_get_simple_extent_dims * - * Purpose: Returns the size in each dimension of a dataspace. This - * function may not be meaningful for all types of dataspaces. + * Purpose: Returns the size in each dimension of a dataspace. This + * function may not be meaningful for all types of dataspaces. * - * Return: Success: Number of dimensions. Zero implies scalar. + * Return: Success: Number of dimensions. Zero implies scalar. + * Failure: Negative * - * Failure: Negative - * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 - * - * Modifications: + * Programmer: Robb Matzke + * Thursday, December 11, 1997 * *------------------------------------------------------------------------- */ int H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[]) { - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -950,15 +903,15 @@ done: } /* end H5S_get_simple_extent_dims() */ /*------------------------------------------------------------------------- - * Function: H5S_write + * Function: H5S_write * - * Purpose: Updates a dataspace by writing a message to an object - * header. + * Purpose: Updates a dataspace by writing a message to an object + * header. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ @@ -983,22 +936,14 @@ done: } /* end H5S_write() */ /*------------------------------------------------------------------------- - * Function: H5S_append - * - * Purpose: Updates a dataspace by adding a message to an object - * header. + * Function: H5S_append * - * Return: Non-negative on success/Negative on failure + * Purpose: Updates a dataspace by adding a message to an object header. * - * Programmer: Quincey Koziol - * Tuesday, December 31, 2002 + * Return: Non-negative on success/Negative on failure * - * Modifications: - * - * John Mainzer, 6/6/05 - * Updated function to use the new dirtied parameter of - * H5AC_unprotect() instead of manipulating the is_dirty - * field of the cache info. + * Programmer: Quincey Koziol + * Tuesday, December 31, 2002 * *------------------------------------------------------------------------- */ @@ -1023,24 +968,24 @@ done: } /* end H5S_append() */ /*------------------------------------------------------------------------- - * Function: H5S_read + * Function: H5S_read * - * Purpose: Reads the dataspace from an object header. + * Purpose: Reads the dataspace from an object header. * - * Return: Success: Pointer to a new dataspace. + * Return: Success: Pointer to a new dataspace. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 * *------------------------------------------------------------------------- */ H5S_t * H5S_read(const H5O_loc_t *loc, hid_t dxpl_id) { - H5S_t *ds = NULL; /* Dataspace to return */ - H5S_t *ret_value; /* Return value */ + H5S_t *ds = NULL; /* Dataspace to return */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1061,10 +1006,9 @@ H5S_read(const H5O_loc_t *loc, hid_t dxpl_id) ret_value = ds; done: - if (ret_value == NULL) { + if (ret_value == NULL) if (ds != NULL) ds = H5FL_FREE(H5S_t, ds); - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_read() */ @@ -1080,13 +1024,13 @@ done: RETURNS TRUE/FALSE/FAIL DESCRIPTION - This function determines the if a dataspace is "simple". ie. if it + This function determines the if a dataspace is "simple". ie. if it has orthogonal, evenly spaced dimensions. --------------------------------------------------------------------------*/ static htri_t H5S_is_simple(const H5S_t *sdim) { - htri_t ret_value; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1107,18 +1051,18 @@ H5S_is_simple(const H5S_t *sdim) Check if a dataspace is simple USAGE htri_t H5Sis_simple(space_id) - hid_t space_id; IN: ID of dataspace object to query + hid_t space_id; IN: ID of dataspace object to query RETURNS TRUE/FALSE/FAIL DESCRIPTION - This function determines the if a dataspace is "simple". ie. if it + This function determines the if a dataspace is "simple". ie. if it has orthogonal, evenly spaced dimensions. --------------------------------------------------------------------------*/ htri_t H5Sis_simple(hid_t space_id) { - H5S_t *space; /* dataspace to modify */ - htri_t ret_value; + H5S_t *space; /* Dataspace to check */ + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", space_id); @@ -1140,11 +1084,11 @@ done: Sets the size of a simple dataspace USAGE herr_t H5Sset_extent_simple(space_id, rank, dims, max) - hid_t space_id; IN: Dataspace object to query - int rank; IN: # of dimensions for the dataspace - const size_t *dims; IN: Size of each dimension for the dataspace - const size_t *max; IN: Maximum size of each dimension for the - dataspace + hid_t space_id; IN: Dataspace object to query + int rank; IN: # of dimensions for the dataspace + const size_t *dims; IN: Size of each dimension for the dataspace + const size_t *max; IN: Maximum size of each dimension for the + dataspace RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -1158,21 +1102,12 @@ done: Currently, only the first dimension in the array (the slowest) may be unlimited in size. - MODIFICATION - A null dataspace cannot be created from simple space with this function. - - Christian Chilan 01/17/2007 - Verifies that each element of DIMS is not equal to H5S_UNLIMITED. - - Raymond Lu 03/30/2011 - We allow 0 dimension size for non-unlimited dimension starting from 1.8.7 - release. --------------------------------------------------------------------------*/ herr_t H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], const hsize_t max[/*rank*/]) { - H5S_t *space; /* dataspace to modify */ - int u; /* local counting variable */ + H5S_t *space; /* Dataspace to modify */ + int u; /* Local counting variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1185,21 +1120,18 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], con HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified") if (rank < 0 || rank > H5S_MAX_RANK) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank") - if (dims) { - for (u = 0; u < rank; u++) { + if (dims) + for (u = 0; u < rank; u++) if (H5S_UNLIMITED == dims[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "current dimension must have a specific size, not H5S_UNLIMITED") - } - } if (max != NULL) { if (dims == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "maximum dimension specified, but no current dimensions specified") - for (u = 0; u < rank; u++) { + for (u = 0; u < rank; u++) if (max[u] != H5S_UNLIMITED && max[u] < dims[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid maximum dimension size") - } } /* Do it */ @@ -1208,21 +1140,18 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], con done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Sset_extent_simple() */ /*------------------------------------------------------------------------- - * Function: H5S_set_extent_simple + * Function: H5S_set_extent_simple * - * Purpose: This is where the real work happens for - * H5Sset_extent_simple(). + * Purpose: This is where the real work happens for H5Sset_extent_simple(). * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke (copied from H5Sset_extent_simple) + * Programmer: Robb Matzke * Wednesday, July 8, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -1287,31 +1216,26 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, const hs done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_set_extent_simple() */ +} /* end H5S_set_extent_simple() */ /*------------------------------------------------------------------------- - * Function: H5Screate_simple + * Function: H5Screate_simple * - * Purpose: Creates a new simple dataspace object and opens it for - * access. The DIMS argument is the size of the simple dataset - * and the MAXDIMS argument is the upper limit on the size of - * the dataset. MAXDIMS may be the null pointer in which case - * the upper limit is the same as DIMS. If an element of - * MAXDIMS is H5S_UNLIMITED then the corresponding dimension is - * unlimited, otherwise no element of MAXDIMS should be smaller - * than the corresponding element of DIMS. + * Purpose: Creates a new simple dataspace object and opens it for + * access. The DIMS argument is the size of the simple dataset + * and the MAXDIMS argument is the upper limit on the size of + * the dataset. MAXDIMS may be the null pointer in which case + * the upper limit is the same as DIMS. If an element of + * MAXDIMS is H5S_UNLIMITED then the corresponding dimension is + * unlimited, otherwise no element of MAXDIMS should be smaller + * than the corresponding element of DIMS. * - * Return: Success: The ID for the new simple dataspace object. - * - * Failure: Negative + * Return: Success: The ID for the new simple dataspace object. * - * Programmer: Quincey Koziol - * Tuesday, January 27, 1998 + * Failure: H5I_INVALID_HID * - * Modification: - * Raymond Lu 03/30/2011 - * We allow 0-dimension for non-unlimited dimension starting - * from 1.8.7 release. + * Programmer: Quincey Koziol + * Tuesday, January 27, 1998 * *------------------------------------------------------------------------- */ @@ -1320,72 +1244,65 @@ H5Screate_simple(int rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/ { H5S_t *space = NULL; int i; - hid_t ret_value; + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "Is*[a0]h*[a0]h", rank, dims, maxdims); /* Check arguments */ if (rank < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality cannot be negative") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dimensionality cannot be negative") if (rank > H5S_MAX_RANK) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimensionality is too large") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "dimensionality is too large") /* We allow users to use this function to create scalar or null dataspace. * Check DIMS isn't set when the RANK is 0. */ if (!dims && rank != 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dataspace information") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid dataspace information") /* Check whether the current dimensions are valid */ for (i = 0; i < rank; i++) { if (H5S_UNLIMITED == dims[i]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "current dimension must have a specific size, not H5S_UNLIMITED") if (maxdims && H5S_UNLIMITED != maxdims[i] && maxdims[i] < dims[i]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "maxdims is smaller than dims") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "maxdims is smaller than dims") } /* end for */ /* Create the space and set the extent */ if (NULL == (space = H5S_create_simple((unsigned)rank, dims, maxdims))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, H5I_INVALID_HID, "can't create simple dataspace") /* Atomize */ if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace ID") done: - if (ret_value < 0) { + if (ret_value < 0) if (space && H5S_close(space) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - } /* end if */ + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to release dataspace") FUNC_LEAVE_API(ret_value) } /* end H5Screate_simple() */ /*------------------------------------------------------------------------- - * Function: H5S_create_simple + * Function: H5S_create_simple * - * Purpose: Internal function to create simple dataspace + * Purpose: Internal function to create simple dataspace * - * Return: Success: The ID for the new simple dataspace object. - * Failure: Negative + * Return: Success: A pointer to a dataspace object + * Failure: NULL * - * Errors: - * - * Programmer: Quincey Koziol - * Thursday, April 3, 2003 - * - * Modifications: - * Extracted from H5Screate_simple - * Quincey Koziol, Thursday, April 3, 2003 + * Programmer: Quincey Koziol + * Thursday, April 3, 2003 * *------------------------------------------------------------------------- */ H5S_t * H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]) { - H5S_t *ret_value; /* Return value */ + H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1403,21 +1320,17 @@ done: } /* end H5S_create_simple() */ /*------------------------------------------------------------------------- - * Function: H5Sencode + * Function: H5Sencode * - * Purpose: Given a dataspace ID, converts the object description + * Purpose: Given a dataspace ID, converts the object description * (including selection) into binary in a buffer. * - * Return: Success: non-negative + * Return: Success: Non-negative + * Failure: Negative * - * Failure: negative - * - * Programmer: Raymond Lu - * slu@ncsa.uiuc.edu + * Programmer: Raymond Lu * July 14, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -1438,20 +1351,18 @@ H5Sencode(hid_t obj_id, void *buf, size_t *nalloc) done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Sencode() */ /*------------------------------------------------------------------------- - * Function: H5S_encode + * Function: H5S_encode * - * Purpose: Private function for H5Sencode. Converts an object + * Purpose: Private function for H5Sencode. Converts an object * description for dataspace and its selection into binary * in a buffer. * - * Return: Success: non-negative - * Failure: negative + * Return: SUCCEED/FAIL * - * Programmer: Raymond Lu - * slu@ncsa.uiuc.edu + * Programmer: Raymond Lu * July 14, 2004 * *------------------------------------------------------------------------- @@ -1459,11 +1370,11 @@ done: static herr_t H5S_encode(H5S_t *obj, unsigned char *buf, size_t *nalloc) { - size_t extent_size; /* Size of serialized dataspace extent */ - hssize_t sselect_size; /* Signed size of serialized dataspace selection */ - size_t select_size; /* Size of serialized dataspace selection */ - H5F_t * f = NULL; /* Fake file structure*/ - herr_t ret_value = SUCCEED; + H5F_t * f = NULL; /* Fake file structure*/ + size_t extent_size; /* Size of serialized dataspace extent */ + hssize_t sselect_size; /* Signed size of serialized dataspace selection */ + size_t select_size; /* Size of serialized dataspace selection */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1516,17 +1427,16 @@ done: } /* end H5S_encode() */ /*------------------------------------------------------------------------- - * Function: H5Sdecode + * Function: H5Sdecode * - * Purpose: Decode a binary object description of dataspace and + * Purpose: Decode a binary object description of dataspace and * return a new object handle. * - * Return: Success: dataspace ID(non-negative) + * Return: Success: dataspace ID(non-negative) * - * Failure: negative + * Failure: H5I_INVALID_HID * - * Programmer: Raymond Lu - * slu@ncsa.uiuc.edu + * Programmer: Raymond Lu * July 14, 2004 * *------------------------------------------------------------------------- @@ -1537,35 +1447,34 @@ H5Sdecode(const void *buf) H5S_t *ds; hid_t ret_value; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "*x", buf); if (buf == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty buffer") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "empty buffer") if ((ds = H5S_decode((const unsigned char *)buf)) == NULL) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, FAIL, "can't decode object") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDECODE, H5I_INVALID_HID, "can't decode object") /* Register the type and return the ID */ if ((ret_value = H5I_register(H5I_DATASPACE, ds, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTREGISTER, FAIL, "unable to register dataspace") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace") done: FUNC_LEAVE_API(ret_value) } /* end H5Sdecode() */ /*------------------------------------------------------------------------- - * Function: H5S_decode + * Function: H5S_decode * - * Purpose: Private function for H5Sdecode. Reconstructs a binary + * Purpose: Private function for H5Sdecode. Reconstructs a binary * description of dataspace and returns a new object handle. * - * Return: Success: dataspace ID(non-negative) + * Return: Success: Pointer to a dataspace buffer * - * Failure: negative + * Failure: NULL * - * Programmer: Raymond Lu - * slu@ncsa.uiuc.edu + * Programmer: Raymond Lu * July 14, 2004 * *------------------------------------------------------------------------- @@ -1573,12 +1482,12 @@ done: static H5S_t * H5S_decode(const unsigned char *buf) { - H5S_t * ds; - H5S_extent_t *extent; - size_t extent_size; /* size of the extent message*/ - H5F_t * f = NULL; /* Fake file structure*/ - uint8_t sizeof_size; /* 'Size of sizes' for file */ - H5S_t * ret_value; + H5F_t * f = NULL; /* Fake file structure*/ + H5S_t * ds; /* Decoded dataspace */ + H5S_extent_t * extent; /* Entent of decoded dataspace */ + size_t extent_size; /* size of the extent message*/ + uint8_t sizeof_size; /* 'Size of sizes' for file */ + H5S_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1637,31 +1546,27 @@ done: } /* end H5S_decode() */ /*------------------------------------------------------------------------- - * Function: H5S_get_simple_extent_type - * - * Purpose: Internal function for retrieving the type of extent for a dataspace object + * Function: H5S_get_simple_extent_type * - * Return: Success: The class of the dataspace object + * Purpose: Internal function for retrieving the type of extent for a dataspace object * - * Failure: N5S_NO_CLASS + * Return: Success: The class of the dataspace object * - * Errors: + * Failure: N5S_NO_CLASS * - * Programmer: Quincey Koziol - * Thursday, September 28, 2000 + * Programmer: Quincey Koziol + * Thursday, September 28, 2000 * * Note: This routine participates in the "Inlining C function pointers" * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * - * Modifications: - * *------------------------------------------------------------------------- */ H5S_class_t H5S_get_simple_extent_type(const H5S_t *space) { - H5S_class_t ret_value; + H5S_class_t ret_value = H5S_NO_CLASS; /* Return value */ FUNC_ENTER_NOAPI(H5S_NO_CLASS) @@ -1671,23 +1576,19 @@ H5S_get_simple_extent_type(const H5S_t *space) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5S_get_simple_extent_type() */ /*------------------------------------------------------------------------- - * Function: H5Sget_simple_extent_type - * - * Purpose: Retrieves the type of extent for a dataspace object - * - * Return: Success: The class of the dataspace object + * Function: H5Sget_simple_extent_type * - * Failure: N5S_NO_CLASS + * Purpose: Retrieves the type of extent for a dataspace object * - * Errors: + * Return: Success: The class of the dataspace object * - * Programmer: Quincey Koziol - * Thursday, July 23, 1998 + * Failure: N5S_NO_CLASS * - * Modifications: + * Programmer: Quincey Koziol + * Thursday, July 23, 1998 * *------------------------------------------------------------------------- */ @@ -1695,7 +1596,7 @@ H5S_class_t H5Sget_simple_extent_type(hid_t sid) { H5S_t * space; - H5S_class_t ret_value; + H5S_class_t ret_value; /* Return value */ FUNC_ENTER_API(H5S_NO_CLASS) H5TRACE1("Sc", "i", sid); @@ -1708,7 +1609,7 @@ H5Sget_simple_extent_type(hid_t sid) done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Sget_simple_extent_type() */ /*-------------------------------------------------------------------------- NAME @@ -1717,17 +1618,17 @@ done: 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 + hid_t space_id; IN: Dataspace object to reset RETURNS Non-negative on success/Negative on failure DESCRIPTION - This function resets the type of a dataspace back to "none" with no + This function resets the type of a dataspace to H5S_NULL with no extent information stored for the dataspace. --------------------------------------------------------------------------*/ herr_t H5Sset_extent_none(hid_t space_id) { - H5S_t *space; /* dataspace to modify */ + H5S_t *space; /* Dataspace to modify */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1792,12 +1693,11 @@ done: /*------------------------------------------------------------------------- * Function: H5S_set_extent * - * Purpose: Modify the dimensions of a dataspace. Based on H5S_extend + * Purpose: Modify the dimensions of a dataspace. * - * Return: Success: Non-negative - * Failure: Negative + * Return: TRUE/FALSE/FAIL * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * March 13, 2002 * *------------------------------------------------------------------------- @@ -1815,7 +1715,7 @@ H5S_set_extent(H5S_t *space, const hsize_t *size) HDassert(size); /* Verify that the dimensions being changed are allowed to change */ - for (u = 0; u < space->extent.rank; u++) { + for (u = 0; u < space->extent.rank; u++) if (space->extent.size[u] != size[u]) { /* Check for invalid dimension size modification */ if (space->extent.max && H5S_UNLIMITED != space->extent.max[u] && space->extent.max[u] < size[u]) @@ -1826,7 +1726,6 @@ H5S_set_extent(H5S_t *space, const hsize_t *size) /* Indicate that dimension size can be modified */ ret_value = TRUE; } /* end if */ - } /* end for */ /* Update dimension size(s) */ if (ret_value) @@ -1855,7 +1754,7 @@ done: hbool_t H5S_has_extent(const H5S_t *ds) { - hbool_t ret_value; + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1872,12 +1771,12 @@ H5S_has_extent(const H5S_t *ds) /*------------------------------------------------------------------------- * Function: H5S_set_extent_real * - * Purpose: Modify the dimensions of a dataspace. Based on H5S_extend + * Purpose: Modify the dimensions of a dataspace. * * Return: Success: Non-negative * Failure: Negative * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * March 13, 2002 * *------------------------------------------------------------------------- @@ -1916,23 +1815,24 @@ done: } /* end H5S_set_extent_real() */ /*------------------------------------------------------------------------- - * Function: H5Sextent_equal + * Function: H5Sextent_equal * - * Purpose: Determines if two dataspace extents are equal. + * Purpose: Determines if two dataspace extents are equal. * - * Return: Success: TRUE if equal, FALSE if unequal + * Return: Success: TRUE if equal, FALSE if unequal * - * Failure: Negative + * Failure: FAIL * - * Programmer: Quincey Koziol - * Monday, October 24, 2005 + * Programmer: Quincey Koziol + * Monday, October 24, 2005 * *------------------------------------------------------------------------- */ htri_t H5Sextent_equal(hid_t space1_id, hid_t space2_id) { - const H5S_t *ds1, *ds2; /* Dataspaces to compare */ + const H5S_t *ds1; /* Dataspaces to compare */ + const H5S_t *ds2; htri_t ret_value; FUNC_ENTER_API(FAIL) @@ -1958,11 +1858,11 @@ done: Check if two dataspaces have equal extents USAGE htri_t H5S_extent_equal(ds1, ds2) - H5S_t *ds1, *ds2; IN: Dataspace objects to compare + H5S_t *ds1, *ds2; IN: Dataspace objects to compare RETURNS TRUE if equal, FALSE if unequal on succeess/Negative on failure DESCRIPTION - Compare two dataspaces if their extents are identical. + Compare two dataspaces if their extents are identical. --------------------------------------------------------------------------*/ htri_t H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2) @@ -2011,15 +1911,15 @@ done: } /* end H5S_extent_equal() */ /*------------------------------------------------------------------------- - * Function: H5S_extent_nelem + * Function: H5S_extent_nelem * - * Purpose: Determines how many elements a dataset extent describes. + * Purpose: Determines how many elements a dataset extent describes. * - * Return: Success: Number of data points in the dataset extent. - * Failure: negative + * Return: Success: Number of data points in the dataset extent. + * Failure: Negative * - * Programmer: Quincey Koziol - * Thursday, November 30, 2006 + * Programmer: Quincey Koziol + * Thursday, November 30, 2006 * *------------------------------------------------------------------------- */ @@ -2040,7 +1940,7 @@ H5S_extent_nelem(const H5S_extent_t *ext) * * Purpose: Set the encoding for a dataspace to the latest version. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Tuesday, July 24, 2007 |