summaryrefslogtreecommitdiffstats
path: root/src/H5Toffset.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2004-09-28 19:04:19 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2004-09-28 19:04:19 (GMT)
commit5c0011a71384223791d18028968382db43f08a6f (patch)
tree113cc1dd6c8d0ecd1996ddb8f0e9f7693f470e95 /src/H5Toffset.c
parenta841ea35292de8097b429f98af48b29f21c97893 (diff)
downloadhdf5-5c0011a71384223791d18028968382db43f08a6f.zip
hdf5-5c0011a71384223791d18028968382db43f08a6f.tar.gz
hdf5-5c0011a71384223791d18028968382db43f08a6f.tar.bz2
[svn-r9329]
Purpose: Feature Description: Datatypes and groups now use H5FO "file object" code that was previously only used by datasets. These objects will hold a file open if the file is closed but they have not yet been closed. If these objects are unlinked then relinked, they will not be destroyed. If they are opened twice (even by two different names), both IDs will "see" changes made to the object using the other ID. When an object is opened using two different names (e.g., if a dataset was opened under one name, then mounted and opened under its new name), calling H5Iget_name() on a given hid_t will return the name used to open that hid_t, not the current name of the object (this is a feature, and a change from the previous behavior of datasets). Solution: Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's, and H5G_t's into a "shared" struct and a private struct. The shared structs (H5D_shared_t, etc.) hold the object's information and are used by all IDs that point to a given object in the file. The private structs are pointed to by the hid_t and contain the object's group entry information (including its name) and a pointer to the shared struct for that object. This changed the naming of structs throughout the library (e.g., datatype->size is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip. Platforms tested: Visual Studio 7, sleipnir, arabica, verbena Misc. update:
Diffstat (limited to 'src/H5Toffset.c')
-rw-r--r--src/H5Toffset.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/H5Toffset.c b/src/H5Toffset.c
index 850737c..943415e 100644
--- a/src/H5Toffset.c
+++ b/src/H5Toffset.c
@@ -103,13 +103,13 @@ H5Tget_offset(hid_t type_id)
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type")
- while (dt->parent)
- dt = dt->parent; /*defer to parent*/
- if (!H5T_IS_ATOMIC(dt))
+ while (dt->shared->parent)
+ dt = dt->shared->parent; /*defer to parent*/
+ if (!H5T_IS_ATOMIC(dt->shared))
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for specified data type")
/* Offset */
- ret_value = (int)dt->u.atomic.offset;
+ ret_value = (int)dt->shared->u.atomic.offset;
done:
FUNC_LEAVE_API(ret_value)
@@ -167,13 +167,13 @@ H5Tset_offset(hid_t type_id, size_t offset)
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type")
- if (H5T_STATE_TRANSIENT!=dt->state)
+ if (H5T_STATE_TRANSIENT!=dt->shared->state)
HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only")
- if (H5T_STRING == dt->type && offset != 0)
+ if (H5T_STRING == dt->shared->type && offset != 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset must be zero for this type")
- if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0)
+ if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined")
- if (H5T_COMPOUND==dt->type || H5T_REFERENCE==dt->type || H5T_OPAQUE==dt->type)
+ if (H5T_COMPOUND==dt->shared->type || H5T_REFERENCE==dt->shared->type || H5T_OPAQUE==dt->shared->type)
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "operation not defined for this datatype")
/* Do the real work */
@@ -233,25 +233,25 @@ H5T_set_offset(H5T_t *dt, size_t offset)
/* Check args */
assert(dt);
- assert(H5T_STRING!=dt->type || 0==offset);
- assert(H5T_REFERENCE!=dt->type);
- assert(H5T_OPAQUE!=dt->type);
- assert(H5T_COMPOUND!=dt->type);
- assert(!(H5T_ENUM==dt->type && 0==dt->u.enumer.nmembs));
+ assert(H5T_STRING!=dt->shared->type || 0==offset);
+ assert(H5T_REFERENCE!=dt->shared->type);
+ assert(H5T_OPAQUE!=dt->shared->type);
+ assert(H5T_COMPOUND!=dt->shared->type);
+ assert(!(H5T_ENUM==dt->shared->type && 0==dt->shared->u.enumer.nmembs));
- if (dt->parent) {
- if (H5T_set_offset(dt->parent, offset)<0)
+ if (dt->shared->parent) {
+ if (H5T_set_offset(dt->shared->parent, offset)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset for base type")
/* Adjust size of datatype appropriately */
- if(dt->type==H5T_ARRAY)
- dt->size = dt->parent->size * dt->u.array.nelem;
- else if(dt->type!=H5T_VLEN)
- dt->size = dt->parent->size;
+ if(dt->shared->type==H5T_ARRAY)
+ dt->shared->size = dt->shared->parent->shared->size * dt->shared->u.array.nelem;
+ else if(dt->shared->type!=H5T_VLEN)
+ dt->shared->size = dt->shared->parent->shared->size;
} else {
- if (offset+dt->u.atomic.prec > 8*dt->size)
- dt->size = (offset + dt->u.atomic.prec + 7) / 8;
- dt->u.atomic.offset = offset;
+ if (offset+dt->shared->u.atomic.prec > 8*dt->shared->size)
+ dt->shared->size = (offset + dt->shared->u.atomic.prec + 7) / 8;
+ dt->shared->u.atomic.offset = offset;
}
done: