summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5D.c19
-rw-r--r--src/H5T.c64
-rw-r--r--src/H5Tprivate.h1
3 files changed, 74 insertions, 10 deletions
diff --git a/src/H5D.c b/src/H5D.c
index 0ead927..ac63596 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1559,20 +1559,25 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type,
if(NULL == (new_dset = H5D_new(dcpl_id)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- /* Get new dataset's property list object */
- if (NULL == (new_plist = H5I_object(new_dset->dcpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list");
+ /* Check if the datatype is "sensible" for use in a dataset */
+ if(H5T_is_sensible(type)!=TRUE)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible");
- if(H5P_get(new_plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout");
-
/* Copy datatype for dataset */
- new_dset->type = H5T_copy(type, H5T_COPY_ALL);
+ if((new_dset->type = H5T_copy(type, H5T_COPY_ALL))==NULL)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy datatype");
/* Mark any VL datatypes as being on disk now */
if (H5T_vlen_mark(new_dset->type, f, H5T_VLEN_DISK)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location");
+ /* Get new dataset's property list object */
+ if (NULL == (new_plist = H5I_object(new_dset->dcpl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list");
+
+ if(H5P_get(new_plist, H5D_CRT_CHUNK_DIM_NAME, &chunk_ndims) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout");
+
if(H5P_get(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve external file list");
diff --git a/src/H5T.c b/src/H5T.c
index 4a104a4..1e886fc 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -5851,14 +5851,15 @@ H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type)
FUNC_ENTER_NOAPI(H5T_commit, FAIL);
+ assert (loc);
+ assert (name && *name);
+ assert (type);
+
/*
* Check arguments. We cannot commit an immutable type because H5Tclose()
* normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing
* a named type should always succeed.
*/
- assert (loc);
- assert (name && *name);
- assert (type);
if (H5T_STATE_NAMED==type->state || H5T_STATE_OPEN==type->state) {
HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
"data type is already committed");
@@ -5868,6 +5869,10 @@ H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type)
"data type is immutable");
}
+ /* Check for a "sensible" datatype to store on disk */
+ if(H5T_is_sensible(type)!=TRUE)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datatype is not sensible");
+
/* Find the insertion file */
if (NULL==(file=H5G_insertion_file(loc, name))) {
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
@@ -8089,6 +8094,59 @@ H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[])
/*-------------------------------------------------------------------------
+ * Function: H5T_is_sensible
+ *
+ * Purpose: Determines if a data type is sensible to store on disk
+ * (i.e. not partially initialized)
+ *
+ * Return: Success: TRUE, FALSE
+ *
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Tuesday, June 11, 2002
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5T_is_sensible(const H5T_t *dt)
+{
+ htri_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI(H5T_is_sensible, FAIL);
+
+ assert(dt);
+
+ switch(dt->type) {
+ case H5T_COMPOUND:
+ /* Only allow compound datatypes with at least one member to be stored on disk */
+ if(dt->u.compnd.nmembs > 0)
+ ret_value=TRUE;
+ else
+ ret_value=FALSE;
+ break;
+
+ case H5T_ENUM:
+ /* Only allow enum datatypes with at least one member to be stored on disk */
+ if(dt->u.enumer.nmembs > 0)
+ ret_value=TRUE;
+ else
+ ret_value=FALSE;
+ break;
+
+ default:
+ /* Assume all other datatype are sensible to store on disk */
+ ret_value=TRUE;
+ break;
+ } /* end switch */
+
+ FUNC_LEAVE(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5T_print_stats
*
* Purpose: Print statistics about a conversion path. Statistics are
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 23cd9a3..2381b5d 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -133,6 +133,7 @@ __DLL__ herr_t H5T_enum_valueof(H5T_t *dt, const char *name,
void *value/*out*/);
__DLL__ herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t ndim, hssize_t *point, void *_op_data);
__DLL__ htri_t H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc);
+__DLL__ htri_t H5T_is_sensible(const H5T_t *dt);
/* Reference specific functions */
__DLL__ H5R_type_t H5T_get_ref_type(const H5T_t *dt);