summaryrefslogtreecommitdiffstats
path: root/src/H5Oattr.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-04-17 20:31:50 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-04-17 20:31:50 (GMT)
commit880d8357bf87cf0761e53ecb0c7b1fb1edbd1528 (patch)
treed71b5c1c36fdbd5571079c8782477308e95284eb /src/H5Oattr.c
parent7456a9293d0672d8c327f58951b30aa911d95dc2 (diff)
downloadhdf5-880d8357bf87cf0761e53ecb0c7b1fb1edbd1528.zip
hdf5-880d8357bf87cf0761e53ecb0c7b1fb1edbd1528.tar.gz
hdf5-880d8357bf87cf0761e53ecb0c7b1fb1edbd1528.tar.bz2
[svn-r8376] Purpose:
Code cleanup Description: Update null dataspace changes to try to write older version of dataspace information whenever possible. Refactor common code to only one location. Allow I/O operations to succeed on null dataspaces. Platforms tested: FreeBSD 4.9 (sleipnir) h5committest
Diffstat (limited to 'src/H5Oattr.c')
-rw-r--r--src/H5Oattr.c51
1 files changed, 11 insertions, 40 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 7ca18cf..2fd4677 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -181,47 +181,18 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED *
if (NULL==(attr->ds = H5FL_CALLOC(H5S_t)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- if((extent=(H5O_SDSPACE->decode)(f,dxpl_id,p,NULL))!=NULL) {
- unsigned i; /* Local index variable */
-
- if(extent->type != H5S_NO_CLASS) { /* File is new, created by version 1.7 or after */
- /* Compute the number of elements in the extent */
- if(extent->type == H5S_NULL)
- extent->nelem = 0;
- else {
- for(i=0, extent->nelem=1; i<extent->u.simple.rank; i++)
- extent->nelem*=extent->u.simple.size[i];
- }
- } else { /* File was created by version 1.6 or before, when there was no H5S_NULL */
- /* Set the dataspace type to be simple or scalar as appropriate */
- if(extent->u.simple.rank>0)
- extent->type = H5S_SIMPLE;
- else
- extent->type = H5S_SCALAR;
-
- /* Compute the number of elements in the extent */
- for(i=0, extent->nelem=1; i<extent->u.simple.rank; i++)
- extent->nelem*=extent->u.simple.size[i];
- }
-
- /* Copy the extent information */
- HDmemcpy(&(attr->ds->extent),extent, sizeof(H5S_extent_t));
-
- /* Release temporary extent information */
- H5FL_FREE(H5S_extent_t,extent);
- } else {
- attr->ds->extent.type = H5S_NULL;
- attr->ds->extent.nelem = 0;
- }
+ if((extent=(H5O_SDSPACE->decode)(f,dxpl_id,p,NULL))==NULL)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute dataspace");
+
+ /* Copy the extent information */
+ HDmemcpy(&(attr->ds->extent),extent, sizeof(H5S_extent_t));
+
+ /* Release temporary extent information */
+ H5FL_FREE(H5S_extent_t,extent);
- if(attr->ds->extent.type == H5S_NULL) {
- if(H5S_select_none(attr->ds)<0)
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set none selection");
- } else {
- /* Default to entire dataspace being selected */
- if(H5S_select_all(attr->ds,0)<0)
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
- }
+ /* Default to entire dataspace being selected */
+ if(H5S_select_all(attr->ds,0)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
if(version < H5O_ATTR_VERSION_NEW)
p += H5O_ALIGN(attr->ds_size);