diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2011-04-12 20:25:27 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2011-04-12 20:25:27 (GMT) |
commit | 6fc1d0535960edf24e66ca14afc27b31ec2320db (patch) | |
tree | 3b5cae467443e375c05433294137fe45c0d44717 /src/H5S.c | |
parent | 1285f6734c5916ce54104e05163b4114655d7954 (diff) | |
download | hdf5-6fc1d0535960edf24e66ca14afc27b31ec2320db.zip hdf5-6fc1d0535960edf24e66ca14afc27b31ec2320db.tar.gz hdf5-6fc1d0535960edf24e66ca14afc27b31ec2320db.tar.bz2 |
[svn-r20487] Bug 1386 - allow dimension size to be zero even though it isn't unlimited. This is a follow-up checkin for
r20440 and r20469:
1. The dataspace code has another bug - when the maximal dimension isn't passed in for H5Sset_extent_simple, it
is supposed to be same as the dimension. The current library sets NULL to it. I corrected it and added a
test case to it.
2. I corrected the tests of Fortran and C++ for this problem.
Tested on heiwa, jam, and amani.
Diffstat (limited to 'src/H5S.c')
-rw-r--r-- | src/H5S.c | 25 |
1 files changed, 20 insertions, 5 deletions
@@ -1163,6 +1163,11 @@ H5Sis_simple(hid_t space_id) Raymond Lu 03/30/2011 We allow 0-dimension for non-unlimited dimension starting from 1.8.7 release. + + Raymond Lu 04/11/2011 + I added a condition check to make sure the new size won't exceed the + current maximal size when this function is called to change the + dimension size of an existent dataspace. --------------------------------------------------------------------------*/ herr_t H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], @@ -1197,6 +1202,14 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], } } + /* Check through all the dimensions to see if the new dimension size exceeds the current + * size or if the new maximal size exceeds the current maximal size */ + for(u = 0; u < space->extent.rank; u++) { + if(space->extent.max && H5S_UNLIMITED!=space->extent.max[u] && + (space->extent.max[u]<dims[u] || (max && space->extent.max[u]<max[u]))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new size exceeds current maximal size") + } /* end for */ + /* Do it */ if (H5S_set_extent_simple(space, (unsigned)rank, dims, max)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set simple extent") @@ -1259,13 +1272,15 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, } /* end for */ space->extent.nelem = nelem; - /* Copy the maximum dimensions if specified */ + /* Copy the maximum dimensions if specified. Otherwise, the maximal dimensions are the + * same as the dimension */ + space->extent.max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)rank); if(max != NULL) { - space->extent.max = (hsize_t *)H5FL_ARR_MALLOC(hsize_t, (size_t)rank); HDmemcpy(space->extent.max, max, sizeof(hsize_t) * rank); - } /* end if */ - else - space->extent.max = NULL; + } else { + for(u = 0; u < space->extent.rank; u++) + space->extent.max[u] = dims[u]; + } } /* end else */ /* Selection related cleanup */ |