mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-27 02:10:55 +08:00
[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)
This commit is contained in:
parent
5aacf74f24
commit
5279ef2f48
54
src/H5D.c
54
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 */
|
||||
|
22
src/H5Dio.c
22
src/H5Dio.c
@ -269,16 +269,24 @@ H5D_fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_t
|
||||
/* Get the number of elements */
|
||||
nelmts = H5S_get_simple_extent_npoints(space);
|
||||
|
||||
/* Allocate a temporary buffer and background buffer */
|
||||
if(NULL == (tmp_buf = H5FL_BLK_MALLOC(type_conv, (size_t)nelmts * buf_size)) || NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)nelmts * buf_size)))
|
||||
/* Allocate a temporary buffer */
|
||||
if(NULL == (tmp_buf = H5FL_BLK_MALLOC(type_conv, (size_t)nelmts * buf_size)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
|
||||
|
||||
/* XXX: Should replicate the fill value into the temp. buffer elements, then
|
||||
* type convert the temp. buffer, then scatter the temp. buffer elements
|
||||
* to the user's buffer. - QAK, 2007/05/31
|
||||
*/
|
||||
/* Fill the selection in the temporary buffer */
|
||||
if(H5S_select_fill(tconv_buf, src_type_size, space, tmp_buf) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed")
|
||||
|
||||
/* Convert disk buffer into memory buffer */
|
||||
if(!H5T_path_noop(tpath)) {
|
||||
/* Allocate a background buffer */
|
||||
if(NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)nelmts * buf_size)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
|
||||
|
||||
if(H5T_convert(tpath, src_id, dst_id, (size_t)nelmts, (size_t)0, (size_t)0, tmp_buf, bkg_buf, dxpl_id) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
|
||||
} /* end if */
|
||||
@ -286,13 +294,13 @@ H5D_fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_t
|
||||
/* Copy the final data into the memory buffer */
|
||||
HDmemcpy(buf, tmp_buf, (size_t)nelmts * dst_type_size);
|
||||
} else {
|
||||
/* If there's no VL type of data, do conversion first then fill the data into
|
||||
* the memory buffer. */
|
||||
if(NULL == (bkg_buf = H5FL_BLK_CALLOC(type_elem, buf_size)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
|
||||
|
||||
/* Convert disk buffer into memory buffer */
|
||||
if(!H5T_path_noop(tpath)) {
|
||||
/* If there's no VL type of data, do conversion first then fill the data into
|
||||
* the memory buffer. */
|
||||
if(NULL == (bkg_buf = H5FL_BLK_CALLOC(type_elem, buf_size)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
|
||||
|
||||
/* Perform datatype conversion */
|
||||
if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, tconv_buf, bkg_buf, dxpl_id) < 0)
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
|
||||
|
@ -3403,7 +3403,7 @@ H5D_istore_initialize_by_extent(H5D_io_info_t *io_info)
|
||||
if(NULL == (chunk = H5D_istore_lock(io_info, NULL, FALSE, &idx_hint)))
|
||||
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to read raw data chunk")
|
||||
|
||||
if(H5S_select_all(space_chunk, 1) < 0)
|
||||
if(H5S_select_all(space_chunk, TRUE) < 0)
|
||||
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to select space")
|
||||
|
||||
for(u = 0; u < rank; u++)
|
||||
|
@ -221,7 +221,7 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, unsigned UNUSED mesg_flags,
|
||||
H5FL_FREE(H5S_extent_t, extent);
|
||||
|
||||
/* Default to entire dataspace being selected */
|
||||
if(H5S_select_all(attr->ds, 0) < 0)
|
||||
if(H5S_select_all(attr->ds, FALSE) < 0)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection")
|
||||
|
||||
if(version < H5O_ATTR_VERSION_2)
|
||||
|
@ -23,12 +23,14 @@
|
||||
#define H5O_PACKAGE /*suppress error about including H5Opkg */
|
||||
|
||||
#include "H5private.h" /* Generic Functions */
|
||||
#include "H5Dprivate.h" /* Datasets */
|
||||
#include "H5Eprivate.h" /* Error handling */
|
||||
#include "H5FLprivate.h" /* Free Lists */
|
||||
#include "H5Iprivate.h" /* IDs */
|
||||
#include "H5MMprivate.h" /* Memory management */
|
||||
#include "H5Opkg.h" /* Object headers */
|
||||
#include "H5Pprivate.h" /* Property lists */
|
||||
#include "H5Sprivate.h" /* Dataspaces */
|
||||
|
||||
|
||||
static void *H5O_fill_old_decode(H5F_t *f, hid_t dxpl_id, unsigned mesg_flags, const uint8_t *p);
|
||||
@ -659,19 +661,53 @@ H5O_fill_old_size(const H5F_t UNUSED *f, const void *_mesg)
|
||||
herr_t
|
||||
H5O_fill_reset_dyn(H5O_fill_t *fill)
|
||||
{
|
||||
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_reset_dyn)
|
||||
hid_t fill_type_id = -1; /* Datatype ID for fill value datatype when reclaiming VL fill values */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5O_fill_reset_dyn, FAIL)
|
||||
|
||||
HDassert(fill);
|
||||
|
||||
if(fill->buf)
|
||||
if(fill->buf) {
|
||||
if(fill->type && H5T_detect_class(fill->type, H5T_VLEN) > 0) {
|
||||
H5T_t *fill_type; /* Copy of fill value datatype */
|
||||
H5S_t *fill_space; /* Scalar dataspace for fill value element */
|
||||
|
||||
/* Copy the fill value datatype and get an ID for it */
|
||||
if(NULL == (fill_type = H5T_copy(fill->type, H5T_COPY_TRANSIENT)))
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy fill value datatype")
|
||||
if((fill_type_id = H5I_register(H5I_DATATYPE, fill_type)) < 0) {
|
||||
H5T_close(fill_type);
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register fill value datatype")
|
||||
} /* end if */
|
||||
|
||||
/* Create a scalar dataspace for the fill value element */
|
||||
if(NULL == (fill_space = H5S_create(H5S_SCALAR)))
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create scalar dataspace")
|
||||
|
||||
/* Reclaim any variable length components of the fill value */
|
||||
if(H5D_vlen_reclaim(fill_type_id, fill_space, H5P_DATASET_XFER_DEFAULT, fill->buf) < 0) {
|
||||
H5S_close(fill_space);
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length fill value data")
|
||||
} /* end if */
|
||||
|
||||
/* Release the scalar fill value dataspace */
|
||||
H5S_close(fill_space);
|
||||
} /* end if */
|
||||
|
||||
/* Release the fill value buffer now */
|
||||
fill->buf = H5MM_xfree(fill->buf);
|
||||
} /* end if */
|
||||
fill->size = 0;
|
||||
if(fill->type) {
|
||||
H5T_close(fill->type);
|
||||
fill->type = NULL;
|
||||
} /* end if */
|
||||
|
||||
FUNC_LEAVE_NOAPI(SUCCEED)
|
||||
done:
|
||||
if(fill_type_id > 0)
|
||||
H5I_dec_ref(fill_type_id);
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O_fill_reset_dyn() */
|
||||
|
||||
|
||||
|
@ -126,6 +126,9 @@ const H5P_libclass_t H5P_CLS_DCRT[1] = {{
|
||||
/* Library Private Variables */
|
||||
/*****************************/
|
||||
|
||||
/* Declare extern the free list to manage blocks of type conversion data */
|
||||
H5FL_BLK_EXTERN(type_conv);
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -2022,7 +2025,8 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value)
|
||||
H5O_fill_reset_dyn(&fill);
|
||||
|
||||
if(value) {
|
||||
H5T_t *type; /* Datatype for fill value */
|
||||
H5T_t *type; /* Datatype for fill value */
|
||||
H5T_path_t *tpath; /* Conversion information */
|
||||
|
||||
/* Retrieve pointer to datatype */
|
||||
if(NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE)))
|
||||
@ -2035,6 +2039,30 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value)
|
||||
if(NULL == (fill.buf = H5MM_malloc((size_t)fill.size)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for fill value")
|
||||
HDmemcpy(fill.buf, value, (size_t)fill.size);
|
||||
|
||||
/* Set up type conversion function */
|
||||
if(NULL == (tpath = H5T_path_find(type, type, NULL, NULL, H5AC_ind_dxpl_id, FALSE)))
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types")
|
||||
|
||||
/* If necessary, convert fill value datatypes (which copies VL components, etc.) */
|
||||
if(!H5T_path_noop(tpath)) {
|
||||
uint8_t *bkg_buf = NULL; /* Background conversion buffer */
|
||||
|
||||
/* Allocate a background buffer */
|
||||
if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)fill.size)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
|
||||
|
||||
/* Convert the fill value */
|
||||
if(H5T_convert(tpath, type_id, type_id, (size_t)1, (size_t)0, (size_t)0, fill.buf, bkg_buf, H5AC_ind_dxpl_id) < 0) {
|
||||
if(bkg_buf)
|
||||
H5FL_BLK_FREE(type_conv, bkg_buf);
|
||||
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
|
||||
} /* end if */
|
||||
|
||||
/* Release the background buffer */
|
||||
if(bkg_buf)
|
||||
H5FL_BLK_FREE(type_conv, bkg_buf);
|
||||
} /* end if */
|
||||
} /* end if */
|
||||
else
|
||||
fill.size = (-1);
|
||||
|
11
src/H5S.c
11
src/H5S.c
@ -38,7 +38,6 @@
|
||||
#define H5S_ENCODE_VERSION 0
|
||||
|
||||
/* Local static function prototypes */
|
||||
static H5S_t * H5S_create(H5S_class_t type);
|
||||
static herr_t H5S_set_extent_simple (H5S_t *space, unsigned rank,
|
||||
const hsize_t *dims, const hsize_t *max);
|
||||
static htri_t H5S_is_simple(const H5S_t *sdim);
|
||||
@ -300,13 +299,13 @@ H5S_term_interface(void)
|
||||
EXAMPLES
|
||||
REVISION LOG
|
||||
--------------------------------------------------------------------------*/
|
||||
static H5S_t *
|
||||
H5S_t *
|
||||
H5S_create(H5S_class_t type)
|
||||
{
|
||||
H5S_t *new_ds = NULL; /* New dataspace created */
|
||||
H5S_t *ret_value; /* Return value */
|
||||
|
||||
FUNC_ENTER_NOAPI_NOINIT(H5S_create)
|
||||
FUNC_ENTER_NOAPI(H5S_create, NULL)
|
||||
|
||||
/* Create a new data space */
|
||||
if(NULL == (new_ds = H5FL_MALLOC(H5S_t)))
|
||||
@ -333,7 +332,7 @@ H5S_create(H5S_class_t type)
|
||||
} /* end switch */
|
||||
|
||||
/* Start with "all" selection */
|
||||
if(H5S_select_all(new_ds, 0) < 0)
|
||||
if(H5S_select_all(new_ds, FALSE) < 0)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection")
|
||||
|
||||
/* Reset common selection info pointer */
|
||||
@ -1159,7 +1158,7 @@ H5S_read(const H5O_loc_t *loc, hid_t dxpl_id)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "unable to load dataspace info from dataset header")
|
||||
|
||||
/* Default to entire dataspace being selected */
|
||||
if(H5S_select_all(ds, 0) < 0)
|
||||
if(H5S_select_all(ds, FALSE) < 0)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection")
|
||||
|
||||
/* Set the value for successful return */
|
||||
@ -1895,7 +1894,7 @@ H5S_decode(const unsigned char *buf)
|
||||
H5FL_FREE(H5S_extent_t, extent);
|
||||
|
||||
/* Initialize to "all" selection. Deserialization relies on valid existing selection. */
|
||||
if(H5S_select_all(ds, 0) < 0)
|
||||
if(H5S_select_all(ds, FALSE) < 0)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection")
|
||||
|
||||
/* Decode the select part of dataspace. I believe this part always exists. */
|
||||
|
28
src/H5Sall.c
28
src/H5Sall.c
@ -547,8 +547,8 @@ H5S_all_deserialize (H5S_t *space, const uint8_t UNUSED *buf)
|
||||
assert(space);
|
||||
|
||||
/* Change to "all" selection */
|
||||
if((ret_value=H5S_select_all(space,1))<0)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
|
||||
if((ret_value = H5S_select_all(space, TRUE)) < 0)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value);
|
||||
@ -702,7 +702,7 @@ H5S_all_is_regular(const H5S_t UNUSED *space)
|
||||
USAGE
|
||||
herr_t H5S_select_all(dsid)
|
||||
hid_t dsid; IN: Dataspace ID of selection to modify
|
||||
unsigned rel_prev; IN: Flag whether to release previous selection or not
|
||||
hbool_t rel_prev; IN: Flag whether to release previous selection or not
|
||||
RETURNS
|
||||
Non-negative on success/Negative on failure
|
||||
DESCRIPTION
|
||||
@ -713,28 +713,28 @@ H5S_all_is_regular(const H5S_t UNUSED *space)
|
||||
REVISION LOG
|
||||
--------------------------------------------------------------------------*/
|
||||
herr_t
|
||||
H5S_select_all (H5S_t *space, unsigned rel_prev)
|
||||
H5S_select_all(H5S_t *space, hbool_t rel_prev)
|
||||
{
|
||||
herr_t ret_value=SUCCEED; /* return value */
|
||||
herr_t ret_value = SUCCEED; /* return value */
|
||||
|
||||
FUNC_ENTER_NOAPI(H5S_select_all, FAIL);
|
||||
FUNC_ENTER_NOAPI(H5S_select_all, FAIL)
|
||||
|
||||
/* Check args */
|
||||
assert(space);
|
||||
HDassert(space);
|
||||
|
||||
/* Remove current selection first */
|
||||
if(rel_prev)
|
||||
if(H5S_SELECT_RELEASE(space)<0)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection");
|
||||
if(H5S_SELECT_RELEASE(space) < 0)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection")
|
||||
|
||||
/* Set number of elements in selection */
|
||||
space->select.num_elem=(hsize_t)H5S_GET_EXTENT_NPOINTS(space);
|
||||
space->select.num_elem = (hsize_t)H5S_GET_EXTENT_NPOINTS(space);
|
||||
|
||||
/* Set selection type */
|
||||
space->select.type=H5S_sel_all;
|
||||
space->select.type = H5S_sel_all;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value);
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5S_select_all() */
|
||||
|
||||
|
||||
@ -767,8 +767,8 @@ herr_t H5Sselect_all (hid_t spaceid)
|
||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
|
||||
|
||||
/* Call internal routine to do the work */
|
||||
if((ret_value=H5S_select_all(space,1))<0)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
|
||||
if((ret_value = H5S_select_all(space, TRUE)) < 0)
|
||||
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_API(ret_value);
|
||||
|
@ -211,6 +211,7 @@ H5_DLL H5S_t *H5S_read(const struct H5O_loc_t *loc, hid_t dxpl_id);
|
||||
H5_DLL int H5S_extend(H5S_t *space, const hsize_t *size);
|
||||
H5_DLL int H5S_set_extent(H5S_t *space, const hsize_t *size);
|
||||
H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size);
|
||||
H5_DLL H5S_t *H5S_create(H5S_class_t type);
|
||||
H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/],
|
||||
const hsize_t maxdims[/*rank*/]);
|
||||
H5_DLL herr_t H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
|
||||
@ -242,7 +243,7 @@ H5_DLL htri_t H5S_select_is_single(const H5S_t *space);
|
||||
H5_DLL htri_t H5S_select_is_regular(const H5S_t *space);
|
||||
|
||||
/* Operations on all selections */
|
||||
H5_DLL herr_t H5S_select_all(H5S_t *space, unsigned rel_prev);
|
||||
H5_DLL herr_t H5S_select_all(H5S_t *space, hbool_t rel_prev);
|
||||
|
||||
/* Operations on none selections */
|
||||
H5_DLL herr_t H5S_select_none(H5S_t *space);
|
||||
|
@ -215,6 +215,100 @@ test_getset(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: test_getset_vl
|
||||
*
|
||||
* Purpose: Tests the H5Pget_fill_value() and H5Pset_fill_value()
|
||||
* functions, using variable-length datatype.
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: number of errors
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Thursday, May 31, 2007
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
test_getset_vl(hid_t fapl)
|
||||
{
|
||||
hsize_t dims[1] = {2};
|
||||
hid_t fileid = (-1), spaceid = (-1), typeid = (-1), datasetid = (-1), plistid = (-1);
|
||||
char fill_value[] = "aaaa";
|
||||
char orig_fill_value[] = "aaaa";
|
||||
char *f1 = fill_value;
|
||||
char *f2;
|
||||
char filename[1024];
|
||||
|
||||
TESTING("property lists, with variable-length datatype");
|
||||
|
||||
/* Create string type. */
|
||||
if((typeid = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR
|
||||
if(H5Tset_size(typeid, H5T_VARIABLE) < 0) TEST_ERROR
|
||||
|
||||
/* Set up dataset creation property list, with fill value */
|
||||
if((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
|
||||
if(H5Pset_fill_value(plistid, typeid, &f1) < 0) TEST_ERROR
|
||||
|
||||
/* Modify original fill value string */
|
||||
fill_value[0] = 'b';
|
||||
|
||||
/* Retrieve fill value from property */
|
||||
if(H5Pget_fill_value(plistid, typeid, &f2) < 0) TEST_ERROR
|
||||
|
||||
/* Verify that the fill value is the original value */
|
||||
if(HDstrcmp(f2, orig_fill_value)) TEST_ERROR
|
||||
|
||||
/* Release the fill value retrieved */
|
||||
HDfree(f2);
|
||||
|
||||
/* Open file. */
|
||||
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
|
||||
if((fileid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
|
||||
|
||||
/* Write an dataset of this type. */
|
||||
if((spaceid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR
|
||||
if((datasetid = H5Dcreate(fileid, "Dataset", typeid, spaceid, plistid)) < 0) TEST_ERROR
|
||||
|
||||
/* Close IDs (except datatype) */
|
||||
if(H5Dclose(datasetid) < 0) TEST_ERROR
|
||||
if(H5Pclose(plistid) < 0) TEST_ERROR
|
||||
if(H5Sclose(spaceid) < 0) TEST_ERROR
|
||||
if(H5Fclose(fileid) < 0) TEST_ERROR
|
||||
|
||||
|
||||
/* Re-open file, group & dataset */
|
||||
if((fileid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR
|
||||
if((datasetid = H5Dopen(fileid, "Dataset")) < 0) TEST_ERROR
|
||||
|
||||
/* Get dataset's creation property list */
|
||||
if((plistid = H5Dget_create_plist(datasetid)) < 0) TEST_ERROR
|
||||
|
||||
/* Query fill value */
|
||||
if(H5Pget_fill_value(plistid, typeid, &f2) < 0) TEST_ERROR
|
||||
|
||||
/* Verify that the fill value is the original value */
|
||||
if(HDstrcmp(f2, orig_fill_value)) TEST_ERROR
|
||||
|
||||
/* Release the fill value retrieved */
|
||||
HDfree(f2);
|
||||
|
||||
/* Close IDs */
|
||||
if(H5Dclose(datasetid) < 0) TEST_ERROR
|
||||
if(H5Fclose(fileid) < 0) TEST_ERROR
|
||||
if(H5Pclose(plistid) < 0) TEST_ERROR
|
||||
if(H5Tclose(typeid) < 0) TEST_ERROR
|
||||
|
||||
PASSED();
|
||||
return 0;
|
||||
|
||||
error:
|
||||
H5E_BEGIN_TRY {
|
||||
} H5E_END_TRY;
|
||||
return 1;
|
||||
} /* end test_getset_vl() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: test_create
|
||||
@ -1448,6 +1542,7 @@ main(int argc, char *argv[])
|
||||
|
||||
/* Property list tests */
|
||||
nerrors += test_getset();
|
||||
nerrors += test_getset_vl(fapl);
|
||||
|
||||
/* Copy the file access property list */
|
||||
if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR
|
||||
|
Loading…
Reference in New Issue
Block a user