summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5D.c125
-rw-r--r--src/H5Dio.c84
-rw-r--r--src/H5Dpkg.h1
-rw-r--r--src/H5F.c19
-rw-r--r--src/H5T.c47
-rw-r--r--src/H5Tprivate.h5
-rw-r--r--test/ntypes.c25
7 files changed, 181 insertions, 125 deletions
diff --git a/src/H5D.c b/src/H5D.c
index cd67fee..95145c7 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -58,6 +58,7 @@ static haddr_t H5D_get_offset(const H5D_t *dset);
static herr_t H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id);
static herr_t H5D_set_extent(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id);
static herr_t H5D_close(H5D_t *dataset);
+static herr_t H5D_init_type(H5F_t *file, H5D_t *dset, hid_t type_id, const H5T_t *type);
static int H5D_crt_fill_value_cmp(const void *value1, const void *value2, size_t size);
static int H5D_crt_ext_file_list_cmp(const void *value1, const void *value2, size_t size);
static int H5D_crt_data_pipeline_cmp(const void *value1, const void *value2, size_t size);
@@ -1624,6 +1625,75 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5D_init_type
+ *
+ * Purpose: Copy a datatype for a dataset's use, performing all the
+ * necessary adjustments, etc.
+ *
+ * Return: Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Errors:
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, June 24, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5D_init_type(H5F_t *file, H5D_t *dset, hid_t type_id, const H5T_t *type)
+{
+ htri_t relocatable; /* Flag whether the type is relocatable */
+ htri_t immutable; /* Flag whether the type is immutable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5D_init_type, FAIL)
+
+ /* Sanity checking */
+ assert(file);
+ assert(dset);
+ assert(type);
+
+ /* Check whether the datatype is relocatable */
+ if((relocatable=H5T_is_relocatable(type))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't check datatype?")
+
+ /* Check whether the datatype is immutable */
+ if((immutable=H5T_is_immutable(type))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't check datatype?")
+
+ /* Copy the datatype if it's a custom datatype or if it'll change when it's location is changed */
+ if(!immutable || relocatable) {
+ /* Copy datatype for dataset */
+ if((dset->type = H5T_copy(type, H5T_COPY_ALL))==NULL)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "can't copy datatype")
+
+ /* Mark any datatypes as being on disk now */
+ if(H5T_vlen_mark(dset->type, file, H5T_VLEN_DISK)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
+
+ /* Get a datatype ID for the dataset's datatype */
+ if((dset->type_id = H5I_register(H5I_DATATYPE, dset->type))<0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type")
+ } /* end if */
+ /* Not a custom datatype, just use it directly */
+ else {
+ if(H5I_inc_ref(type_id)<0)
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINC, FAIL, "Can't increment datatype ID")
+
+ /* Use existing datatype */
+ dset->type_id = type_id;
+ dset->type = (H5T_t *)type; /* (Cast away const OK - QAK) */
+ } /* end else */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_init_type() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5D_update_entry_info
*
* Purpose: Create and fill an H5G_entry_t object for insertion into
@@ -1977,13 +2047,9 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to locate insertion point")
/* Copy datatype for dataset */
- if((new_dset->type = H5T_copy(type, H5T_COPY_ALL))==NULL)
+ if(H5D_init_type(file, new_dset, type_id, type)<0)
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, file, H5T_VLEN_DISK)<0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location")
-
/* Copy dataspace for dataset */
if((new_dset->space = H5S_copy(space, FALSE))==NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy dataspace")
@@ -2176,7 +2242,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "compact dataset size is bigger than header message maximum size")
} /* end case */
break;
-
+
default:
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet")
} /* end switch */
@@ -2211,7 +2277,7 @@ done:
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace")
} /* end if */
if (new_dset->type) {
- if(H5T_close(new_dset->type)<0)
+ if(H5I_dec_ref(new_dset->type_id)<0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype")
} /* end if */
if (H5F_addr_defined(new_dset->ent.header)) {
@@ -2410,6 +2476,9 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id)
/* Get the type and space */
if (NULL==(dataset->type=H5O_read(&(dataset->ent), H5O_DTYPE_ID, 0, NULL, dxpl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load type info from dataset header")
+ /* Get a datatype ID for the dataset's datatype */
+ if((dataset->type_id = H5I_register(H5I_DATATYPE, dataset->type))<0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, NULL, "unable to register type")
if (NULL==(dataset->space=H5S_read(&(dataset->ent),dxpl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load space info from dataset header")
@@ -2590,7 +2659,7 @@ done:
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace")
} /* end if */
if (dataset->type) {
- if(H5T_close(dataset->type)<0)
+ if(H5I_dec_ref(dataset->type_id)<0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype")
} /* end if */
dataset->ent.file = NULL;
@@ -2677,7 +2746,7 @@ H5D_close(H5D_t *dataset)
* Release datatype, dataspace and creation property list -- there isn't
* much we can do if one of these fails, so we just continue.
*/
- free_failed=(H5T_close(dataset->type)<0 || H5S_close(dataset->space)<0 ||
+ free_failed=(H5I_dec_ref(dataset->type_id)<0 || H5S_close(dataset->space)<0 ||
H5I_dec_ref(dataset->dcpl_id) < 0);
/* Remove the dataset from the list of opened objects in the file */
@@ -2744,54 +2813,38 @@ H5D_extend (H5D_t *dataset, const hsize_t *size, hid_t dxpl_id)
assert (dataset);
assert (size);
- /*
- * NOTE: Restrictions on extensions were checked when the dataset was
- * created. All extensions are allowed here since none should be
- * able to muck things up.
+ /* Check if the filters in the DCPL will need to encode, and if so, can they?
+ * Filters need encoding if fill value is defined and a fill policy is set that requires
+ * writing on an extend.
*/
-
if(! dataset->checked_filters)
{
- /* Check if the filters in the DCPL will need to encode, and if so, can they?
- * Filters need encoding if fill value is defined and a fill policy is set that requires
- * writing on an extend.
- */
if(H5P_is_fill_value_defined(&(dataset->fill), &fill_status) < 0)
- {
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill value from dataset.");
- }
if(fill_status == H5D_FILL_VALUE_DEFAULT || fill_status == H5D_FILL_VALUE_USER_DEFINED)
{
if( H5Pget_fill_time(dataset->dcpl_id, &fill_time) < 0)
- {
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Couldn't retrieve fill time from dataset.");
- }
if(fill_time == H5D_FILL_TIME_ALLOC ||
(fill_time == H5D_FILL_TIME_IFSET && fill_status == H5D_FILL_VALUE_USER_DEFINED) )
{
/* Filters must have encoding enabled. Ensure that all filters can be applied */
- hid_t type_id;
-
- type_id = H5I_register(H5I_DATATYPE, dataset->type);
- if(type_id < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type")
-
- if(H5Z_can_apply(dataset->dcpl_id, type_id) <0)
- {
- H5I_remove(type_id);
+ if(H5Z_can_apply(dataset->dcpl_id, dataset->type_id) <0)
HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters")
- }
- if(H5I_remove(type_id) == NULL)
- HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to release data type id")
-
- dataset->checked_filters = TRUE;
+ dataset->checked_filters = TRUE;
}
}
}
+ /*
+ * NOTE: Restrictions on extensions were checked when the dataset was
+ * created. All extensions are allowed here since none should be
+ * able to muck things up.
+ */
+
/* Increase the size of the data space */
space=dataset->space;
if ((changed=H5S_extend (space, size))<0)
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 2fd4a65..a684329 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -75,10 +75,10 @@ static int interface_initialize_g = 0;
#define INTERFACE_INIT NULL
/* Local functions */
-static herr_t H5D_read(H5D_t *dataset, const H5T_t *mem_type,
+static herr_t H5D_read(H5D_t *dataset, hid_t mem_type_id,
const H5S_t *mem_space, const H5S_t *file_space,
hid_t dset_xfer_plist, void *buf/*out*/);
-static herr_t H5D_write(H5D_t *dataset, const H5T_t *mem_type,
+static herr_t H5D_write(H5D_t *dataset, hid_t mem_type_id,
const H5S_t *mem_space, const H5S_t *file_space,
hid_t dset_xfer_plist, const void *buf);
static herr_t
@@ -445,7 +445,6 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf/*out*/)
{
H5D_t *dset = NULL;
- const H5T_t *mem_type = NULL;
const H5S_t *mem_space = NULL;
const H5S_t *file_space = NULL;
herr_t ret_value=SUCCEED; /* Return value */
@@ -459,8 +458,6 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if (NULL == dset->ent.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
- if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
if (H5S_ALL != mem_space_id) {
if (NULL == (mem_space = H5I_object_verify(mem_space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
@@ -488,7 +485,7 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer")
/* read raw data */
- if (H5D_read(dset, mem_type, mem_space, file_space, plist_id, buf/*out*/) < 0)
+ if (H5D_read(dset, mem_type_id, mem_space, file_space, plist_id, buf/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
done:
@@ -536,7 +533,6 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, const void *buf)
{
H5D_t *dset = NULL;
- const H5T_t *mem_type = NULL;
const H5S_t *mem_space = NULL;
const H5S_t *file_space = NULL;
herr_t ret_value=SUCCEED; /* Return value */
@@ -550,8 +546,6 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if (NULL == dset->ent.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
- if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
if (H5S_ALL != mem_space_id) {
if (NULL == (mem_space = H5I_object_verify(mem_space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
@@ -579,7 +573,7 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer")
/* write raw data */
- if (H5D_write(dset, mem_type, mem_space, file_space, plist_id, buf) < 0)
+ if (H5D_write(dset, mem_type_id, mem_space, file_space, plist_id, buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")
done:
@@ -635,13 +629,13 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
+H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
const H5S_t *file_space, hid_t dxpl_id, void *buf/*out*/)
{
hssize_t snelmts; /*total number of elmts (signed) */
hsize_t nelmts; /*total number of elmts */
H5T_path_t *tpath = NULL; /*type conversion info */
- hid_t src_id = -1, dst_id = -1;/*temporary type atoms */
+ const H5T_t *mem_type = NULL; /* Memory datatype */
H5S_conv_t *sconv=NULL; /*space conversion funcs*/
hbool_t use_par_opt_io=FALSE; /* Whether the 'optimized' I/O routines with be parallel */
#ifdef H5_HAVE_PARALLEL
@@ -656,9 +650,12 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
/* check args */
assert(dataset && dataset->ent.file);
- assert(mem_type);
assert(buf);
+ /* Get memory datatype */
+ if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
+
if (!file_space)
file_space = dataset->space;
if (!mem_space)
@@ -728,13 +725,8 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
* enough value in xfer_parms since turning off data type conversion also
* turns off background preservation.
*/
- if (NULL==(tpath=H5T_path_find(dataset->type, mem_type, NULL, NULL, dxpl_id))) {
+ if (NULL==(tpath=H5T_path_find(dataset->type, mem_type, NULL, NULL, dxpl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types")
- } else if (!H5T_path_noop(tpath)) {
- if ((src_id=H5I_register(H5I_DATATYPE, H5T_copy(dataset->type, H5T_COPY_ALL)))<0 ||
- (dst_id=H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion")
- } /* end if */
/* Set the storage flags for the space conversion check */
switch(dataset->layout.type) {
@@ -767,12 +759,12 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
/* Determine correct I/O routine to invoke */
if(dataset->layout.type!=H5D_CHUNKED) {
if(H5D_contig_read(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv,
- dxpl_cache, dxpl_id, src_id, dst_id, buf)<0)
+ dxpl_cache, dxpl_id, dataset->type_id, mem_type_id, buf)<0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
} /* end if */
else {
if(H5D_chunk_read(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv,
- dxpl_cache, dxpl_id, src_id, dst_id, buf)<0)
+ dxpl_cache, dxpl_id, dataset->type_id, mem_type_id, buf)<0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
} /* end else */
@@ -782,14 +774,6 @@ done:
if (xfer_mode_changed)
H5D_io_restore_mpio(dxpl_id);
#endif /*H5_HAVE_PARALLEL*/
- if (src_id >= 0) {
- if(H5I_dec_ref(src_id)<0)
- HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
- } /* end if */
- if (dst_id >= 0) {
- if(H5I_dec_ref(dst_id)<0)
- HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
- } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_read() */
@@ -843,13 +827,13 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
+H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
const H5S_t *file_space, hid_t dxpl_id, const void *buf)
{
hssize_t snelmts; /*total number of elmts (signed) */
hsize_t nelmts; /*total number of elmts */
H5T_path_t *tpath = NULL; /*type conversion info */
- hid_t src_id = -1, dst_id = -1;/*temporary type atoms */
+ const H5T_t *mem_type = NULL; /* Memory datatype */
H5S_conv_t *sconv=NULL; /*space conversion funcs*/
hbool_t use_par_opt_io=FALSE; /* Whether the 'optimized' I/O routines with be parallel */
#ifdef H5_HAVE_PARALLEL
@@ -864,26 +848,17 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
/* check args */
assert(dataset && dataset->ent.file);
- assert(mem_type);
assert(buf);
+ /* Get the memory datatype */
+ if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
+
/* All filters in the DCPL must have encoding enabled. */
if(! dataset->checked_filters)
{
- hid_t type_id;
-
- type_id = H5I_register(H5I_DATATYPE, dataset->type);
- if(type_id < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type")
-
- if(H5Z_can_apply(dataset->dcpl_id, type_id) <0)
- {
- H5I_remove(type_id);
+ if(H5Z_can_apply(dataset->dcpl_id, dataset->type_id) <0)
HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "can't apply filters")
- }
-
- if(H5I_remove(type_id) == NULL)
- HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to release data type id")
dataset->checked_filters = TRUE;
}
@@ -968,13 +943,8 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
* enough value in xfer_parms since turning off data type conversion also
* turns off background preservation.
*/
- if (NULL==(tpath=H5T_path_find(mem_type, dataset->type, NULL, NULL, dxpl_id))) {
+ if (NULL==(tpath=H5T_path_find(mem_type, dataset->type, NULL, NULL, dxpl_id)))
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types")
- } else if (!H5T_path_noop(tpath)) {
- if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(mem_type, H5T_COPY_ALL)))<0 ||
- (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dataset->type, H5T_COPY_ALL)))<0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion")
- } /* end if */
/* Set the storage flags for the space conversion check */
switch(dataset->layout.type) {
@@ -1007,12 +977,12 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
/* Determine correct I/O routine to invoke */
if(dataset->layout.type!=H5D_CHUNKED) {
if(H5D_contig_write(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv,
- dxpl_cache, dxpl_id, src_id, dst_id, buf)<0)
+ dxpl_cache, dxpl_id, mem_type_id, dataset->type_id, buf)<0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")
} /* end if */
else {
if(H5D_chunk_write(nelmts, dataset, mem_type, mem_space, file_space, tpath, sconv,
- dxpl_cache, dxpl_id, src_id, dst_id, buf)<0)
+ dxpl_cache, dxpl_id, mem_type_id, dataset->type_id, buf)<0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")
} /* end else */
@@ -1037,14 +1007,6 @@ done:
if (xfer_mode_changed)
H5D_io_restore_mpio(dxpl_id);
#endif /*H5_HAVE_PARALLEL*/
- if (src_id >= 0) {
- if(H5I_dec_ref(src_id)<0)
- HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
- } /* end if */
- if (dst_id >= 0) {
- if(H5I_dec_ref(dst_id)<0)
- HDONE_ERROR (H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
- } /* end if */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_write() */
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index 18af011..e1d4b71 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -78,6 +78,7 @@ typedef struct H5D_rdcdc_t {
*/
struct H5D_t {
H5G_entry_t ent; /* cached object header stuff */
+ hid_t type_id; /* ID for dataset's datatype */
H5T_t *type; /* datatype of this dataset */
H5S_t *space; /* dataspace of this dataset */
hid_t dcpl_id; /* dataset creation property id */
diff --git a/src/H5F.c b/src/H5F.c
index e385d69..33e89bc 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -12,14 +12,6 @@
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*****************************************************************************
- * *
- * MODIFICATIONS *
- * Robb Matzke, 30 Aug 1997 *
- * Added `ERRORS' fields to function prologues. *
- * *
- ****************************************************************************/
-
#define H5F_PACKAGE /*suppress error about including H5Fpkg */
/* Pablo information */
@@ -2222,7 +2214,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d
if(fc_degree!=H5F_CLOSE_DEFAULT && fc_degree != shared->fc_degree)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match")
}
-
+
/* Success */
ret_value = file;
@@ -2230,6 +2222,7 @@ done:
if (!ret_value && file)
if(H5F_dest(file, dxpl_id)<0)
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file")
+
FUNC_LEAVE_NOAPI(ret_value)
}
@@ -4692,16 +4685,16 @@ H5Fget_filesize(hid_t file_id)
H5F_t *file=NULL; /* File object for file ID */
haddr_t ret_value; /* Return value */
- FUNC_ENTER_API(H5Fget_filesize, FAIL)
+ FUNC_ENTER_API(H5Fget_filesize, HADDR_UNDEF)
H5TRACE1("a","i",file_id);
/* Check args */
if(NULL==(file=H5I_object_verify(file_id, H5I_FILE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "not a file ID")
/* Go get the actual file size */
- if((ret_value = H5FDget_eof(file->shared->lf))<0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size")
+ if((ret_value = H5FDget_eof(file->shared->lf))==HADDR_UNDEF)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTGET, HADDR_UNDEF, "unable to get file size")
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5T.c b/src/H5T.c
index a7ddab6..dcbad77 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -2891,12 +2891,14 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
case H5T_COPY_REOPEN:
/*
* Return a transient type (locked or unlocked) or an opened named
- * type.
+ * type. Immutable transient types are degraded to read-only.
*/
if (H5F_addr_defined(new_dt->ent.header)) {
if (H5O_open (&(new_dt->ent))<0)
HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type");
new_dt->state = H5T_STATE_OPEN;
+ } else if (H5T_STATE_IMMUTABLE==new_dt->state) {
+ new_dt->state = H5T_STATE_RDONLY;
}
break;
} /* end switch */
@@ -4249,7 +4251,7 @@ done:
*-------------------------------------------------------------------------
*/
htri_t
-H5T_is_immutable(H5T_t *dt)
+H5T_is_immutable(const H5T_t *dt)
{
htri_t ret_value = FALSE;
@@ -4282,7 +4284,7 @@ done:
*-------------------------------------------------------------------------
*/
htri_t
-H5T_is_named(H5T_t *dt)
+H5T_is_named(const H5T_t *dt)
{
htri_t ret_value = FALSE;
@@ -4390,6 +4392,45 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5T_is_relocatable
+ *
+ * Purpose: Check if a datatype will change between disk and memory.
+ *
+ * Notes: Currently, only variable-length and object references change
+ * between disk & memory (see cases where things are changed in
+ * the H5T_set_loc() code above).
+ *
+ * Return:
+ * One of two values on success:
+ * TRUE - If the location of any vlen types changed
+ * FALSE - If the location of any vlen types is the same
+ * <0 is returned on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, June 24, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+htri_t
+H5T_is_relocatable(const H5T_t *dt)
+{
+ htri_t ret_value = FALSE;
+
+ FUNC_ENTER_NOAPI(H5T_is_relocatable, FAIL);
+
+ assert(dt);
+
+ if(H5T_detect_class(dt, H5T_VLEN))
+ ret_value = TRUE;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+} /* end H5T_is_relocatable() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5T_print_stats
*
* Purpose: Print statistics about a conversion path. Statistics are
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 69656ad..48958d8 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -71,8 +71,9 @@ H5_DLL size_t H5T_get_size(const H5T_t *dt);
H5_DLL int H5T_cmp(const H5T_t *dt1, const H5T_t *dt2);
H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE * stream);
H5_DLL H5G_entry_t *H5T_entof(H5T_t *dt);
-H5_DLL htri_t H5T_is_immutable(H5T_t *dt);
-H5_DLL htri_t H5T_is_named(H5T_t *dt);
+H5_DLL htri_t H5T_is_immutable(const H5T_t *dt);
+H5_DLL htri_t H5T_is_named(const H5T_t *dt);
+H5_DLL htri_t H5T_is_relocatable(const H5T_t *dt);
H5_DLL H5T_path_t *H5T_path_find(const H5T_t *src, const H5T_t *dst,
const char *name, H5T_conv_t func, hid_t dxpl_id);
H5_DLL hbool_t H5T_path_noop(const H5T_path_t *p);
diff --git a/test/ntypes.c b/test/ntypes.c
index f4d3337..d23358d 100644
--- a/test/ntypes.c
+++ b/test/ntypes.c
@@ -137,7 +137,7 @@ test_atomic_dtype(hid_t file)
free(tmp);
/* Convert to the integer type */
- if(H5Tconvert(native_type, H5T_NATIVE_INT, (hsize_t)(DIM0*DIM1), icheck2, NULL, H5P_DEFAULT)<0)
+ if(H5Tconvert(native_type, H5T_NATIVE_INT, (DIM0*DIM1), icheck2, NULL, H5P_DEFAULT)<0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
@@ -152,8 +152,9 @@ test_atomic_dtype(hid_t file)
}
}
- H5Dclose(dataset);
- H5Tclose(dtype);
+ if(H5Dclose(dataset)<0) TEST_ERROR;
+ if(H5Tclose(native_type)<0) TEST_ERROR;
+ if(H5Tclose(dtype)<0) TEST_ERROR;
/*------------------ Test different data types ----------------*/
@@ -175,6 +176,7 @@ test_atomic_dtype(hid_t file)
TEST_ERROR;
if(H5Dclose(dataset)<0) TEST_ERROR;
+ if(H5Tclose(native_type)<0) TEST_ERROR;
if(H5Tclose(dtype)<0) TEST_ERROR;
@@ -196,6 +198,7 @@ test_atomic_dtype(hid_t file)
TEST_ERROR;
if(H5Dclose(dataset)<0) TEST_ERROR;
+ if(H5Tclose(native_type)<0) TEST_ERROR;
if(H5Tclose(dtype)<0) TEST_ERROR;
@@ -217,6 +220,7 @@ test_atomic_dtype(hid_t file)
TEST_ERROR;
if(H5Dclose(dataset)<0) TEST_ERROR;
+ if(H5Tclose(native_type)<0) TEST_ERROR;
if(H5Tclose(dtype)<0) TEST_ERROR;
@@ -238,6 +242,7 @@ test_atomic_dtype(hid_t file)
TEST_ERROR;
if(H5Dclose(dataset)<0) TEST_ERROR;
+ if(H5Tclose(native_type)<0) TEST_ERROR;
if(H5Tclose(dtype)<0) TEST_ERROR;
@@ -456,7 +461,7 @@ test_compound_dtype2(hid_t file)
memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
free(tmp);
- if (H5Tconvert(native_type, tid_m, (hsize_t)(DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if (H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
TEST_ERROR;
free(bkg);
@@ -638,7 +643,7 @@ test_compound_dtype(hid_t file)
memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
free(tmp);
- if (H5Tconvert(native_type, tid2, (hsize_t)(DIM0*DIM1), check, bkg, H5P_DEFAULT)<0)
+ if (H5Tconvert(native_type, tid2, (DIM0*DIM1), check, bkg, H5P_DEFAULT)<0)
TEST_ERROR;
free(bkg);
@@ -832,7 +837,7 @@ test_compound_dtype3(hid_t file)
memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
free(tmp);
- if (H5Tconvert(native_type, tid_m, (hsize_t)(DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if (H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
TEST_ERROR;
free(bkg);
@@ -1022,7 +1027,7 @@ test_compound_opaque(hid_t file)
HDmemcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
HDfree(tmp);
- if (H5Tconvert(native_type, tid_m, (hsize_t)(DIM0*DIM1), check, bkg, H5P_DEFAULT))
+ if (H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, bkg, H5P_DEFAULT))
TEST_ERROR;
HDfree(bkg);
@@ -1166,7 +1171,7 @@ test_enum_dtype(hid_t file)
memcpy(scheck2, tmp, DIM0*DIM1*H5Tget_size(native_type));
free(tmp);
- if (H5Tconvert(native_type, tid_m, (hsize_t)(DIM0*DIM1), scheck2, NULL, H5P_DEFAULT)<0)
+ if (H5Tconvert(native_type, tid_m, (DIM0*DIM1), scheck2, NULL, H5P_DEFAULT)<0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
@@ -1305,7 +1310,7 @@ test_array_dtype(hid_t file)
memcpy(check, tmp, DIM0*DIM1*H5Tget_size(native_type));
free(tmp);
- if (H5Tconvert(native_type, tid_m, (hsize_t)(DIM0*DIM1), check, NULL, H5P_DEFAULT)<0)
+ if (H5Tconvert(native_type, tid_m, (DIM0*DIM1), check, NULL, H5P_DEFAULT)<0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
@@ -1427,7 +1432,7 @@ test_array_dtype2(hid_t file)
memcpy(icheck3, tmp, DIM0*DIM1*H5Tget_size(native_type));
free(tmp);
- if (H5Tconvert(native_type, tid_m, (hsize_t)(DIM0*DIM1), icheck3, NULL, H5P_DEFAULT)<0)
+ if (H5Tconvert(native_type, tid_m, (DIM0*DIM1), icheck3, NULL, H5P_DEFAULT)<0)
TEST_ERROR;
/* Check that the values read are the same as the values written */