summaryrefslogtreecommitdiffstats
path: root/src/H5D.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-05-31 20:33:19 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-05-31 20:33:19 (GMT)
commit5279ef2f48eeccfd5d282670859d80d3fd782573 (patch)
treec3a01a0f98451ea453f15ff206f00cae44d01d3a /src/H5D.c
parent5aacf74f24c5c63ee25558b6c8be08009d7e245e (diff)
downloadhdf5-5279ef2f48eeccfd5d282670859d80d3fd782573.zip
hdf5-5279ef2f48eeccfd5d282670859d80d3fd782573.tar.gz
hdf5-5279ef2f48eeccfd5d282670859d80d3fd782573.tar.bz2
[svn-r13825] Description:
Incremental step forward in fixing problems with fill values that have a variable-length daattype. This set of changes fixes problems with the copying the property list values. tested Tn: Mac OS X/32 10.4.9 (amazon)
Diffstat (limited to 'src/H5D.c')
-rw-r--r--src/H5D.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/src/H5D.c b/src/H5D.c
index cad1742..5293714 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -90,6 +90,9 @@ H5D_dxpl_cache_t H5D_def_dxpl_cache;
/* Library Private Variables */
/*****************************/
+/* Declare extern the free list to manage blocks of type conversion data */
+H5FL_BLK_EXTERN(type_conv);
+
/*******************/
/* Local Variables */
@@ -869,11 +872,56 @@ H5Dget_create_plist(hid_t dset_id)
if(H5P_get(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value")
- /* Copy the dataset type into the fill value message, if there's actually a fill value */
- if(copied_fill.buf != NULL && copied_fill.type == NULL)
+ /* Check if there is a fill value, but no type yet */
+ if(copied_fill.buf != NULL && copied_fill.type == NULL) {
+ H5T_path_t *tpath; /* Conversion information*/
+
+ /* Copy the dataset type into the fill value message */
if(NULL == (copied_fill.type = H5T_copy(dset->shared->type, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset datatype for fill value")
+ /* Set up type conversion function */
+ if(NULL == (tpath = H5T_path_find(dset->shared->type, copied_fill.type, NULL, NULL, H5AC_ind_dxpl_id, FALSE)))
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types")
+
+ /* Convert disk form of fill value into memory form */
+ if(!H5T_path_noop(tpath)) {
+ hid_t dst_id, src_id; /* Source & destination datatypes for type conversion */
+ uint8_t *bkg_buf = NULL; /* Background conversion buffer */
+ size_t bkg_size; /* Size of background buffer */
+
+ /* Wrap copies of types to convert */
+ dst_id = H5I_register(H5I_DATATYPE, H5T_copy(copied_fill.type, H5T_COPY_TRANSIENT));
+ if(dst_id < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype")
+ src_id = H5I_register(H5I_DATATYPE, H5T_copy(dset->shared->type, H5T_COPY_ALL));
+ if(src_id < 0) {
+ H5I_dec_ref(dst_id);
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype")
+ } /* end if */
+
+ /* Allocate a background buffer */
+ bkg_size = MAX(H5T_get_size(copied_fill.type), H5T_get_size(dset->shared->type));
+ if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /* Convert fill value */
+ if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, copied_fill.buf, bkg_buf, H5AC_ind_dxpl_id) < 0) {
+ H5I_dec_ref(src_id);
+ H5I_dec_ref(dst_id);
+ if(bkg_buf)
+ H5FL_BLK_FREE(type_conv, bkg_buf);
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
+ } /* end if */
+
+ /* Release local resources */
+ H5I_dec_ref(src_id);
+ H5I_dec_ref(dst_id);
+ if(bkg_buf)
+ H5FL_BLK_FREE(type_conv, bkg_buf);
+ } /* end if */
+ } /* end if */
+
/* Set back the fill value property to property list */
if(H5P_set(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property list fill value")
@@ -1384,7 +1432,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id,
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy dataspace")
/* Set the dataset's dataspace to 'all' selection */
- if(H5S_select_all(new_dset->shared->space,1) < 0)
+ if(H5S_select_all(new_dset->shared->space, TRUE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection")
/* Make the "set local" filter callbacks for this dataset */