diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2011-04-07 21:56:38 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2011-04-07 21:56:38 (GMT) |
commit | 4b7f286a45b24de8cb5d08780df21fc7b79542ed (patch) | |
tree | 7d02277da5b03000fcc25ef6b6d4f2356e77e634 /src/H5S.c | |
parent | baba8a3d59da7ab265900a4e94a7ee47d8856a4e (diff) | |
download | hdf5-4b7f286a45b24de8cb5d08780df21fc7b79542ed.zip hdf5-4b7f286a45b24de8cb5d08780df21fc7b79542ed.tar.gz hdf5-4b7f286a45b24de8cb5d08780df21fc7b79542ed.tar.bz2 |
[svn-r20440] Bug 1386 - allow dimension size to be zero even though it isn't unlimited. I added test cases for contiguous, compact, and chunked, and external storage datasets, and also attribute. The test includes dataspace selections. I'll handle the tools in the next step.
Tested on jam, amani, and heiwa.
Diffstat (limited to 'src/H5S.c')
-rw-r--r-- | src/H5S.c | 30 |
1 files changed, 14 insertions, 16 deletions
@@ -1160,14 +1160,17 @@ H5Sis_simple(hid_t space_id) 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 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 */ - herr_t ret_value=SUCCEED; /* Return value */ + int u; /* local counting variable */ + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Sset_extent_simple, FAIL) H5TRACE4("e", "iIs*[a1]h*[a1]h", space_id, rank, dims, max); @@ -1183,8 +1186,6 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], 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 && max[u]!=H5S_UNLIMITED) || max==NULL) && dims[u]==0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimension size") } } if (max!=NULL) { @@ -1303,6 +1304,11 @@ done: * Programmer: Quincey Koziol * Tuesday, January 27, 1998 * + * Modification: + * Raymond Lu 03/30/2011 + * We allow 0-dimension for non-unlimited dimension starting + * from 1.8.7 release. + * *------------------------------------------------------------------------- */ hid_t @@ -1332,17 +1338,9 @@ H5Screate_simple(int rank, const hsize_t dims[/*rank*/], for(i = 0; i < rank; i++) { if(H5S_UNLIMITED == dims[i]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "current dimension must have a specific size, not H5S_UNLIMITED") - if(maxdims) { - if(H5S_UNLIMITED != maxdims[i] && maxdims[i]<dims[i]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "maxdims is smaller than dims") - if(H5S_UNLIMITED != maxdims[i] && dims[i] == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero sized dimension for non-unlimited dimension") - } /* end if */ - else { - if(dims[i] == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero sized dimension for non-unlimited dimension") - } /* end else */ - } /* end else */ + if(maxdims && H5S_UNLIMITED != maxdims[i] && maxdims[i]<dims[i]) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "maxdims is smaller than dims") + } /* end for */ /* Create the space and set the extent */ if(NULL == (space = H5S_create_simple((unsigned)rank,dims,maxdims))) @@ -1906,7 +1904,7 @@ H5S_set_extent_real(H5S_t *space, const hsize_t *size) /* Change the dataspace size & re-compute the number of elements in the extent */ for(u = 0, nelem = 1; u < space->extent.rank; u++ ) { space->extent.size[u] = size[u]; - nelem *= space->extent.size[u]; + nelem *= size[u]; } /* end for */ space->extent.nelem = nelem; |