summaryrefslogtreecommitdiffstats
path: root/src/H5D.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-06-04 22:27:11 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-06-04 22:27:11 (GMT)
commitb4c5e3e00965f4ba6bd6b865cbde3bd33fcdbe47 (patch)
tree36c4e26a2a7c4ac25c2618c0384171cd1833920f /src/H5D.c
parent412b58f5246e11f88a75aed1c4b4156db1a49272 (diff)
downloadhdf5-b4c5e3e00965f4ba6bd6b865cbde3bd33fcdbe47.zip
hdf5-b4c5e3e00965f4ba6bd6b865cbde3bd33fcdbe47.tar.gz
hdf5-b4c5e3e00965f4ba6bd6b865cbde3bd33fcdbe47.tar.bz2
[svn-r407] ./src/H5A.c
./src/H5D.c ./src/H5Tconv.c ./src/H5detect.c Updated to work with new internal H5T functions. Fixed some data type memory leaks during error recovery. ./src/H5Dprivate.h Added H5D_typeof() similar to H5D_entof() that returns a pointer directly to the dataset's type. This is used by H5Tcopy() when invoked on a dataset (see below). ./src/H5Epublic.h Fixed typos in H5E_BEGIN_TRY and H5E_END_TRY macros. ./src/H5F.c Closing a file with objects still open reports the file name in the warning message. Removed unnecessary invalidation of shared data types. ./src/H5Gent.c ./src/H5Gpkg.h ./src/H5Gprivate.h Added `const' to some arguments. ./src/H5O.c ./src/H5Oprivate.h ./src/H5Oshared.c An object header message can now be a pointer to a message in some other object header. The pointer is to the first message of the appropriate type in the other object header and hard link counts are maintained automatically to prevent dangling pointers. The old global heap method of message sharing is also supported although nothing actually uses it. ./src/H5Oattr.c ./src/H5Ocomp.c ./src/H5Ocont.c ./src/H5Odtype.c ./src/H5Oefl.c ./src/H5Olayout.c ./src/H5Oname.c ./src/H5Osdspace.c ./src/H5Oshare.c ./src/H5Ostab.c Changed the data type for the shared message info struct to H5O_shared_t and added an extra initializer to the class methods struct for the set_share method. ./src/H5Odtype.c Added the ability to share data type messages by pointing to other object headers. ./src/H5T.c ./src/H5Tpkg.h ./src/H5Tprivate.h ./src/H5Tpublic.h Added named data types and changed the functionality of some API functions as follows: * The term `read-only' means that a type handle cannot be modified with functions like H5Tset_*() or H5Tinsert(). * The term `immutable' means the same as `read-only' with the added restriction that H5Tclose() cannot be called for the type. A transient type is made immutable by calling H5Tlock(). * Handles to named types are always read-only. * Handles to predefined types are immutable. * A transient type can be converted to a named type by calling H5Tcommit(). This function will fail if the type is already named or is immutable. * The API function H5Tcommitted() returns an indication of whether a data type has been commited (or is named). If H5Tcommitted() returns TRUE for a data type obtained by calling H5Dget_type() on a dataset, then the dataset is using a shared data type. * H5Topen() returns a handle to a named type. * H5Tcopy() always returns a handle to a modifiable transient type even when invoked on a named type. Also, when invoked on a dataset it returns a modifiable transient type which is a copy of the dataset's data type. * Using a named data type in the call to H5Dcreate() causes the dataset object header to point to the named data type, but using a transient type causes the type to be copied into the dataset's object header. * The data type returned from H5Dget_type() is a named data type or a read-only transient data type depending on whether the dataset points to a named data type. The old behavior, to return a modifiable transient type, is accomplished by overloading H5Tcopy() to operate on datasets (see above). * H5Tshare(), H5Tunshare(), and H5Tis_shared() have been removed from the API. The following features were *not* implemented because they need more discussion: * A named data type can be opened by applying H5Topen() to a dataset in which case the data type is the data type of the dataset (or the data type to which the dataset points if the dataset has a shared data type). * A named data type can have attributes like groups or datasets. * The members of a compound data type can point to named data types. ./src/h5ls.c Reports `Data type' for named data type objects in the file.
Diffstat (limited to 'src/H5D.c')
-rw-r--r--src/H5D.c123
1 files changed, 84 insertions, 39 deletions
diff --git a/src/H5D.c b/src/H5D.c
index ea0eb38..7c8783d 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -393,6 +393,11 @@ H5Dget_space (hid_t dataset_id)
*
* Modifications:
*
+ * Robb Matzke, 1 Jun 1998
+ * If the dataset has a named data type then a handle to the opened data
+ * type is returned. Otherwise the returned data type is read-only. If
+ * atomization of the data type fails then the data type is closed.
+ *
*-------------------------------------------------------------------------
*/
hid_t
@@ -411,20 +416,27 @@ H5Dget_type (hid_t dataset_id)
HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
}
- /* Copy the data type */
- if (NULL==(copied_type=H5T_copy (dataset->type))) {
+ /* Copy the data type and mark it read-only */
+ if (NULL==(copied_type=H5T_copy (dataset->type, H5T_COPY_REOPEN))) {
HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
"unable to copy the data type");
}
-
+ if (H5T_lock (copied_type, FALSE)<0) {
+ H5T_close (copied_type);
+ HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
+ "unable to lock transient data type");
+ }
+
/* Create an atom */
if ((ret_value=H5I_register (H5_DATATYPE, copied_type))<0) {
+ H5T_close (copied_type);
HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
"unable to register data type");
}
FUNC_LEAVE (ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5Dget_create_plist
@@ -758,7 +770,7 @@ H5D_create(H5G_t *loc, const char *name, const H5T_t *type, const H5S_t *space,
/* Initialize the dataset object */
new_dset = H5MM_xcalloc(1, sizeof(H5D_t));
H5F_addr_undef(&(new_dset->ent.header));
- new_dset->type = H5T_copy(type);
+ new_dset->type = H5T_copy(type, H5T_COPY_ALL);
new_dset->space = H5S_copy(space);
new_dset->create_parms = H5P_copy (H5P_DATASET_CREATE, create_parms);
efl = &(new_dset->create_parms->efl);
@@ -781,35 +793,37 @@ H5D_create(H5G_t *loc, const char *name, const H5T_t *type, const H5S_t *space,
"unable to initialize contiguous storage");
}
- /* Don't go through all these checks for scalar dataspaces */
- if(ndims>0) {
- for (i=1; i<ndims; i++) {
- if (max_dim[i]>new_dset->layout.dim[i]) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
- "only the first dimension can be extendible");
- }
- }
- if (efl->nused>0) {
- hsize_t max_points = H5S_get_npoints_max (space);
- hsize_t max_storage = H5O_efl_total_size (efl);
-
- if (H5S_UNLIMITED==max_points) {
- if (H5O_EFL_UNLIMITED!=max_storage) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
- "unlimited data space but finite storage");
- }
- } else if (max_points * H5T_get_size (type) < max_points) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
- "data space * type size overflowed");
- } else if (max_points * H5T_get_size (type) > max_storage) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
- "data space size exceeds external storage size");
- }
- } else if (max_dim[0]>new_dset->layout.dim[0]) {
- HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL,
- "extendible contiguous non-external dataset");
- }
- }
+ /* Don't go through all these checks for scalar dataspaces */
+ if(ndims>0) {
+ for (i=1; i<ndims; i++) {
+ if (max_dim[i]>new_dset->layout.dim[i]) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
+ "only the first dimension can be extendible");
+ }
+ }
+ if (efl->nused>0) {
+ hsize_t max_points = H5S_get_npoints_max (space);
+ hsize_t max_storage = H5O_efl_total_size (efl);
+
+ if (H5S_UNLIMITED==max_points) {
+ if (H5O_EFL_UNLIMITED!=max_storage) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
+ "unlimited data space but finite "
+ "storage");
+ }
+ } else if (max_points * H5T_get_size (type) < max_points) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
+ "data space * type size overflowed");
+ } else if (max_points * H5T_get_size (type) > max_storage) {
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
+ "data space size exceeds external storage "
+ "size");
+ }
+ } else if (max_dim[0]>new_dset->layout.dim[0]) {
+ HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL,
+ "extendible contiguous non-external dataset");
+ }
+ }
break;
case H5D_CHUNKED:
@@ -842,8 +856,7 @@ H5D_create(H5G_t *loc, const char *name, const H5T_t *type, const H5S_t *space,
/* Update the type and space header messages */
if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0,
- (H5O_FLAG_CONSTANT|H5O_FLAG_SHARED),
- new_dset->type) < 0 ||
+ H5O_FLAG_CONSTANT|H5O_FLAG_SHARED, new_dset->type)<0 ||
H5S_modify(&(new_dset->ent), new_dset->space) < 0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
"unable to update type or space header messages");
@@ -1215,8 +1228,10 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
"unable to convert between src and dest data types");
} else if (H5T_conv_noop!=tconv_func) {
- if ((src_id=H5I_register(H5_DATATYPE, H5T_copy(dataset->type)))<0 ||
- (dst_id=H5I_register(H5_DATATYPE, H5T_copy(mem_type)))<0) {
+ if ((src_id=H5I_register(H5_DATATYPE,
+ H5T_copy(dataset->type, H5T_COPY_ALL)))<0 ||
+ (dst_id=H5I_register(H5_DATATYPE,
+ H5T_copy(mem_type, H5T_COPY_ALL)))<0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
"unable to register types for conversion");
}
@@ -1520,8 +1535,10 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
"unable to convert between src and dest data types");
} else if (H5T_conv_noop!=tconv_func) {
- if ((src_id = H5I_register(H5_DATATYPE, H5T_copy(mem_type)))<0 ||
- (dst_id = H5I_register(H5_DATATYPE, H5T_copy(dataset->type)))<0) {
+ if ((src_id = H5I_register(H5_DATATYPE,
+ H5T_copy(mem_type, H5T_COPY_ALL)))<0 ||
+ (dst_id = H5I_register(H5_DATATYPE,
+ H5T_copy(dataset->type, H5T_COPY_ALL)))<0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
"unable to register types for conversion");
}
@@ -1793,3 +1810,31 @@ H5D_entof (H5D_t *dataset)
{
return dataset ? &(dataset->ent) : NULL;
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_typeof
+ *
+ * Purpose: Returns a pointer to the dataset's data type. The data type
+ * is not copied.
+ *
+ * Return: Success: Ptr to the dataset's data type, uncopied.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
+ * Thursday, June 4, 1998
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5D_typeof (H5D_t *dset)
+{
+ FUNC_ENTER (H5D_typeof, NULL);
+ assert (dset);
+ assert (dset->type);
+ FUNC_LEAVE (dset->type);
+}
+