diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2004-10-05 18:36:03 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2004-10-05 18:36:03 (GMT) |
commit | d595bab80e5932009c0ff626ddc75f1346fcef1e (patch) | |
tree | de9204ddd68494fe85e86ce36a5c576381c82bb5 | |
parent | 7ba45c05b3e9345bc8d77a5d205bb41086b78f1e (diff) | |
download | hdf5-d595bab80e5932009c0ff626ddc75f1346fcef1e.zip hdf5-d595bab80e5932009c0ff626ddc75f1346fcef1e.tar.gz hdf5-d595bab80e5932009c0ff626ddc75f1346fcef1e.tar.bz2 |
[svn-r9366]
Purpose: feature change
Description: Prevent creating datatype of size 0.
Platforms tested: fuss(simple change)
-rw-r--r-- | release_docs/RELEASE.txt | 4 | ||||
-rw-r--r-- | src/H5T.c | 6 | ||||
-rw-r--r-- | test/dtypes.c | 17 |
3 files changed, 19 insertions, 8 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index cfa6f5f..2c29bb8 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -52,8 +52,8 @@ New Features -------- - Compound datatype has been enhanced with a new feature of size adjustment. The size can be increased and decreased(without - cutting the last member). No API change is involved. SLU - - 2004/10/1 + cutting the last member) as long as it doesn't go down to zero. + No API change is involved. SLU - 2004/10/1 - Put back 6 old error API functions to be backward compatible with version 1.6. They are H5Epush, H5Eprint, H5Ewalk, H5Eclear, H5Eset_auto, H5Eget_auto. Their new equivalent functions are @@ -1453,8 +1453,8 @@ H5Tcreate(H5T_class_t type, size_t size) FUNC_ENTER_API(H5Tcreate, FAIL); H5TRACE2("i","Ttz",type,size); - /* check args. We start to support size adjustment for compound type. */ - if (size == 0 && type != H5T_COMPOUND) + /* check args */ + if (size == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid size"); /* create the type */ @@ -2024,6 +2024,8 @@ H5Tset_size(hid_t type_id, size_t size) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined"); if (H5T_REFERENCE==dt->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for this datatype"); + if (size==0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't adjust size to 0"); /* Do the work */ if (H5T_set_size(dt, size)<0) diff --git a/test/dtypes.c b/test/dtypes.c index e07e200..6d67bf0 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -2098,8 +2098,12 @@ test_compound_12(void) TESTING("adjust size of compound data types"); - /* Create the empty compound type */ - if ((complex_id = H5Tcreate(H5T_COMPOUND, 0))<0) goto error; + /* Create a compound type of minimal size */ + if ((complex_id = H5Tcreate(H5T_COMPOUND, 1))<0) goto error; + + /* Verify the size */ + if((new_size=H5Tget_size(complex_id))<0) goto error; + if(new_size!=1) goto error; /* Add a couple fields and adjust the size */ offset = size; @@ -2128,9 +2132,14 @@ test_compound_12(void) /* Tries to cut last member. Supposed to fail. */ size--; H5E_BEGIN_TRY { - H5Tset_size(complex_id, size); + ret = H5Tset_size(complex_id, size); } H5E_END_TRY; - + if(ret>=0) { + H5_FAILED(); + puts(" Tries to cut off the last member. Should have failed."); + goto error; + } + if (H5Tclose (complex_id)<0) goto error; PASSED(); return 0; |