From c5a9bb780f5ce444f888b3cfe775bbe07b5d7b95 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 12 Oct 2015 13:48:27 -0500 Subject: [svn-r28041] Description: Merge r27811 from trunk to branch. Tested on: MacOSX/64 10.10.5 (amazon) w/serial & parallel (h5committest not required on this branch) --- src/H5Dchunk.c | 157 +++--- src/H5Dcompact.c | 31 +- src/H5Dcontig.c | 4 +- src/H5Defl.c | 1 + src/H5Dint.c | 180 +++++-- src/H5Dlayout.c | 12 +- src/H5Dmpio.c | 10 +- src/H5Dpkg.h | 3 +- src/H5FD.c | 219 +-------- src/H5FDcore.c | 16 +- src/H5FDdirect.c | 38 +- src/H5FDfamily.c | 54 +-- src/H5FDlog.c | 4 +- src/H5FDmpi.c | 13 +- src/H5FDmpio.c | 175 +++---- src/H5FDprivate.h | 9 +- src/H5Fefc.c | 9 +- src/H5Fint.c | 39 +- src/H5Fprivate.h | 6 +- src/H5Gobj.c | 2 +- src/H5Lexternal.c | 6 +- src/H5Ocopy.c | 2 +- src/H5Oefl.c | 71 ++- src/H5Olayout.c | 7 +- src/H5Oprivate.h | 3 + src/H5P.c | 2 +- src/H5Pdapl.c | 1 + src/H5Pdcpl.c | 799 +++++++++++++++++++++++-------- src/H5Pdxpl.c | 93 +++- src/H5Pencdec.c | 2 +- src/H5Pfapl.c | 1008 +++++++++++++++++++++++++++------------ src/H5Pint.c | 1363 +++++++++++++++++++++++++++++++---------------------- src/H5Plapl.c | 406 ++++++++++------ src/H5Pocpl.c | 323 ++++++++----- src/H5Pocpypl.c | 229 +++++++-- src/H5Pprivate.h | 10 +- src/H5Ptest.c | 12 +- src/H5T.c | 2 + src/H5Z.c | 6 +- src/H5Ztrans.c | 33 +- src/H5err.txt | 2 + test/links.c | 14 +- test/testframe.c | 23 +- test/tfile.c | 8 +- test/tgenprop.c | 29 +- 45 files changed, 3373 insertions(+), 2063 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index de001b7..6ec8aae 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -214,6 +214,7 @@ static herr_t H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *ty H5D_chunk_map_t *fm); static herr_t H5D__chunk_flush(H5D_t *dset, hid_t dxpl_id); static herr_t H5D__chunk_io_term(const H5D_chunk_map_t *fm); +static herr_t H5D__chunk_dest(H5D_t *dset, hid_t dxpl_id); /* "Nonexistent" layout operation callback */ static ssize_t @@ -281,7 +282,8 @@ const H5D_layout_ops_t H5D_LOPS_CHUNK[1] = {{ NULL, NULL, H5D__chunk_flush, - H5D__chunk_io_term + H5D__chunk_io_term, + H5D__chunk_dest }}; @@ -304,6 +306,7 @@ const H5D_layout_ops_t H5D_LOPS_NONEXISTENT[1] = {{ H5D__nonexistent_readvv, NULL, NULL, + NULL, NULL }}; @@ -2253,6 +2256,82 @@ done: /*------------------------------------------------------------------------- + * Function: H5D__chunk_dest + * + * Purpose: Destroy the entire chunk cache by flushing dirty entries, + * preempting all entries, and freeing the cache itself. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Thursday, May 21, 1998 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__chunk_dest(H5D_t *dset, hid_t dxpl_id) +{ + H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ + H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ + H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Dataset's chunk cache */ + H5D_rdcc_ent_t *ent = NULL, *next = NULL; /* Pointer to current & next cache entries */ + int nerrors = 0; /* Accumulated count of errors */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC_TAG(dxpl_id, dset->oloc.addr, FAIL) + + /* Sanity checks */ + HDassert(dset); + HDassert((H5D_CHUNK_IDX_EARRAY == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_EARRAY == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_FARRAY == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_FARRAY == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_BT2 == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_BT2 == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops) || + (H5D_CHUNK_IDX_NONE == dset->shared->layout.storage.u.chunk.idx_type && + H5D_COPS_NONE == dset->shared->layout.storage.u.chunk.ops)); + + /* Fill the DXPL cache values for later use */ + if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) + nerrors++; + + /* Flush all the cached chunks */ + for(ent = rdcc->head; ent; ent = next) { + next = ent->next; + if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0) + nerrors++; + } /* end for */ + + /* Continue even if there are failures. */ + if(nerrors) + HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") + + /* Release cache structures */ + if(rdcc->slot) + rdcc->slot = H5FL_SEQ_FREE(H5D_rdcc_ent_ptr_t, rdcc->slot); + HDmemset(rdcc, 0, sizeof(H5D_rdcc_t)); + + /* Compose chunked index info struct */ + idx_info.f = dset->oloc.file; + idx_info.dxpl_id = dxpl_id; + idx_info.pline = &dset->shared->dcpl_cache.pline; + idx_info.layout = &dset->shared->layout.u.chunk; + idx_info.storage = &dset->shared->layout.storage.u.chunk; + + /* Free any index structures */ + if(dset->shared->layout.storage.u.chunk.ops->dest && + (dset->shared->layout.storage.u.chunk.ops->dest)(&idx_info) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") + +done: + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5D__chunk_dest() */ + + +/*------------------------------------------------------------------------- * Function: H5D_chunk_idx_reset * * Purpose: Reset index information @@ -5927,82 +6006,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_dump_index() */ - -/*------------------------------------------------------------------------- - * Function: H5D__chunk_dest - * - * Purpose: Destroy the entire chunk cache by flushing dirty entries, - * preempting all entries, and freeing the cache itself. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Thursday, May 21, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5D__chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset) -{ - H5D_chk_idx_info_t idx_info; /* Chunked index info */ - H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ - H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ - H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Dataset's chunk cache */ - H5D_rdcc_ent_t *ent = NULL, *next = NULL; /* Pointer to current & next cache entries */ - int nerrors = 0; /* Accumulated count of errors */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE_TAG(dxpl_id, dset->oloc.addr, FAIL) - - HDassert(f); - HDassert(dset); - HDassert((H5D_CHUNK_IDX_EARRAY == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_EARRAY == dset->shared->layout.storage.u.chunk.ops) || - (H5D_CHUNK_IDX_FARRAY == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_FARRAY == dset->shared->layout.storage.u.chunk.ops) || - (H5D_CHUNK_IDX_BT2 == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_BT2 == dset->shared->layout.storage.u.chunk.ops) || - (H5D_CHUNK_IDX_BTREE == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_BTREE == dset->shared->layout.storage.u.chunk.ops) || - (H5D_CHUNK_IDX_NONE == dset->shared->layout.storage.u.chunk.idx_type && - H5D_COPS_NONE == dset->shared->layout.storage.u.chunk.ops)); - - /* Fill the DXPL cache values for later use */ - if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") - - /* Flush all the cached chunks */ - for(ent = rdcc->head; ent; ent = next) { - next = ent->next; - if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0) - nerrors++; - } /* end for */ - - /* Continue even if there are failures. */ - if(nerrors) - HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") - - /* Release cache structures */ - if(rdcc->slot) - rdcc->slot = H5FL_SEQ_FREE(H5D_rdcc_ent_ptr_t, rdcc->slot); - HDmemset(rdcc, 0, sizeof(H5D_rdcc_t)); - - /* Compose chunked index info struct */ - idx_info.f = f; - idx_info.dxpl_id = dxpl_id; - idx_info.pline = &dset->shared->dcpl_cache.pline; - idx_info.layout = &dset->shared->layout.u.chunk; - idx_info.storage = &dset->shared->layout.storage.u.chunk; - - /* Free any index structures */ - if(dset->shared->layout.storage.u.chunk.ops->dest && - (dset->shared->layout.storage.u.chunk.ops->dest)(&idx_info) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "unable to release chunk index info") - -done: - FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5D__chunk_dest() */ - #ifdef H5D_CHUNK_DEBUG /*------------------------------------------------------------------------- diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 13dd4d1..3ec3f44 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -70,6 +70,7 @@ static ssize_t H5D__compact_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]); static herr_t H5D__compact_flush(H5D_t *dset, hid_t dxpl_id); +static herr_t H5D__compact_dest(H5D_t *dset, hid_t dxpl_id); /*********************/ @@ -91,7 +92,8 @@ const H5D_layout_ops_t H5D_LOPS_COMPACT[1] = {{ H5D__compact_readvv, H5D__compact_writevv, H5D__compact_flush, - NULL + NULL, + H5D__compact_dest }}; @@ -389,6 +391,33 @@ done: /*------------------------------------------------------------------------- + * Function: H5D__compact_dest + * + * Purpose: Free the compact buffer + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, Sept 3, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D__compact_dest(H5D_t *dset, hid_t H5_ATTR_UNUSED dxpl_id) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(dset); + + /* Free the buffer for the raw data for compact datasets */ + dset->shared->layout.storage.u.compact.buf = H5MM_xfree(dset->shared->layout.storage.u.compact.buf); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5D__compact_dest() */ + + +/*------------------------------------------------------------------------- * Function: H5D__compact_copy * * Purpose: Copy compact storage raw data from SRC file to DST file. diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index fb3ac85..1f6cd68 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -133,6 +133,7 @@ const H5D_layout_ops_t H5D_LOPS_CONTIG[1] = {{ H5D__contig_readvv, H5D__contig_writevv, H5D__contig_flush, + NULL, NULL }}; @@ -466,7 +467,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__contig_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id) +H5D__contig_init(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + const H5D_t *dset, hid_t H5_ATTR_UNUSED dapl_id) { hsize_t tmp_size; /* Temporary holder for raw data size */ size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ diff --git a/src/H5Defl.c b/src/H5Defl.c index 9e5872a..7a77c22 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -100,6 +100,7 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ H5D__efl_readvv, H5D__efl_writevv, NULL, + NULL, NULL }}; diff --git a/src/H5Dint.c b/src/H5Dint.c index d74144b..9b748e7 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -352,8 +352,11 @@ H5D__get_dxpl_cache_real(hid_t dxpl_id, H5D_dxpl_cache_t *cache) if(H5P_get(dx_plist, H5D_XFER_FILTER_CB_NAME, &cache->filter_cb) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve filter callback function") - /* Get the data transform property */ - if(H5P_get(dx_plist, H5D_XFER_XFORM_NAME, &cache->data_xform_prop) < 0) + /* Look at the data transform property */ + /* (Note: 'peek', not 'get' - if this turns out to be a problem, we should + * add a H5D__free_dxpl_cache() routine. -QAK) + */ + if(H5P_peek(dx_plist, H5D_XFER_XFORM_NAME, &cache->data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "Can't retrieve data transform info") done: @@ -1041,12 +1044,11 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTUNPIN, FAIL, "unable to unpin dataset object header") /* Error cleanup */ - if(ret_value < 0) { - if(dset->shared->layout.type == H5D_CHUNKED && layout_init) { - if(H5D__chunk_dest(file, dxpl_id, dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") - } /* end if */ - } /* end if */ + if(ret_value < 0) + if(layout_init) + /* Destroy the layout information for the dataset */ + if(dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset, dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__update_oh_info() */ @@ -1081,6 +1083,10 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, H5P_genplist_t *dc_plist = NULL; /* New Property list */ hbool_t has_vl_type = FALSE; /* Flag to indicate a VL-type for dataset */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ + hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ + hbool_t fill_copied = FALSE; /* Flag to indicate that fill-value message was copied */ + hbool_t pline_copied = FALSE; /* Flag to indicate that pipeline message was copied */ + hbool_t efl_copied = FALSE; /* Flag to indicate that external file list message was copied */ H5G_loc_t dset_loc; /* Dataset location */ H5D_t *ret_value; /* Return value */ @@ -1138,6 +1144,7 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, H5O_layout_t *layout; /* Dataset's layout information */ H5O_pline_t *pline; /* Dataset's I/O pipeline information */ H5O_fill_t *fill; /* Dataset's fill value info */ + H5O_efl_t *efl; /* Dataset's external file list info */ /* Check if the filters in the DCPL can be applied to this dataset */ if(H5Z_can_apply(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) @@ -1154,13 +1161,20 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* Retrieve the properties we need */ pline = &new_dset->shared->dcpl_cache.pline; if(H5P_get(dc_plist, H5O_CRT_PIPELINE_NAME, pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve pipeline filter") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve pipeline filter") + pline_copied = TRUE; layout = &new_dset->shared->layout; if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, layout) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve layout") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve layout") + layout_copied = TRUE; fill = &new_dset->shared->dcpl_cache.fill; if(H5P_get(dc_plist, H5D_CRT_FILL_VALUE_NAME, fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve fill value info") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve fill value info") + fill_copied = TRUE; + efl = &new_dset->shared->dcpl_cache.efl; + if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, efl) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't retrieve external file list") + efl_copied = TRUE; /* Check that chunked layout is used if filters are enabled */ if(pline->nused > 0 && H5D_CHUNKED != layout->type) @@ -1177,10 +1191,6 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* If MPI VFD is used, no filter support yet. */ if(H5F_HAS_FEATURE(file, H5FD_FEAT_HAS_MPI) && pline->nused > 0) HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "Parallel I/O does not support filters yet") - - /* Get the dataset's external file list information */ - if(H5P_get(dc_plist, H5D_CRT_EXT_FILE_LIST_NAME, &new_dset->shared->dcpl_cache.efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve external file list") } /* end if */ /* Set the latest version of the layout, pline & fill messages, if requested */ @@ -1238,10 +1248,21 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, done: if(!ret_value && new_dset && new_dset->shared) { if(new_dset->shared) { - if(new_dset->shared->layout.type == H5D_CHUNKED && layout_init) { - if(H5D__chunk_dest(file, dxpl_id, new_dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to destroy chunk cache") - } /* end if */ + if(layout_init) + if(new_dset->shared->layout.ops->dest && (new_dset->shared->layout.ops->dest)(new_dset, dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "unable to destroy layout info") + if(pline_copied) + if(H5O_msg_reset(H5O_PLINE_ID, &new_dset->shared->dcpl_cache.pline) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset I/O pipeline info") + if(layout_copied) + if(H5O_msg_reset(H5O_LAYOUT_ID, &new_dset->shared->layout) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset layout info") + if(fill_copied) + if(H5O_msg_reset(H5O_FILL_ID, &new_dset->shared->dcpl_cache.fill) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset fill-value info") + if(efl_copied) + if(H5O_msg_reset(H5O_EFL_ID, &new_dset->shared->dcpl_cache.efl) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset external file list info") if(new_dset->shared->space && H5S_close(new_dset->shared->space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") if(new_dset->shared->type && H5I_dec_ref(new_dset->shared->type_id) < 0) @@ -1661,10 +1682,9 @@ done: if(H5F_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc)) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header") if(dataset->shared) { - if(dataset->shared->layout.type == H5D_CHUNKED && layout_init) { - if(H5D__chunk_dest(dataset->oloc.file, dxpl_id, dataset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") - } /* end if */ + if(layout_init) + if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset, dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") if(dataset->shared->space && H5S_close(dataset->shared->space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") if(dataset->shared->type) { @@ -1755,16 +1775,10 @@ H5D_close(H5D_t *dataset) dataset->shared->cache.chunk.single_chunk_info = H5FL_FREE(H5D_chunk_info_t, dataset->shared->cache.chunk.single_chunk_info); dataset->shared->cache.chunk.single_chunk_info = NULL; } /* end if */ - - /* Flush and destroy chunks in the cache. Continue to close even if - * it fails. */ - if(H5D__chunk_dest(dataset->oloc.file, H5AC_dxpl_id, dataset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") break; case H5D_COMPACT: - /* Free the buffer for the raw data for compact datasets */ - dataset->shared->layout.storage.u.compact.buf = H5MM_xfree(dataset->shared->layout.storage.u.compact.buf); + /* Nothing special to do (info freed in the layout destroy) */ break; case H5D_LAYOUT_ERROR: @@ -1776,24 +1790,34 @@ H5D_close(H5D_t *dataset) #endif /* NDEBUG */ } /* end switch */ /*lint !e788 All appropriate cases are covered */ + /* Destroy any cached layout information for the dataset */ + if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset, H5AC_dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") + + /* Release layout, fill-value, efl & pipeline messages */ + if(dataset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) + free_failed |= (H5O_msg_reset(H5O_PLINE_ID, &dataset->shared->dcpl_cache.pline) < 0) || + (H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) || + (H5O_msg_reset(H5O_FILL_ID, &dataset->shared->dcpl_cache.fill) < 0) || + (H5O_msg_reset(H5O_EFL_ID, &dataset->shared->dcpl_cache.efl) < 0); + /* Uncork cache entries with object address tag */ if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__GET_CORKED, &corked) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_SYSTEM, FAIL, "unable to retrieve an object's cork status") - else if(corked) { + HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") + else if(corked) if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_SYSTEM, FAIL, "unable to uncork an object") - } + HDONE_ERROR(H5E_DATASET, H5E_CANTUNCORK, FAIL, "unable to uncork an object") /* If the dataset is opened for SWMR access, shut that down */ if(dataset->shared->is_swimming) if(H5D__swmr_teardown(dataset, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to shut down SWMR access") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to shut down SWMR access") /* - * 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 = (H5I_dec_ref(dataset->shared->type_id) < 0) || + * 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 |= (H5I_dec_ref(dataset->shared->type_id) < 0) || (H5S_close(dataset->shared->space) < 0) || (H5I_dec_ref(dataset->shared->dcpl_id) < 0); @@ -2957,7 +2981,9 @@ H5D_get_create_plist(H5D_t *dset) { H5P_genplist_t *dcpl_plist; /* Dataset's DCPL */ H5P_genplist_t *new_plist; /* Copy of dataset's DCPL */ + H5O_layout_t copied_layout; /* Layout to tweak */ H5O_fill_t copied_fill; /* Fill value to tweak */ + H5O_efl_t copied_efl; /* External file list to tweak */ hid_t new_dcpl_id = FAIL; hid_t ret_value; /* Return value */ @@ -2965,21 +2991,62 @@ H5D_get_create_plist(H5D_t *dset) /* Check args */ if(NULL == (dcpl_plist = (H5P_genplist_t *)H5I_object(dset->shared->dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get property list") /* Copy the creation property list */ if((new_dcpl_id = H5P_copy_plist(dcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to copy the creation property list") if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "can't get property list") /* Retrieve any object creation properties */ if(H5O_get_create_plist(&dset->oloc, H5AC_ind_dxpl_id, new_plist) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object creation info") + /* Get the layout property */ + if(H5P_peek(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get layout") + + /* Reset layout values set when dataset is created */ + copied_layout.ops = NULL; + switch(copied_layout.type) { + case H5D_COMPACT: + copied_layout.storage.u.compact.buf = H5MM_xfree(copied_layout.storage.u.compact.buf); + HDmemset(&copied_layout.storage.u.compact, 0, sizeof(copied_layout.storage.u.compact)); + break; + + case H5D_CONTIGUOUS: + copied_layout.storage.u.contig.addr = HADDR_UNDEF; + copied_layout.storage.u.contig.size = 0; + break; + + case H5D_CHUNKED: + /* Reset chunk size */ + copied_layout.u.chunk.size = 0; + + /* Reset index info, if the chunk ops are set */ + if(copied_layout.storage.u.chunk.ops) + /* Reset address and pointer of the array struct for the chunked storage index */ + if(H5D_chunk_idx_reset(&copied_layout.storage.u.chunk, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") + + /* Reset chunk index ops */ + copied_layout.storage.u.chunk.ops = NULL; + break; + + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + default: + HDassert(0 && "Unknown layout type!"); + } /* end switch */ + + /* Set back the (possibly modified) layout property to property list */ + if(H5P_poke(new_plist, H5D_CRT_LAYOUT_NAME, &copied_layout) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set layout") + /* Get the fill value property */ - 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") + if(H5P_peek(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get fill value") /* Check if there is a fill value, but no type yet */ if(copied_fill.buf != NULL && copied_fill.type == NULL) { @@ -3006,7 +3073,7 @@ H5D_get_create_plist(H5D_t *dset) src_id = H5I_register(H5I_DATATYPE, H5T_copy(dset->shared->type, H5T_COPY_ALL), FALSE); if(src_id < 0) { H5I_dec_ref(dst_id); - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy/register datatype") } /* end if */ /* Allocate a background buffer */ @@ -3014,7 +3081,7 @@ H5D_get_create_plist(H5D_t *dset) if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { H5I_dec_ref(src_id); H5I_dec_ref(dst_id); - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed") } /* end if */ /* Convert fill value */ @@ -3036,9 +3103,26 @@ H5D_get_create_plist(H5D_t *dset) } /* 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") + /* Set back the (possibly modified) fill value property to property list */ + if(H5P_poke(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set fill value") + + /* Get the fill value property */ + if(H5P_peek(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &copied_efl) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get external file list") + + /* Reset efl name_offset and heap_addr, these are the values when the dataset is created */ + if(copied_efl.slot) { + unsigned u; + + copied_efl.heap_addr = HADDR_UNDEF; + for(u = 0; u < copied_efl.nused; u++) + copied_efl.slot[u].name_offset = 0; + } /* end if */ + + /* Set back the (possibly modified) external file list property to property list */ + if(H5P_poke(new_plist, H5D_CRT_EXT_FILE_LIST_NAME, &copied_efl) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set external file list") /* Set the return value */ ret_value = new_dcpl_id; diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 06b59f9..d20a6a1 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -499,7 +499,6 @@ H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset, } /* end if */ /* Store EFL file name offset */ - HDassert(0 == efl->slot[u].name_offset); efl->slot[u].name_offset = offset; } /* end for */ @@ -534,12 +533,11 @@ H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset, done: /* Error cleanup */ - if(ret_value < 0) { - if(dset->shared->layout.type == H5D_CHUNKED && layout_init) { - if(H5D__chunk_dest(file, dxpl_id, dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") - } /* end if */ - } /* end if */ + if(ret_value < 0) + if(layout_init) + /* Destroy any cached layout information for the dataset */ + if(dset->shared->layout.ops->dest && (dset->shared->layout.ops->dest)(dset, dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) } /* end H5D__layout_oh_create() */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 289e12b..c35f194 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -605,7 +605,8 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") /* Check the optional property list on what to do with collective chunk IO. */ - chunk_opt_mode = (H5FD_mpio_chunk_opt_t)H5P_peek_unsigned(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME); + if(H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, &chunk_opt_mode) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't get chunk optimization option") if(H5FD_MPIO_CHUNK_ONE_IO == chunk_opt_mode) io_option = H5D_ONE_LINK_CHUNK_IO; /*no opt*/ /* direct request to multi-chunk-io */ @@ -621,7 +622,9 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf if((mpi_size = H5F_mpi_get_size(io_info->dset->oloc.file)) < 0) HGOTO_ERROR(H5E_IO, H5E_MPI, FAIL, "unable to obtain mpi size") - one_link_chunk_io_threshold = H5P_peek_unsigned(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME); + /* Get the chunk optimization option */ + if(H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, &one_link_chunk_io_threshold) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't get chunk optimization option") /* step 1: choose an IO option */ /* If the average number of chunk per process is greater than a threshold, we will do one link chunked IO. */ @@ -1698,7 +1701,8 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, /* Setup parameters */ H5_CHECKED_ASSIGN(total_chunks, int, fm->layout->u.chunk.nchunks, hsize_t); - percent_nproc_per_chunk = H5P_peek_unsigned(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME); + if(H5P_get(dx_plist, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, &percent_nproc_per_chunk) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTGET, FAIL, "couldn't get percent nproc per chunk") /* if ratio is 0, perform collective io */ if(0 == percent_nproc_per_chunk) { if(H5D__chunk_addrmap(io_info, chunk_addr) < 0) diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index f5b1b94..258c161 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -143,6 +143,7 @@ typedef ssize_t (*H5D_layout_writevv_func_t)(const struct H5D_io_info_t *io_info size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[]); typedef herr_t (*H5D_layout_flush_func_t)(H5D_t *dataset, hid_t dxpl_id); typedef herr_t (*H5D_layout_io_term_func_t)(const struct H5D_chunk_map_t *cm); +typedef herr_t (*H5D_layout_dest_func_t)(H5D_t *dataset, hid_t dxpl_id); /* Typedef for grouping layout I/O routines */ typedef struct H5D_layout_ops_t { @@ -160,6 +161,7 @@ typedef struct H5D_layout_ops_t { H5D_layout_writevv_func_t writevv; /* Low-level I/O routine for writing data */ H5D_layout_flush_func_t flush; /* Low-level I/O routine for flushing raw data */ H5D_layout_io_term_func_t io_term; /* I/O shutdown routine */ + H5D_layout_dest_func_t dest; /* Destroy layout info */ } H5D_layout_ops_t; /* Function pointers for either multiple or single block I/O access */ @@ -699,7 +701,6 @@ H5_DLL herr_t H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5_DLL herr_t H5D__chunk_bh_info(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout, const H5O_pline_t *pline, hsize_t *btree_size); H5_DLL herr_t H5D__chunk_dump_index(H5D_t *dset, hid_t dxpl_id, FILE *stream); -H5_DLL herr_t H5D__chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset); H5_DLL herr_t H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *store); H5_DLL herr_t H5D__chunk_create_flush_dep(const H5D_rdcc_t *rdcc, diff --git a/src/H5FD.c b/src/H5FD.c index bda9357..2dc4de5 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -65,12 +65,7 @@ /********************/ /* Local Prototypes */ /********************/ -static herr_t H5FD_pl_copy(void *(*copy_func)(const void *), size_t pl_size, - const void *old_pl, void **copied_pl); -static herr_t H5FD_pl_close(hid_t driver_id, herr_t (*free_func)(void *), - void *pl); static herr_t H5FD_free_cls(H5FD_class_t *cls); -static herr_t H5FD_fapl_copy(hid_t driver_id, const void *fapl, void **copied_fapl); static int H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/); static int H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/); @@ -457,9 +452,11 @@ H5FD_get_class(hid_t id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") if(TRUE == H5P_isa_class(id, H5P_FILE_ACCESS)) { - if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID") - ret_value = H5FD_get_class(driver_id); + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + + if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID & info") + ret_value = H5FD_get_class(driver_prop.driver_id); } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a driver id or file access property list") @@ -614,96 +611,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_pl_copy - * - * Purpose: Copies the driver-specific part of the a property list. - * This is common code, used by both the dataset transfer and - * file access property list routines. - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Thursday, October 23, 2003 - * - * Modifications: - * Pedro Vicente Nunes, Wednesday, July 26, 2006 - * added a HGOTO_ERROR call in the case the copy function returns NULL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_pl_copy(void *(*copy_func)(const void *), size_t pl_size, const void *old_pl, void **copied_pl) -{ - void *new_pl = NULL; /* Copy of property list */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Copy old pl, if one exists */ - if(old_pl) { - /* Allow the driver to copy or do it ourselves */ - if(copy_func) { - new_pl = (copy_func)(old_pl); - if(new_pl==NULL) - HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "property list copy failed") - } else if(pl_size>0) { - if((new_pl = H5MM_malloc(pl_size))==NULL) - HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "property list allocation failed") - HDmemcpy(new_pl, old_pl, pl_size); - } else - HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "no way to copy driver property list") - } /* end if */ - - /* Set copied value */ - *copied_pl=new_pl; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_pl_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5FD_pl_close - * - * Purpose: Closes a driver for a property list - * This is common code, used by both the dataset transfer and - * file access property list routines. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Quincey Koziol - * Thursday, October 23, 2003 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_pl_close(hid_t driver_id, herr_t (*free_func)(void *), void *pl) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Allow driver to free or do it ourselves */ - if(pl && free_func) { - if((free_func)(pl) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver free request failed") - } /* end if */ - else - H5MM_xfree(pl); - - /* Decrement reference count for driver */ - if(H5I_dec_ref(driver_id) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement reference count for driver") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_pl_close() */ - - -/*------------------------------------------------------------------------- * Function: H5FD_fapl_get * * Purpose: Gets the file access property list associated with a file. @@ -725,8 +632,6 @@ done: * Programmer: Robb Matzke * Friday, August 13, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ void * @@ -747,88 +652,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_fapl_open - * - * Purpose: Mark a driver as used by a file access property list - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Thursday, October 23, 2003 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5FD_fapl_open(H5P_genplist_t *plist, hid_t driver_id, const void *driver_info) -{ - void *copied_driver_info = NULL; /* Temporary VFL driver info */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Increment the reference count on driver and copy driver info */ - if(H5I_inc_ref(driver_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") - if(H5FD_fapl_copy(driver_id, driver_info, &copied_driver_info) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "can't copy VFL driver info") - - /* Set the driver properties for the list */ - if(H5P_set(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set driver ID") - if(H5P_set(plist, H5F_ACS_FILE_DRV_INFO_NAME, &copied_driver_info) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set driver info") - copied_driver_info = NULL; - -done: - if(ret_value < 0) - if(copied_driver_info && H5FD_fapl_close(driver_id, copied_driver_info) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close copy of driver info") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5FD_fapl_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5FD_fapl_copy - * - * Purpose: Copies the driver-specific part of the file access property - * list. - * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Robb Matzke - * Tuesday, August 3, 1999 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5FD_fapl_copy(hid_t driver_id, const void *old_fapl, void **copied_fapl) -{ - H5FD_class_t *driver; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Check args */ - if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID") - - /* Copy the file access property list */ - if(H5FD_pl_copy(driver->fapl_copy, driver->fapl_size, old_fapl, copied_fapl) < 0) - HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "can't copy driver file access property list") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} - - -/*------------------------------------------------------------------------- * Function: H5FD_fapl_close * * Purpose: Closes a driver for a dataset transfer property list @@ -839,26 +662,32 @@ done: * Programmer: Robb Matzke * Tuesday, August 3, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t -H5FD_fapl_close(hid_t driver_id, void *fapl) +H5FD_fapl_close(hid_t driver_id, const void *driver_info) { - H5FD_class_t *driver = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ if(driver_id > 0) { + H5FD_class_t *driver; + + /* Retrieve the driver for the ID */ if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID") - /* Close the driver for the property list */ - if(H5FD_pl_close(driver_id, driver->fapl_free, fapl) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver fapl_free request failed") + /* Allow driver to free info or do it ourselves */ + if(driver_info) { + if(driver->fapl_free) { + if((driver->fapl_free)((void *)driver_info) < 0) /* Casting away const OK -QAK */ + HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "driver free request failed") + } /* end if */ + else + H5MM_xfree((void *)driver_info); /* Casting away const OK -QAK */ + } /* end if */ } /* end if */ done: @@ -970,7 +799,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_class_t *driver; /* VFD for file */ H5FD_t *file = NULL; /* VFD file struct */ - hid_t driver_id = -1; /* VFD ID */ + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ H5P_genplist_t *plist; /* Property list pointer */ unsigned long driver_flags = 0; /* File-inspecific driver feature flags */ H5FD_file_image_info_t file_image_info; /* Initial file image */ @@ -987,11 +816,11 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") /* Get the VFD to open the file with */ - if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID") + if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID & info") /* Get driver info */ - if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_id))) + if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_prop.driver_id))) HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid driver ID in file access property list") if(NULL == driver->open) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method") @@ -1000,7 +829,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5FD_driver_query(driver, &driver_flags); /* Get initial file image info */ - if(H5P_get(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) + if(H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file image info") /* If an image is provided, make sure the driver supports this feature */ @@ -1019,7 +848,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) * Fill in public fields. We must increment the reference count on the * driver ID to prevent it from being freed while this file is open. */ - file->driver_id = driver_id; + file->driver_id = driver_prop.driver_id; if(H5I_inc_ref(file->driver_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") file->cls = driver; diff --git a/src/H5FDcore.c b/src/H5FDcore.c index e3f5d92..9e576d6 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -538,7 +538,7 @@ H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) fa.increment = increment; fa.backing_store = backing_store; - ret_value= H5P_set_driver(plist, H5FD_CORE, &fa); + ret_value = H5P_set_driver(plist, H5FD_CORE, &fa); done: FUNC_LEAVE_API(ret_value) @@ -560,8 +560,8 @@ done: herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_store /*out*/) { - H5FD_core_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ + const H5FD_core_fapl_t *fa; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -569,14 +569,14 @@ H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_stor if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - if(H5FD_CORE != H5P_get_driver(plist)) + if(H5FD_CORE != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = (H5FD_core_fapl_t *)H5P_get_driver_info(plist))) + if(NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - if (increment) + if(increment) *increment = fa->increment; - if (backing_store) + if(backing_store) *backing_store = fa->backing_store; done: @@ -664,7 +664,7 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HDassert(H5P_DEFAULT != fapl_id); if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (H5FD_core_fapl_t *)H5P_get_driver_info(plist))) + if(NULL == (fa = (H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Build the open flags */ @@ -674,7 +674,7 @@ H5FD_core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if(H5F_ACC_EXCL & flags) o_flags |= O_EXCL; /* Retrieve initial file image info */ - if(H5P_get(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) + if(H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial file image info") /* If the file image exists and this is an open, make sure the file doesn't exist */ diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index c39e850..642ce4c 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -283,8 +283,6 @@ H5FD_direct_term(void) * Programmer: Raymond Lu * Wednesday, 20 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -301,17 +299,17 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if(boundary != 0) - fa.mboundary = boundary; + fa.mboundary = boundary; else - fa.mboundary = MBOUNDARY_DEF; + fa.mboundary = MBOUNDARY_DEF; if(block_size != 0) - fa.fbsize = block_size; + fa.fbsize = block_size; else - fa.fbsize = FBSIZE_DEF; + fa.fbsize = FBSIZE_DEF; if(cbuf_size != 0) - fa.cbsize = cbuf_size; + fa.cbsize = cbuf_size; else - fa.cbsize = CBSIZE_DEF; + fa.cbsize = CBSIZE_DEF; /* Set the default to be true for data alignment */ fa.must_align = TRUE; @@ -320,7 +318,7 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu if(fa.cbsize % fa.fbsize != 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "copy buffer size must be a multiple of block size") - ret_value= H5P_set_driver(plist, H5FD_DIRECT, &fa); + ret_value = H5P_set_driver(plist, H5FD_DIRECT, &fa); done: FUNC_LEAVE_API(ret_value) @@ -340,37 +338,35 @@ done: * Programmer: Raymond Lu * Wednesday, October 18, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary/*out*/, size_t *block_size/*out*/, size_t *cbuf_size/*out*/) { - H5FD_direct_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + const H5FD_direct_fapl_t *fa; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "ixxx", fapl_id, boundary, block_size, cbuf_size); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - if (H5FD_DIRECT!=H5P_get_driver(plist)) + if(H5FD_DIRECT != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if (NULL==(fa=H5P_get_driver_info(plist))) + if(NULL == (fa = H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") - if (boundary) + if(boundary) *boundary = fa->mboundary; - if (block_size) - *block_size = fa->fbsize; + if(block_size) + *block_size = fa->fbsize; if (cbuf_size) - *cbuf_size = fa->cbsize; + *cbuf_size = fa->cbsize; done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pget_fapl_direct() */ /*------------------------------------------------------------------------- @@ -511,7 +507,7 @@ H5FD_direct_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxadd /* Get the driver specific information */ if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (H5FD_direct_fapl_t *)H5P_get_driver_info(plist))) + if(NULL == (fa = (H5FD_direct_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") file->fd = fd; diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 0ead309..8886e2c 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -269,7 +269,6 @@ H5Pset_fapl_family(hid_t fapl_id, hsize_t msize, hid_t memb_fapl_id) FUNC_ENTER_API(FAIL) H5TRACE3("e", "ihi", fapl_id, msize, memb_fapl_id); - /* Check arguments */ if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") @@ -279,16 +278,13 @@ H5Pset_fapl_family(hid_t fapl_id, hsize_t msize, hid_t memb_fapl_id) if(TRUE != H5P_isa_class(memb_fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - /* - * Initialize driver specific information. No need to copy it into the FA - * struct since all members will be copied by H5P_set_driver(). - */ + /* Initialize driver specific information. */ fa.memb_size = msize; fa.memb_fapl_id = memb_fapl_id; if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - ret_value= H5P_set_driver(plist, H5FD_FAMILY, &fa); + ret_value = H5P_set_driver(plist, H5FD_FAMILY, &fa); done: FUNC_LEAVE_API(ret_value) @@ -318,21 +314,20 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Pget_fapl_family(hid_t fapl_id, hsize_t *msize/*out*/, - hid_t *memb_fapl_id/*out*/) +H5Pget_fapl_family(hid_t fapl_id, hsize_t *msize/*out*/, hid_t *memb_fapl_id/*out*/) { - H5FD_family_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + const H5FD_family_fapl_t *fa; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, msize, memb_fapl_id); if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_FAMILY != H5P_get_driver(plist)) + if(H5FD_FAMILY != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = (H5FD_family_fapl_t *)H5P_get_driver_info(plist))) + if(NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") if(msize) *msize = fa->memb_size; @@ -597,12 +592,8 @@ H5FD_family_sb_decode(H5FD_t *_file, const char H5_ATTR_UNUSED *name, const unsi file->pmem_size = msize; /* Check if member size from file access property is correct */ - if(msize != file->pmem_size) { - char err_msg[128]; - - HDsnprintf(err_msg, sizeof(err_msg), "Family member size should be %lu. But the size from file access property is %lu", (unsigned long)msize, (unsigned long)file->pmem_size); - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, err_msg) - } /* end if */ + if(msize != file->pmem_size) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "Family member size should be %lu. But the size from file access property is %lu", (unsigned long)msize, (unsigned long)file->pmem_size) /* Update member file size to the size saved in the superblock. * That's the size intended to be. */ @@ -628,23 +619,6 @@ done: * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * Raymond Lu - * Thursday, November 18, 2004 - * When file is re-opened, member size passed in from access property - * is checked to see if it's reasonable. If there is only 1 member - * file, member size can't be smaller than current member size. - * If there are at least 2 member files, member size can only be equal - * the 1st member size. - * - * Raymond Lu - * Tuesday, May 24, 2005 - * The modification described above has been changed. The major checking - * is done in H5F_read_superblock. Member file size is saved in the - * superblock now. H5F_read_superblock() reads this saved size and compare - * to the size passed in from file access property. Wrong size will - * result in a failure. - * *------------------------------------------------------------------------- */ static H5FD_t * @@ -668,7 +642,7 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, /* Initialize file from file access properties */ if(NULL == (file = (H5FD_family_t *)H5MM_calloc(sizeof(H5FD_family_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct") - if(H5P_FILE_ACCESS_DEFAULT==fapl_id) { + if(H5P_FILE_ACCESS_DEFAULT == fapl_id) { file->memb_fapl_id = H5P_FILE_ACCESS_DEFAULT; if(H5I_inc_ref(file->memb_fapl_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") @@ -678,11 +652,11 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, } /* end if */ else { H5P_genplist_t *plist; /* Property list pointer */ - H5FD_family_fapl_t *fa; + const H5FD_family_fapl_t *fa; if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (H5FD_family_fapl_t *)H5P_get_driver_info(plist))) + if(NULL == (fa = (const H5FD_family_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Check for new family file size. It's used by h5repart only. */ @@ -695,8 +669,8 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, file->repart_members = TRUE; } /* end if */ - if(fa->memb_fapl_id==H5P_FILE_ACCESS_DEFAULT) { - if(H5I_inc_ref(fa->memb_fapl_id, FALSE)<0) + if(fa->memb_fapl_id == H5P_FILE_ACCESS_DEFAULT) { + if(H5I_inc_ref(fa->memb_fapl_id, FALSE) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") file->memb_fapl_id = fa->memb_fapl_id; } /* end if */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 0e9b449..7e1342a 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -473,7 +473,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) { H5FD_log_t *file = NULL; H5P_genplist_t *plist; /* Property list */ - H5FD_log_fapl_t *fa; /* File access property list information */ + const H5FD_log_fapl_t *fa; /* File access property list information */ int fd = -1; /* File descriptor */ int o_flags; /* Flags for open() call */ #ifdef H5_HAVE_WIN32_API @@ -512,7 +512,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) /* Get the driver specific information */ if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(NULL == (fa = (H5FD_log_fapl_t *)H5P_get_driver_info(plist))) + if(NULL == (fa = (const H5FD_log_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") #ifdef H5_HAVE_GETTIMEOFDAY diff --git a/src/H5FDmpi.c b/src/H5FDmpi.c index 86a5d39..fdc4eca 100644 --- a/src/H5FDmpi.c +++ b/src/H5FDmpi.c @@ -452,24 +452,13 @@ done: * Programmer: Robb Matzke * Monday, August 9, 1999 * - * Modifications: - * - * Quincey Koziol - 2002/06/17 - * Removed 'disp' parameter, read & write routines will use - * the address of the dataset in MPI_File_set_view() calls, as - * necessary. - * - * Quincey Koziol - 2002/06/17 - * Changed to set temporary properties in a dxpl, instead of - * flags in the file struct, which will make this more threadsafe. - * *------------------------------------------------------------------------- */ herr_t H5FD_mpi_setup_collective(hid_t dxpl_id, MPI_Datatype *btype, MPI_Datatype *ftype) { H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index b696f38..eb8e70f 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -304,33 +304,6 @@ H5FD_mpio_term(void) * Programmer: Albert Cheng * Feb 3, 1998 * - * Modifications: - * Robb Matzke, 1998-02-18 - * Check all arguments before the property list is updated so we - * don't leave the property list in a bad state if something - * goes wrong. Also, the property list data type changed to - * allow more generality so all the mpi-related stuff is in the - * `u.mpi' member. The `access_mode' will contain only - * mpi-related flags defined in H5Fpublic.h. - * - * Albert Cheng, 1998-04-16 - * Removed the ACCESS_MODE argument. The access mode is changed - * to be controlled by data transfer property list during data - * read/write calls. - * - * Robb Matzke, 1999-08-06 - * Modified to work with the virtual file layer. - * - * Raymond Lu, 2001-10-23 - * Changed the file access list to the new generic property - * list. - * - * Albert Cheng, 2003-04-17 - * Modified the description of the function that it now stores - * a duplicate of the communicator and INFO object. Free the - * old duplicates if previously set. (Work is actually done - * by H5P_set_driver.) - * *------------------------------------------------------------------------- */ herr_t @@ -357,11 +330,11 @@ H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info) fa.info = info; /* duplication is done during driver setting. */ - ret_value= H5P_set_driver(plist, H5FD_MPIO, &fa); + ret_value = H5P_set_driver(plist, H5FD_MPIO, &fa); done: FUNC_LEAVE_API(ret_value) -} +} /* H5Pset_fapl_mpio() */ /*------------------------------------------------------------------------- @@ -386,71 +359,60 @@ done: * Programmer: Robb Matzke * Thursday, February 26, 1998 * - * Modifications: - * - * Albert Cheng, Apr 16, 1998 - * Removed the access_mode argument. The access_mode is changed - * to be controlled by data transfer property list during data - * read/write calls. - * - * Raymond Lu, 2001-10-23 - * Changed the file access list to the new generic property - * list. - * - * Albert Cheng, 2003-04-17 - * Return duplicates of the stored communicator and Info object. - * *------------------------------------------------------------------------- */ herr_t H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/) { - H5FD_mpio_fapl_t *fa; H5P_genplist_t *plist; /* Property list pointer */ - MPI_Comm comm_tmp=MPI_COMM_NULL; - int mpi_code; /* mpi return code */ - herr_t ret_value=SUCCEED; /* Return value */ + const H5FD_mpio_fapl_t *fa; /* MPIO fapl info */ + MPI_Comm comm_tmp = MPI_COMM_NULL; + hbool_t comm_copied = FALSE; /* MPI Comm has been duplicated */ + int mpi_code; /* MPI return code */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, comm, info); if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list") - if(H5FD_MPIO != H5P_get_driver(plist)) + if(H5FD_MPIO != H5P_peek_driver(plist)) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") - if(NULL == (fa = (H5FD_mpio_fapl_t *)H5P_get_driver_info(plist))) + if(NULL == (fa = (const H5FD_mpio_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") /* Store the duplicated communicator in a temporary variable for error */ - /* recovery in case the INFO duplication fails. We cannot attempt to */ - /* the value into *comm yet since if MPI_Comm_dup fails, we will end */ - /* up freeing whatever *comm holds and that could be invalid. */ - if (comm){ - if (MPI_SUCCESS != (mpi_code=MPI_Comm_dup(fa->comm, &comm_tmp))) + /* recovery in case the INFO duplication fails. */ + if(comm) { + if(MPI_SUCCESS != (mpi_code = MPI_Comm_dup(fa->comm, &comm_tmp))) HMPI_GOTO_ERROR(FAIL, "MPI_Comm_dup failed", mpi_code) - } + comm_copied = TRUE; + } /* end if */ - if (info){ - if (MPI_INFO_NULL != fa->info){ - if (MPI_SUCCESS != (mpi_code=MPI_Info_dup(fa->info, info))) + if(info) { + if(MPI_INFO_NULL != fa->info) { + if(MPI_SUCCESS != (mpi_code = MPI_Info_dup(fa->info, info))) HMPI_GOTO_ERROR(FAIL, "MPI_Info_dup failed", mpi_code) - }else{ + } /* end if */ + else /* do not dup it */ *info = MPI_INFO_NULL; - } - } + } /* end if */ - if (comm) + /* Store the copied communicator, now that the Info object has been + * successfully copied. + */ + if(comm) *comm = comm_tmp; done: - if (FAIL==ret_value){ + if(ret_value < 0) /* need to free anything created here */ - if (comm_tmp != MPI_COMM_NULL) + if(comm_copied) MPI_Comm_free(&comm_tmp); - } + FUNC_LEAVE_API(ret_value) -} +} /* end H5Pget_fapl_mpio() */ /*------------------------------------------------------------------------- @@ -965,32 +927,6 @@ done: * Programmer: * January 30, 1998 * - * Modifications: - * Robb Matzke, 1998-02-18 - * Added the ACCESS_PARMS argument. Moved some error checking - * here from elsewhere. - * - * rky, 1998-01-11 - * Added H5FD_mpio_Debug debug flags controlled by MPI_Info. - * - * rky, 1998-08-28 - * Init flag controlling redundant metadata writes to disk. - * - * rky, 1998-12-07 - * Added barrier after MPI_File_set_size to prevent race - * condition -- subsequent writes were being truncated, causing - * holes in file. - * - * Robb Matzke, 1999-08-06 - * Modified to work with the virtual file layer. - * - * rky & ppw, 1999-11-07 - * Modified "H5FD_mpio_open" so that file-truncation is - * avoided for brand-new files (with zero filesize). - * - * Albert Cheng, 2003-04-17 - * Duplicate the communicator and Info object so that file is - * insulated from the old one. *------------------------------------------------------------------------- */ static H5FD_t * @@ -1005,11 +941,11 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, int mpi_size; /* Total number of MPI processes */ int mpi_code; /* mpi return code */ MPI_Offset size; - const H5FD_mpio_fapl_t *fa=NULL; + const H5FD_mpio_fapl_t *fa = NULL; H5FD_mpio_fapl_t _fa; H5P_genplist_t *plist; /* Property list pointer */ - MPI_Comm comm_dup=MPI_COMM_NULL; - MPI_Info info_dup=MPI_INFO_NULL; + MPI_Comm comm_dup = MPI_COMM_NULL; + MPI_Info info_dup = MPI_INFO_NULL; H5FD_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1024,39 +960,42 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id, /* Obtain a pointer to mpio-specific file access properties */ if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MPIO != H5P_get_driver(plist)) { + if(H5P_FILE_ACCESS_DEFAULT == fapl_id || H5FD_MPIO != H5P_peek_driver(plist)) { _fa.comm = MPI_COMM_SELF; /*default*/ _fa.info = MPI_INFO_NULL; /*default*/ fa = &_fa; - } else { - if(NULL == (fa = (const H5FD_mpio_fapl_t *)H5P_get_driver_info(plist))) + } /* end if */ + else { + if(NULL == (fa = (const H5FD_mpio_fapl_t *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") - } + } /* end else */ /* Duplicate communicator and Info object for use by this file. */ - if (FAIL==H5FD_mpi_comm_info_dup(fa->comm, fa->info, &comm_dup, &info_dup)) + if(FAIL == H5FD_mpi_comm_info_dup(fa->comm, fa->info, &comm_dup, &info_dup)) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOPY, NULL, "Communicator/Info duplicate failed") /* convert HDF5 flags to MPI-IO flags */ /* some combinations are illegal; let MPI-IO figure it out */ - mpi_amode = (flags&H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY; - if (flags&H5F_ACC_CREAT) mpi_amode |= MPI_MODE_CREATE; - if (flags&H5F_ACC_EXCL) mpi_amode |= MPI_MODE_EXCL; + mpi_amode = (flags & H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY; + if(flags & H5F_ACC_CREAT) + mpi_amode |= MPI_MODE_CREATE; + if(flags & H5F_ACC_EXCL) + mpi_amode |= MPI_MODE_EXCL; #ifdef H5FDmpio_DEBUG /* Check for debug commands in the info parameter */ { - char debug_str[128]; - int flag, i; - if (MPI_INFO_NULL != info_dup) { - MPI_Info_get(fa->info, H5F_MPIO_DEBUG_KEY, sizeof(debug_str)-1, debug_str, &flag); - if (flag) { - fprintf(stdout, "H5FD_mpio debug flags=%s\n", debug_str ); - for (i=0; - debug_str[i]/*end of string*/ && i<128/*just in case*/; - ++i) { + if(MPI_INFO_NULL != info_dup) { + char debug_str[128]; + int flag; + + MPI_Info_get(fa->info, H5F_MPIO_DEBUG_KEY, sizeof(debug_str) - 1, debug_str, &flag); + if(flag) { + int i; + + fprintf(stdout, "H5FD_mpio debug flags = '%s'\n", debug_str); + for(i = 0; debug_str[i]/*end of string*/ && i < 128/*just in case*/; ++i) H5FD_mpio_Debug[(int)debug_str[i]] = 1; - } } } } @@ -1523,21 +1462,21 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t dxpl_id, had use_view_this_time = TRUE; /* prepare for a full-blown xfer using btype, ftype, and disp */ - if(H5P_get(plist, H5FD_MPI_XFER_MEM_MPI_TYPE_NAME, &buf_type)<0) + if(H5P_get(plist, H5FD_MPI_XFER_MEM_MPI_TYPE_NAME, &buf_type) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") - if(H5P_get(plist, H5FD_MPI_XFER_FILE_MPI_TYPE_NAME, &file_type)<0) + if(H5P_get(plist, H5FD_MPI_XFER_FILE_MPI_TYPE_NAME, &file_type) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O type property") /* * Set the file view when we are using MPI derived types */ - if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, H5FD_mpi_native_g, file->info))) + if(MPI_SUCCESS != (mpi_code = MPI_File_set_view(file->f, mpi_off, MPI_BYTE, file_type, H5FD_mpi_native_g, file->info))) HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code) /* When using types, use the address as the displacement for * MPI_File_set_view and reset the address for the read to zero */ - mpi_off=0; + mpi_off = 0; } /* end if */ } /* end if */ @@ -1553,7 +1492,7 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t dxpl_id, had HDassert(plist); /* get the transfer mode from the dxpl */ - if(H5P_get(plist, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, &coll_opt_mode)<0) + if(H5P_get(plist, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, &coll_opt_mode) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get MPI-I/O collective_op property") if(coll_opt_mode == H5FD_MPIO_COLLECTIVE_IO) { diff --git a/src/H5FDprivate.h b/src/H5FDprivate.h index 4083aa8..2c18659 100644 --- a/src/H5FDprivate.h +++ b/src/H5FDprivate.h @@ -90,6 +90,12 @@ typedef struct { } \ } +/* Define structure to hold driver ID & info for FAPLs */ +typedef struct { + hid_t driver_id; /* Driver's ID */ + const void *driver_info; /* Driver info, for open callbacks */ +} H5FD_driver_prop_t; + /*****************************/ /* Library Private Variables */ @@ -111,8 +117,7 @@ H5_DLL hsize_t H5FD_sb_size(H5FD_t *file); H5_DLL herr_t H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf); H5_DLL herr_t H5FD_sb_load(H5FD_t *file, const char *name, const uint8_t *buf); H5_DLL void *H5FD_fapl_get(H5FD_t *file); -H5_DLL herr_t H5FD_fapl_open(struct H5P_genplist_t *plist, hid_t driver_id, const void *driver_info); -H5_DLL herr_t H5FD_fapl_close(hid_t driver_id, void *fapl); +H5_DLL herr_t H5FD_fapl_close(hid_t driver_id, const void *fapl); H5_DLL hid_t H5FD_register(const void *cls, size_t size, hbool_t app_ref); H5_DLL H5FD_t *H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); diff --git a/src/H5Fefc.c b/src/H5Fefc.c index 9916002..8aa9079 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -162,8 +162,7 @@ H5F_efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, * support this so clients do not have to make 2 different calls depending * on the state of the efc. */ if(!efc) { - if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id, - dxpl_id))) + if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") /* Increment the number of open objects to prevent the file from being @@ -235,8 +234,7 @@ H5F_efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, } /* end if */ else { /* Cannot cache file, just open file and return */ - if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id, - dxpl_id))) + if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") /* Increment the number of open objects to prevent the file from @@ -257,8 +255,7 @@ H5F_efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Open the file */ - if(NULL == (ent->file = H5F_open(name, flags, fcpl_id, fapl_id, - dxpl_id))) + if(NULL == (ent->file = H5F_open(name, flags, fcpl_id, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") open_file = TRUE; diff --git a/src/H5Fint.c b/src/H5Fint.c index 3410036..ae0b3ba 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -154,10 +154,11 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) { H5P_genplist_t *new_plist; /* New property list */ H5P_genplist_t *old_plist; /* Old property list */ - void *driver_info=NULL; - unsigned efc_size = 0; H5F_object_flush_t flush_info; /* Object flush property values */ - hid_t ret_value = SUCCEED; + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */ + unsigned efc_size = 0; + hid_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -211,32 +212,26 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) if(H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set elink file cache size") - /* - * Since we're resetting the driver ID and info, close them if they - * exist in this new property list. - */ - if(H5P_facc_close(ret_value, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't free the old driver information") - - /* Increment the reference count on the driver ID and insert it into the property list */ - if(H5I_inc_ref(f->shared->lf->driver_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") - if(H5P_set(new_plist, H5F_ACS_FILE_DRV_ID_NAME, &(f->shared->lf->driver_id)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID") + /* Prepare the driver property */ + driver_prop.driver_id = f->shared->lf->driver_id; + driver_prop.driver_info = H5FD_fapl_get(f->shared->lf); + driver_prop_copied = TRUE; - /* Set the driver "info" in the property list */ - driver_info = H5FD_fapl_get(f->shared->lf); - if(driver_info != NULL && H5P_set(new_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver info") + /* Set the driver property */ + if(H5P_set(new_plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID & info") /* Set the file close degree appropriately */ - if(f->shared->fc_degree == H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) { + if(f->shared->fc_degree == H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") - } else if(f->shared->fc_degree != H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0) { + else if(f->shared->fc_degree != H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") - } done: + /* Release the copy of the driver info, if it was set up */ + if(driver_prop_copied && H5FD_fapl_close(driver_prop.driver_id, driver_prop.driver_info) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close copy of driver info") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_access_plist() */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 3942c5c..c2d2d0e 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -444,8 +444,7 @@ #define H5F_ACS_SIEVE_BUF_SIZE_NAME "sieve_buf_size" /* Maximum sieve buffer size (when data sieving is allowed by file driver) */ #define H5F_ACS_SDATA_BLOCK_SIZE_NAME "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data allocations) */ #define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ -#define H5F_ACS_FILE_DRV_ID_NAME "driver_id" /* File driver ID */ -#define H5F_ACS_FILE_DRV_INFO_NAME "driver_info" /* File driver info */ +#define H5F_ACS_FILE_DRV_NAME "driver-id/info" /* File driver ID & info */ #define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ #define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ #define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ @@ -715,9 +714,6 @@ H5_DLL void H5F_addr_encode_len(size_t addr_len, uint8_t **pp, haddr_t addr); H5_DLL void H5F_addr_decode(const H5F_t *f, const uint8_t **pp, haddr_t *addr_p); H5_DLL void H5F_addr_decode_len(size_t addr_len, const uint8_t **pp, haddr_t *addr_p); -/* File access property list callbacks */ -H5_DLL herr_t H5P_facc_close(hid_t dxpl_id, void *close_data); - /* Shared file list related routines */ H5_DLL void H5F_sfile_assert_num(unsigned n); diff --git a/src/H5Gobj.c b/src/H5Gobj.c index 7e9d183..6c7b488 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -156,7 +156,7 @@ H5G__obj_create(H5F_t *f, hid_t dxpl_id, H5G_obj_create_t *gcrt_info, HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get group info") /* Get the pipeline property */ - if(H5P_get(gc_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(gc_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get group info") /* Call the "real" group creation routine now */ diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 570719d..bbdad12 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -254,7 +254,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get parent's file access property list") /* Get callback_info */ - if(H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info)<0) + if(H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get elink callback info") /* Get file access property list */ @@ -279,7 +279,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, /* Check if we need to allocate larger buffer */ if((size_t)group_name_len > sizeof(local_group_name)) { if(NULL == (parent_group_name = (char *)H5MM_malloc((size_t)group_name_len))) - HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, FAIL, "can't allocate buffer to hold group name, group_name_len = %Zu", group_name_len) + HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, FAIL, "can't allocate buffer to hold group name, group_name_len = %zd", group_name_len) } /* end if */ else parent_group_name = local_group_name; @@ -378,7 +378,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, /* try searching from property list */ if(ext_file == NULL) { - if(H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) + if(H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix") if(my_prefix) { if(H5L_build_name(my_prefix, temp_file_name, &full_name/*out*/) < 0) diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index a315842..f205e74 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -1106,7 +1106,7 @@ H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object copy flag") /* Retrieve the marge committed datatype list */ - if(H5P_get(ocpy_plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) + if(H5P_peek(ocpy_plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get merge committed datatype list") /* Get callback info */ diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 7337c75..a6b51e6 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -258,64 +258,47 @@ H5O_efl_copy(const void *_mesg, void *_dest) { const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg; H5O_efl_t *dest = (H5O_efl_t *) _dest; - size_t u; /* Local index variable */ - void *ret_value; /* Return value */ + size_t u; /* Local index variable */ + hbool_t slot_allocated = FALSE; /* Flag to indicate that dynamic allocation has begun */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* check args */ HDassert(mesg); - if(!dest) { - if(NULL == (dest = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message") - if(NULL == (dest->slot = (H5O_efl_entry_t *)H5MM_calloc(mesg->nalloc * sizeof(H5O_efl_entry_t)))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slots") - } /* end if */ - else if(dest->nalloc < mesg->nalloc) { - H5O_efl_entry_t *temp_slot; /* Temporary pointer to new slot information */ - /* Allocate new 'slot' information */ - if(NULL == (temp_slot = (H5O_efl_entry_t *)H5MM_calloc(mesg->nalloc * sizeof(H5O_efl_entry_t)))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slots") + /* Allocate destination message, if necessary */ + if(!dest && NULL == (dest = (H5O_efl_t *)H5MM_calloc(sizeof(H5O_efl_t)))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message") - /* Release old 'slot' information */ - for(u = 0; u < dest->nused; u++) - dest->slot[u].name = (char *)H5MM_xfree(dest->slot[u].name); - dest->slot = (H5O_efl_entry_t *)H5MM_xfree(dest->slot); + /* copy */ + *dest = *mesg; - /* Point to new 'slot' information */ - dest->slot = temp_slot; + /* Deep copy allocated information */ + if(dest->nalloc > 0) { + if(NULL == (dest->slot = (H5O_efl_entry_t *)H5MM_calloc(dest->nalloc * sizeof(H5O_efl_entry_t)))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slots") + slot_allocated = TRUE; + for(u = 0; u < mesg->nused; u++) { + dest->slot[u] = mesg->slot[u]; + if(NULL == (dest->slot[u].name = H5MM_xstrdup(mesg->slot[u].name))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slot name") + } /* end for */ } /* end if */ - else { - /* Release old 'slot' information */ - for(u = 0; u < dest->nused; u++) - dest->slot[u].name = (char *)H5MM_xfree(dest->slot[u].name); - } /* end else */ - dest->heap_addr = mesg->heap_addr; - dest->nalloc = mesg->nalloc; - dest->nused = mesg->nused; - - for(u = 0; u < mesg->nused; u++) { - dest->slot[u] = mesg->slot[u]; - if(NULL == (dest->slot[u].name = H5MM_xstrdup(mesg->slot[u].name))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "can't allocate efl message slot name") - } /* end for */ /* Set return value */ ret_value = dest; done: if(NULL == ret_value) { - if(dest && NULL == _dest) { - if(dest->slot) { - for(u = 0; u < mesg->nused; u++) { - if(dest->slot[u].name != NULL && dest->slot[u].name != mesg->slot[u].name) - dest->slot[u].name = (char *)H5MM_xfree(dest->slot[u].name); - } /* end for */ - dest->slot = (H5O_efl_entry_t *)H5MM_xfree(dest->slot); - } /* end if */ - dest = (H5O_efl_t *)H5MM_xfree(dest); + if(slot_allocated) { + for(u = 0; u < dest->nused; u++) + if(dest->slot[u].name != NULL && dest->slot[u].name != mesg->slot[u].name) + dest->slot[u].name = (char *)H5MM_xfree(dest->slot[u].name); + dest->slot = (H5O_efl_entry_t *)H5MM_xfree(dest->slot); } /* end if */ + if(NULL == _dest) + dest = (H5O_efl_t *)H5MM_xfree(dest); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -389,8 +372,10 @@ H5O_efl_reset(void *_mesg) /* reset */ if(mesg->slot) { - for(u = 0; u < mesg->nused; u++) + for(u = 0; u < mesg->nused; u++) { mesg->slot[u].name = (char *)H5MM_xfree(mesg->slot[u].name); + mesg->slot[u].name_offset = 0; + } /* end for */ mesg->slot = (H5O_efl_entry_t *)H5MM_xfree(mesg->slot); } /* end if */ mesg->heap_addr = HADDR_UNDEF; diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 7a19c77..c67cddb 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -566,6 +566,9 @@ H5O_layout_copy(const void *_mesg, void *_dest) case H5D_COMPACT: /* Deep copy the buffer for compact datasets also */ if(mesg->storage.u.compact.size > 0) { + /* Sanity check */ + HDassert(mesg->storage.u.compact.buf); + /* Allocate memory for the raw data */ if(NULL == (dest->storage.u.compact.buf = H5MM_malloc(dest->storage.u.compact.size))) HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, NULL, "unable to allocate memory for compact dataset") @@ -662,13 +665,13 @@ H5O_layout_reset(void *_mesg) if(mesg) { /* Reset associated storage information, if it's been initialized */ - if(H5D_LAYOUT_ERROR != mesg->storage.type) { + if(H5D_LAYOUT_ERROR != mesg->storage.type) if(H5O_storage_reset(&mesg->storage) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to free message resources") - } /* end if */ /* Reset the message */ mesg->type = H5D_CONTIGUOUS; + mesg->version = H5O_LAYOUT_VERSION_DEFAULT; } /* end if */ done: diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 7514b3e..8790780 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -404,6 +404,9 @@ typedef struct H5O_efl_t { */ #define H5O_LAYOUT_VERSION_4 4 +/* The default version of the format. (Earlier versions had bugs) */ +#define H5O_LAYOUT_VERSION_DEFAULT H5O_LAYOUT_VERSION_3 + /* The latest version of the format. Look through the 'encode' * and 'size' callbacks for places to change when updating this. */ #define H5O_LAYOUT_VERSION_LATEST H5O_LAYOUT_VERSION_4 diff --git a/src/H5P.c b/src/H5P.c index ff230ed..cc73eda 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -1395,7 +1395,7 @@ H5Premove(hid_t plist_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); /* Create the new property list class */ - if((ret_value = H5P_remove(plist_id,plist,name)) < 0) + if((ret_value = H5P_remove(plist, name)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property"); done: diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index fe68c11..f180938 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -164,6 +164,7 @@ H5P__dacc_reg_prop(H5P_genclass_t *pclass) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register info for append flush */ + /* (Note: this property should not have an encode/decode callback -QAK) */ if(H5P_register_real(pclass, H5D_ACS_APPEND_FLUSH_NAME, H5D_ACS_APPEND_FLUSH_SIZE, &H5D_def_append_flush_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 3e87c33..4c1892d 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -60,34 +60,44 @@ #define H5D_DEF_STORAGE_COMPACT {H5D_COMPACT, { .compact = H5D_DEF_STORAGE_COMPACT_INIT }} #define H5D_DEF_STORAGE_CONTIG {H5D_CONTIGUOUS, { .contig = H5D_DEF_STORAGE_CONTIG_INIT }} #define H5D_DEF_STORAGE_CHUNK {H5D_CHUNKED, { .chunk = H5D_DEF_STORAGE_CHUNK_INIT }} -#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, H5D_LOPS_COMPACT, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_COMPACT} -#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, H5D_LOPS_CONTIG, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CONTIG} -#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_3, H5D_LOPS_CHUNK, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CHUNK} +#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_COMPACT, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_COMPACT} +#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CONTIG, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CONTIG} +#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CHUNK, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CHUNK} #else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Note that the compact & chunked layout initialization values are using the * contiguous layout initialization in the union, because the contiguous * layout is first in the union. These values are overridden in the * H5P__init_def_layout() routine. -QAK */ -#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* ======== Dataset creation properties ======== */ /* Definitions for storage layout property */ #define H5D_CRT_LAYOUT_SIZE sizeof(H5O_layout_t) #define H5D_CRT_LAYOUT_DEF H5D_DEF_LAYOUT_CONTIG +#define H5D_CRT_LAYOUT_SET H5P__dcrt_layout_set +#define H5D_CRT_LAYOUT_GET H5P__dcrt_layout_get #define H5D_CRT_LAYOUT_ENC H5P__dcrt_layout_enc #define H5D_CRT_LAYOUT_DEC H5P__dcrt_layout_dec +#define H5D_CRT_LAYOUT_DEL H5P__dcrt_layout_del +#define H5D_CRT_LAYOUT_COPY H5P__dcrt_layout_copy #define H5D_CRT_LAYOUT_CMP H5P__dcrt_layout_cmp +#define H5D_CRT_LAYOUT_CLOSE H5P__dcrt_layout_close /* Definitions for fill value. size=0 means fill value will be 0 as * library default; size=-1 means fill value is undefined. */ #define H5D_CRT_FILL_VALUE_SIZE sizeof(H5O_fill_t) #define H5D_CRT_FILL_VALUE_DEF {{0, NULL, H5O_NULL_ID, {{0, HADDR_UNDEF}}}, H5O_FILL_VERSION_2, NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_FILL_TIME_IFSET, FALSE} -#define H5D_CRT_FILL_VALUE_ENC H5P__fill_value_enc -#define H5D_CRT_FILL_VALUE_DEC H5P__fill_value_dec +#define H5D_CRT_FILL_VALUE_SET H5P__dcrt_fill_value_set +#define H5D_CRT_FILL_VALUE_GET H5P__dcrt_fill_value_get +#define H5D_CRT_FILL_VALUE_ENC H5P__dcrt_fill_value_enc +#define H5D_CRT_FILL_VALUE_DEC H5P__dcrt_fill_value_dec +#define H5D_CRT_FILL_VALUE_DEL H5P__dcrt_fill_value_del +#define H5D_CRT_FILL_VALUE_COPY H5P__dcrt_fill_value_copy #define H5D_CRT_FILL_VALUE_CMP H5P_fill_value_cmp +#define H5D_CRT_FILL_VALUE_CLOSE H5P__dcrt_fill_value_close /* Definitions for space allocation time state */ #define H5D_CRT_ALLOC_TIME_STATE_SIZE sizeof(unsigned) #define H5D_CRT_ALLOC_TIME_STATE_DEF 1 @@ -96,9 +106,14 @@ /* Definitions for external file list */ #define H5D_CRT_EXT_FILE_LIST_SIZE sizeof(H5O_efl_t) #define H5D_CRT_EXT_FILE_LIST_DEF {HADDR_UNDEF, 0, 0, NULL} +#define H5D_CRT_EXT_FILE_LIST_SET H5P__dcrt_ext_file_list_set +#define H5D_CRT_EXT_FILE_LIST_GET H5P__dcrt_ext_file_list_get #define H5D_CRT_EXT_FILE_LIST_ENC H5P__dcrt_ext_file_list_enc #define H5D_CRT_EXT_FILE_LIST_DEC H5P__dcrt_ext_file_list_dec +#define H5D_CRT_EXT_FILE_LIST_DEL H5P__dcrt_ext_file_list_del +#define H5D_CRT_EXT_FILE_LIST_COPY H5P__dcrt_ext_file_list_copy #define H5D_CRT_EXT_FILE_LIST_CMP H5P__dcrt_ext_file_list_cmp +#define H5D_CRT_EXT_FILE_LIST_CLOSE H5P__dcrt_ext_file_list_close /******************/ @@ -123,18 +138,31 @@ static herr_t H5P__init_def_layout(void); /* Property class callbacks */ static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass); -static herr_t H5P__dcrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); -static herr_t H5P__dcrt_close(hid_t dxpl_id, void *close_data); /* Property callbacks */ +static herr_t H5P__dcrt_layout_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dcrt_layout_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dcrt_layout_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dcrt_layout_dec(const void **pp, void *value); +static herr_t H5P__dcrt_layout_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dcrt_layout_copy(const char *name, size_t size, void *value); static int H5P__dcrt_layout_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P__fill_value_enc(const void *value, void **pp, size_t *size); -static herr_t H5P__fill_value_dec(const void **pp, void *value); +static herr_t H5P__dcrt_layout_close(const char *name, size_t size, void *value); +static herr_t H5P__dcrt_fill_value_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dcrt_fill_value_get(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dcrt_fill_value_enc(const void *value, void **pp, size_t *size); +static herr_t H5P__dcrt_fill_value_dec(const void **pp, void *value); +static herr_t H5P__dcrt_fill_value_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dcrt_fill_value_copy(const char *name, size_t size, void *value); +static herr_t H5P__dcrt_fill_value_close(const char *name, size_t size, void *value); +static herr_t H5P__dcrt_ext_file_list_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dcrt_ext_file_list_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__dcrt_ext_file_list_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dcrt_ext_file_list_dec(const void **pp, void *value); +static herr_t H5P__dcrt_ext_file_list_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__dcrt_ext_file_list_copy(const char *name, size_t size, void *value); static int H5P__dcrt_ext_file_list_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__dcrt_ext_file_list_close(const char *name, size_t size, void *value); /*********************/ @@ -154,9 +182,9 @@ const H5P_libclass_t H5P_CLS_DCRT[1] = {{ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ - H5P__dcrt_copy, /* Class copy callback */ + NULL, /* Class copy callback */ NULL, /* Class copy callback info */ - H5P__dcrt_close, /* Class close callback */ + NULL, /* Class close callback */ NULL /* Class close callback info */ }}; @@ -213,14 +241,14 @@ H5P__dcrt_reg_prop(H5P_genclass_t *pclass) /* Register the storage layout property */ if(H5P_register_real(pclass, H5D_CRT_LAYOUT_NAME, H5D_CRT_LAYOUT_SIZE, &H5D_def_layout_g, - NULL, NULL, NULL, H5D_CRT_LAYOUT_ENC, H5D_CRT_LAYOUT_DEC, - NULL, NULL, H5D_CRT_LAYOUT_CMP, NULL) < 0) + NULL, H5D_CRT_LAYOUT_SET, H5D_CRT_LAYOUT_GET, H5D_CRT_LAYOUT_ENC, H5D_CRT_LAYOUT_DEC, + H5D_CRT_LAYOUT_DEL, H5D_CRT_LAYOUT_COPY, H5D_CRT_LAYOUT_CMP, H5D_CRT_LAYOUT_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the fill value property */ if(H5P_register_real(pclass, H5D_CRT_FILL_VALUE_NAME, H5D_CRT_FILL_VALUE_SIZE, &H5D_def_fill_g, - NULL, NULL, NULL, H5D_CRT_FILL_VALUE_ENC, H5D_CRT_FILL_VALUE_DEC, - NULL, NULL, H5D_CRT_FILL_VALUE_CMP, NULL) < 0) + NULL, H5D_CRT_FILL_VALUE_SET, H5D_CRT_FILL_VALUE_GET, H5D_CRT_FILL_VALUE_ENC, H5D_CRT_FILL_VALUE_DEC, + H5D_CRT_FILL_VALUE_DEL, H5D_CRT_FILL_VALUE_COPY, H5D_CRT_FILL_VALUE_CMP, H5D_CRT_FILL_VALUE_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the space allocation time state property */ @@ -231,8 +259,8 @@ H5P__dcrt_reg_prop(H5P_genclass_t *pclass) /* Register the external file list property */ if(H5P_register_real(pclass, H5D_CRT_EXT_FILE_LIST_NAME, H5D_CRT_EXT_FILE_LIST_SIZE, &H5D_def_efl_g, - NULL, NULL, NULL, H5D_CRT_EXT_FILE_LIST_ENC, H5D_CRT_EXT_FILE_LIST_DEC, - NULL, NULL, H5D_CRT_EXT_FILE_LIST_CMP, NULL) < 0) + NULL, H5D_CRT_EXT_FILE_LIST_SET, H5D_CRT_EXT_FILE_LIST_GET, H5D_CRT_EXT_FILE_LIST_ENC, H5D_CRT_EXT_FILE_LIST_DEC, + H5D_CRT_EXT_FILE_LIST_DEL, H5D_CRT_EXT_FILE_LIST_COPY, H5D_CRT_EXT_FILE_LIST_CMP, H5D_CRT_EXT_FILE_LIST_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: @@ -241,165 +269,79 @@ done: /*------------------------------------------------------------------------- - * Function: H5P__dcrt_copy + * Function: H5P__dcrt_layout_set * - * Purpose: Callback routine which is called whenever any dataset - * creation property list is copied. This routine copies - * the properties from the old list to the new list. + * Purpose: Copies a layout property when it's set for a property list * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Raymond Lu - * Tuesday, October 2, 2001 + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t -H5P__dcrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void H5_ATTR_UNUSED *copy_data) +H5P__dcrt_layout_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - H5O_fill_t src_fill, dst_fill; /* Source & destination fill values */ - H5O_efl_t src_efl, dst_efl; /* Source & destination external file lists */ - H5O_layout_t src_layout, dst_layout; /* Source & destination layout */ - H5P_genplist_t *src_plist; /* Pointer to source property list */ - H5P_genplist_t *dst_plist; /* Pointer to destination property list */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ + H5O_layout_t new_layout; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - /* Verify property list IDs */ - if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") - if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") - - /* Get the layout, fill value, external file list, and data pipeline - * properties from the old property list - */ - if(H5P_get(src_plist, H5D_CRT_LAYOUT_NAME, &src_layout) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") - if(H5P_get(src_plist, H5D_CRT_FILL_VALUE_NAME, &src_fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") - if(H5P_get(src_plist, H5D_CRT_EXT_FILE_LIST_NAME, &src_efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") + /* Sanity check */ + HDassert(value); /* Make copy of layout */ - if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, &src_layout, &dst_layout)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy layout") - - /* Reset layout values set when dataset is created */ - dst_layout.ops = NULL; - switch(dst_layout.type) { - case H5D_COMPACT: - dst_layout.storage.u.compact.buf = H5MM_xfree(dst_layout.storage.u.compact.buf); - HDmemset(&dst_layout.storage.u.compact, 0, sizeof(dst_layout.storage.u.compact)); - break; - - case H5D_CONTIGUOUS: - dst_layout.storage.u.contig.addr = HADDR_UNDEF; - dst_layout.storage.u.contig.size = 0; - break; - - case H5D_CHUNKED: - /* Reset chunk size */ - dst_layout.u.chunk.size = 0; - - /* Reset index info, if the chunk ops are set */ - if(dst_layout.storage.u.chunk.ops) - /* Reset address and pointer of the array struct for the chunked storage index */ - if(H5D_chunk_idx_reset(&dst_layout.storage.u.chunk, TRUE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") - - /* Reset chunk index ops */ - dst_layout.storage.u.chunk.ops = NULL; - break; - - case H5D_LAYOUT_ERROR: - case H5D_NLAYOUTS: - default: - HDassert(0 && "Unknown layout type!"); - } /* end switch */ + if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy layout") - /* Make copy of fill value */ - if(NULL == H5O_msg_copy(H5O_FILL_ID, &src_fill, &dst_fill)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy fill value") - - /* Make copy of external file list */ - HDmemset(&dst_efl, 0, sizeof(H5O_efl_t)); - if(NULL == H5O_msg_copy(H5O_EFL_ID, &src_efl, &dst_efl)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy external file list") - - /* Reset efl name_offset and heap_addr, these are the values when the dataset is created */ - if(dst_efl.slot) { - unsigned int i; - - dst_efl.heap_addr = HADDR_UNDEF; - for(i = 0; i < dst_efl.nused; i++) - dst_efl.slot[i].name_offset = 0; - } /* end if */ - - /* Set the layout, fill value, external file list, and data pipeline - * properties for the destination property list - */ - if(H5P_set(dst_plist, H5D_CRT_LAYOUT_NAME, &dst_layout) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") - if(H5P_set(dst_plist, H5D_CRT_FILL_VALUE_NAME, &dst_fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") - if(H5P_set(dst_plist, H5D_CRT_EXT_FILE_LIST_NAME, &dst_efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list") + /* Copy new layout message over old one */ + *layout = new_layout; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__dcrt_copy() */ +} /* end H5P__dcrt_layout_set() */ /*------------------------------------------------------------------------- - * Function: H5P__dcrt_close + * Function: H5P__dcrt_layout_get * - * Purpose: Callback routine which is called whenever any dataset create - * property list is closed. This routine performs any generic - * cleanup needed on the properties the library put into the list. + * Purpose: Copies a layout property when it's retrieved from a property list * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Quincey Koziol - * Wednesday, July 11, 2001 + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t -H5P__dcrt_close(hid_t dcpl_id, void H5_ATTR_UNUSED *close_data) +H5P__dcrt_layout_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) { - H5O_fill_t fill; /* Fill value */ - H5O_efl_t efl; /* External file list */ - H5P_genplist_t *plist; /* Property list */ + H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ + H5O_layout_t new_layout; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC - /* Check arguments */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") + /* Sanity check */ + HDassert(value); - /* Get the fill value, external file list, and data pipeline properties - * from the old property list */ - if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") - if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") + /* Make copy of layout */ + if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy layout") - /* Clean up any values set for the fill-value and external file-list */ - if(H5O_msg_reset(H5O_FILL_ID, &fill) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release fill info") - if(H5O_msg_reset(H5O_EFL_ID, &efl) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release external file list info") + /* Copy new layout message over old one */ + *layout = new_layout; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__dcrt_close() */ +} /* end H5P__dcrt_layout_get() */ /*------------------------------------------------------------------------- @@ -547,6 +489,76 @@ done: /*------------------------------------------------------------------------- + * Function: H5P__dcrt_layout_del + * + * Purpose: Frees memory used to store the layout property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Tuesday, Feb 10, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_layout_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Reset the old layout */ + if(H5O_msg_reset(H5O_LAYOUT_ID, value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release layout message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_layout_del() */ + + +/*-------------------------------------------------------------------------- + * Function: H5P__dcrt_layout_copy + * + * Purpose: Copy the layout property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Monday, Feb 9, 2015 + * + *-------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_layout_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + H5O_layout_t *layout = (H5O_layout_t *)value; /* Create local aliases for values */ + H5O_layout_t new_layout; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(layout); + + /* Make copy of layout */ + if(NULL == H5O_msg_copy(H5O_LAYOUT_ID, layout, &new_layout)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy layout") + + /* Set new layout message directly into property list */ + *layout = new_layout; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_layout_copy() */ + + +/*------------------------------------------------------------------------- * Function: H5P__dcrt_layout_cmp * * Purpose: Callback routine which is called whenever the layout @@ -563,7 +575,8 @@ done: *------------------------------------------------------------------------- */ static int -H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t H5_ATTR_UNUSED size) +H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, + size_t H5_ATTR_UNUSED size) { const H5O_layout_t *layout1 = (const H5O_layout_t *)_layout1, /* Create local aliases for values */ *layout2 = (const H5O_layout_t *)_layout2; @@ -577,12 +590,16 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t H5_ATTR_ HDassert(size == sizeof(H5O_layout_t)); /* Check for different layout type */ - if(layout1->type < layout2->type) HGOTO_DONE(-1) - if(layout1->type > layout2->type) HGOTO_DONE(1) + if(layout1->type < layout2->type) + HGOTO_DONE(-1) + if(layout1->type > layout2->type) + HGOTO_DONE(1) /* Check for different layout version */ - if(layout1->version < layout2->version) HGOTO_DONE(-1) - if(layout1->version > layout2->version) HGOTO_DONE(1) + if(layout1->version < layout2->version) + HGOTO_DONE(-1) + if(layout1->version > layout2->version) + HGOTO_DONE(1) /* Compare non-dataset-specific fields in layout info */ switch(layout1->type) { @@ -595,13 +612,17 @@ H5P__dcrt_layout_cmp(const void *_layout1, const void *_layout2, size_t H5_ATTR_ unsigned u; /* Local index variable */ /* Check the number of dimensions */ - if(layout1->u.chunk.ndims < layout2->u.chunk.ndims) HGOTO_DONE(-1) - if(layout1->u.chunk.ndims > layout2->u.chunk.ndims) HGOTO_DONE(1) + if(layout1->u.chunk.ndims < layout2->u.chunk.ndims) + HGOTO_DONE(-1) + if(layout1->u.chunk.ndims > layout2->u.chunk.ndims) + HGOTO_DONE(1) /* Compare the chunk dims */ for(u = 0; u < layout1->u.chunk.ndims - 1; u++) { - if(layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u]) HGOTO_DONE(-1) - if(layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u]) HGOTO_DONE(1) + if(layout1->u.chunk.dim[u] < layout2->u.chunk.dim[u]) + HGOTO_DONE(-1) + if(layout1->u.chunk.dim[u] > layout2->u.chunk.dim[u]) + HGOTO_DONE(1) } /* end for */ } /* end case */ break; @@ -618,7 +639,116 @@ done: /*------------------------------------------------------------------------- - * Function: H5P__fill_value_enc + * Function: H5P__dcrt_layout_close + * + * Purpose: Frees memory used to store the layout property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Tuesday, Feb 10, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_layout_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Reset the old layout */ + if(H5O_msg_reset(H5O_LAYOUT_ID, value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release layout message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_layout_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__dcrt_fill_value_set + * + * Purpose: Copies a fill value property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_fill_value_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ + H5O_fill_t new_fill; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of fill value */ + if(NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy fill value") + + /* Copy new fill value message over old one */ + *fill = new_fill; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_fill_value_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__dcrt_fill_value_get + * + * Purpose: Copies a fill value property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_fill_value_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ + H5O_fill_t new_fill; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of fill value */ + if(NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy fill value") + + /* Copy new fill value message over old one */ + *fill = new_fill; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_fill_value_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__dcrt_fill_value_enc * * Purpose: Callback routine which is called whenever the fill value * property in the dataset creation property list is @@ -633,7 +763,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__fill_value_enc(const void *value, void **_pp, size_t *size) +H5P__dcrt_fill_value_enc(const void *value, void **_pp, size_t *size) { const H5O_fill_t *fill = (const H5O_fill_t *)value; /* Create local aliases for values */ size_t dt_size = 0; /* Size of encoded datatype */ @@ -709,11 +839,11 @@ H5P__fill_value_enc(const void *value, void **_pp, size_t *size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__fill_value_enc() */ +} /* end H5P__dcrt_fill_value_enc() */ /*------------------------------------------------------------------------- - * Function: H5P__fill_value_dec + * Function: H5P__dcrt_fill_value_dec * * Purpose: Callback routine which is called whenever the fill value * property in the dataset creation property list is @@ -728,7 +858,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P__fill_value_dec(const void **_pp, void *_value) +H5P__dcrt_fill_value_dec(const void **_pp, void *_value) { H5O_fill_t *fill = (H5O_fill_t *)_value; /* Fill value */ const uint8_t **pp = (const uint8_t **)_pp; @@ -776,7 +906,77 @@ H5P__fill_value_dec(const void **_pp, void *_value) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__fill_value_dec() */ +} /* end H5P__dcrt_fill_value_dec() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__dcrt_fill_value_del + * + * Purpose: Frees memory used to store the fill value property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Thursday, Feb 26, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_fill_value_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Reset the old fill value message */ + if(H5O_msg_reset(H5O_FILL_ID, value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release fill value message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_fill_value_del() */ + + +/*-------------------------------------------------------------------------- + * Function: H5P__dcrt_fill_value_copy + * + * Purpose: Copy the fill value property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Thursday, Feb 26, 2015 + * + *-------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_fill_value_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + H5O_fill_t *fill = (H5O_fill_t *)value; /* Create local aliases for values */ + H5O_fill_t new_fill; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(fill); + + /* Make copy of fill value message */ + if(NULL == H5O_msg_copy(H5O_FILL_ID, fill, &new_fill)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy fill value") + + /* Set new fill value message directly into property list */ + *fill = new_fill; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_fill_value_copy() */ /*------------------------------------------------------------------------- @@ -795,7 +995,8 @@ done: *------------------------------------------------------------------------- */ int -H5P_fill_value_cmp(const void *_fill1, const void *_fill2, size_t H5_ATTR_UNUSED size) +H5P_fill_value_cmp(const void *_fill1, const void *_fill2, + size_t H5_ATTR_UNUSED size) { const H5O_fill_t *fill1 = (const H5O_fill_t *)_fill1, /* Create local aliases for values */ *fill2 = (const H5O_fill_t *)_fill2; @@ -841,6 +1042,115 @@ done: /*------------------------------------------------------------------------- + * Function: H5P__dcrt_fill_value_close + * + * Purpose: Frees memory used to store the fill value property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Thursday, Feb 26, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_fill_value_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Reset the old fill value message */ + if(H5O_msg_reset(H5O_FILL_ID, value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release fill value message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_fill_value_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__dcrt_ext_file_list_set + * + * Purpose: Copies an external file list property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_ext_file_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ + H5O_efl_t new_efl; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of external file list */ + if(NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy external file list") + + /* Copy new external file list message over old one */ + *efl = new_efl; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_ext_file_list_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__dcrt_ext_file_list_get + * + * Purpose: Copies an external file lsit property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_ext_file_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ + H5O_efl_t new_efl; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of external file list */ + if(NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy external file list") + + /* Copy new external file list message over old one */ + *efl = new_efl; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_ext_file_list_get() */ + + +/*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_enc * * Purpose: Callback routine which is called whenever the efl @@ -1016,6 +1326,76 @@ done: /*------------------------------------------------------------------------- + * Function: H5P__dcrt_ext_file_list_del + * + * Purpose: Frees memory used to store the efl property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Thursday, Feb 26, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_ext_file_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Reset the old efl message */ + if(H5O_msg_reset(H5O_EFL_ID, value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release external file list message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_ext_file_list_del() */ + + +/*-------------------------------------------------------------------------- + * Function: H5P__dcrt_ext_file_list_copy + * + * Purpose: Copy the efl property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Thurday, Feb 26, 2015 + * + *-------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_ext_file_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + H5O_efl_t *efl = (H5O_efl_t *)value; /* Create local aliases for values */ + H5O_efl_t new_efl; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + HDassert(efl); + + /* Make copy of efl message */ + if(NULL == H5O_msg_copy(H5O_EFL_ID, efl, &new_efl)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy external file list") + + /* Set new efl message directly into property list */ + *efl = new_efl; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_ext_file_list_copy() */ + + +/*------------------------------------------------------------------------- * Function: H5P__dcrt_ext_file_list_cmp * * Purpose: Callback routine which is called whenever the external file @@ -1032,7 +1412,8 @@ done: *------------------------------------------------------------------------- */ static int -H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, size_t H5_ATTR_UNUSED size) +H5P__dcrt_ext_file_list_cmp(const void *_efl1, const void *_efl2, + size_t H5_ATTR_UNUSED size) { const H5O_efl_t *efl1 = (const H5O_efl_t *)_efl1, /* Create local aliases for values */ *efl2 = (const H5O_efl_t *)_efl2; @@ -1097,6 +1478,39 @@ done: /*------------------------------------------------------------------------- + * Function: H5P__dcrt_ext_file_list_close + * + * Purpose: Frees memory used to store the efl property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Thursday, Feb 26, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dcrt_ext_file_list_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Reset the old efl message */ + if(H5O_msg_reset(H5O_EFL_ID, value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release external file list message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dcrt_ext_file_list_close() */ + + +/*------------------------------------------------------------------------- * Function: H5P__set_layout * * Purpose: Sets the layout of raw data in the file. @@ -1122,10 +1536,10 @@ H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) /* If we still have the "default" allocation time, change it according to the new layout */ if(alloc_time_state) { - H5O_fill_t fill; /* Fill value */ + H5O_fill_t fill; /* Fill value */ /* Get current fill value info */ - if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set the default based on layout */ @@ -1149,7 +1563,7 @@ H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout) } /* end switch */ /* Set updated fill value info */ - if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time") } /* end if */ @@ -1310,8 +1724,8 @@ H5Pget_layout(hid_t plist_id) if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5D_LAYOUT_ERROR, "can't find object for ID") - /* Get layout property */ - if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + /* Peek at layout property */ + if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5D_LAYOUT_ERROR, "can't get layout") /* Set return value */ @@ -1455,8 +1869,8 @@ H5Pget_chunk(hid_t plist_id, int max_ndims, hsize_t dim[]/*out*/) if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Retrieve the layout property */ - if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + /* Peek at the layout property */ + if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't get layout") if(H5D_CHUNKED != layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a chunked storage layout") @@ -1647,7 +2061,7 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if(H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") if(efl.nused > 0 && H5O_EFL_UNLIMITED == efl.slot[efl.nused - 1].size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "previous file size is unlimited") @@ -1660,7 +2074,6 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) } /* end for */ } /* end if */ - /* Add to the list */ if(efl.nused >= efl.nalloc) { size_t na = efl.nalloc + H5O_EFL_ALLOC; @@ -1678,7 +2091,7 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size) efl.slot[idx].size = size; efl.nused++; - if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if(H5P_poke(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list") done: @@ -1722,7 +2135,7 @@ H5Pget_external_count(hid_t plist_id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if(H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") /* Set return value */ @@ -1780,7 +2193,7 @@ H5Pget_external(hid_t plist_id, unsigned idx, size_t name_size, char *name/*out* HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get value */ - if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if(H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") if(idx >= efl.nused) @@ -1859,11 +2272,11 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) cd_values[1]=pixels_per_block; /* Add the filter */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") if(H5Z_append(&pline, H5Z_FILTER_SZIP, H5Z_FLAG_OPTIONAL, (size_t)2, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add szip filter to pipeline") - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: @@ -1906,11 +2319,11 @@ H5Pset_shuffle(hid_t plist_id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Add the filter */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") if(H5Z_append(&pline, H5Z_FILTER_SHUFFLE, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to shuffle the data") - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: @@ -1952,11 +2365,11 @@ H5Pset_nbit(hid_t plist_id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Add the nbit filter */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") if(H5Z_append(&pline, H5Z_FILTER_NBIT, H5Z_FLAG_OPTIONAL, (size_t)0, NULL) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add nbit filter to pipeline") - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: @@ -2031,11 +2444,11 @@ H5Pset_scaleoffset(hid_t plist_id, H5Z_SO_scale_type_t scale_type, int scale_fac cd_values[1] = (unsigned)scale_factor; /* Add the scaleoffset filter */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") if(H5Z_append(&pline, H5Z_FILTER_SCALEOFFSET, H5Z_FLAG_OPTIONAL, (size_t)2, cd_values) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add scaleoffset filter to pipeline") - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to set pipeline") done: @@ -2075,7 +2488,7 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current fill value */ - if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Release the dynamic fill value components */ @@ -2125,7 +2538,7 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) fill.size = (-1); /* Update fill value in property list */ - if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set fill value") done: @@ -2169,7 +2582,7 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/, * datatype conversion might not have resulted in zero. If fill value * is undefined, also return error. */ - if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") if(fill.size == -1) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "fill value is undefined") @@ -2181,8 +2594,8 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/, } /* end if */ /* - * Can we convert between the source and destination datatypes? - */ + * Can we convert between the source and destination datatypes? + */ if(NULL == (tpath = H5T_path_find(fill.type, type, NULL, NULL, dxpl_id, FALSE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill.type, H5T_COPY_TRANSIENT), FALSE)) < 0) @@ -2337,7 +2750,7 @@ H5P_fill_value_defined(H5P_genplist_t *plist, H5D_fill_value_t *status) HDassert(status); /* Get the fill value struct */ - if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Get the fill-value status */ @@ -2425,8 +2838,8 @@ H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) if(alloc_time == H5D_ALLOC_TIME_DEFAULT) { H5O_layout_t layout; /* Type of storage layout */ - /* Retrieve the storage layout */ - if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + /* Peek at the storage layout */ + if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") /* Set the default based on layout */ @@ -2457,14 +2870,14 @@ H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) alloc_time_state = 0; /* Retrieve previous fill value settings */ - if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Update property value */ fill.alloc_time = alloc_time; /* Set values */ - if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time") @@ -2506,7 +2919,7 @@ H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t *alloc_time/*out*/) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve fill value settings */ - if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set user's value */ @@ -2550,14 +2963,14 @@ H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve previous fill value settings */ - if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Update property value */ fill.fill_time = fill_time; /* Set values */ - if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_poke(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value") done: @@ -2599,7 +3012,7 @@ H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Retrieve fill value settings */ - if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) + if(H5P_peek(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value") /* Set user's value */ diff --git a/src/H5Pdxpl.c b/src/H5Pdxpl.c index b079eea..bb30fe2 100644 --- a/src/H5Pdxpl.c +++ b/src/H5Pdxpl.c @@ -152,6 +152,8 @@ /* Definitions for data transform property */ #define H5D_XFER_XFORM_SIZE sizeof(void *) #define H5D_XFER_XFORM_DEF NULL +#define H5D_XFER_XFORM_SET H5P__dxfr_xform_set +#define H5D_XFER_XFORM_GET H5P__dxfr_xform_get #define H5D_XFER_XFORM_ENC H5P__dxfr_xform_enc #define H5D_XFER_XFORM_DEC H5P__dxfr_xform_dec #define H5D_XFER_XFORM_DEL H5P__dxfr_xform_del @@ -203,6 +205,8 @@ static herr_t H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **pp, si static herr_t H5P__dxfr_mpio_chunk_opt_hard_dec(const void **pp, void *value); static herr_t H5P__dxfr_edc_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dxfr_edc_dec(const void **pp, void *value); +static herr_t H5P__dxfr_xform_set(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__dxfr_xform_get(hid_t prop_id, const char* name, size_t size, void* value); static herr_t H5P__dxfr_xform_enc(const void *value, void **pp, size_t *size); static herr_t H5P__dxfr_xform_dec(const void **pp, void *value); static herr_t H5P__dxfr_xform_del(hid_t prop_id, const char* name, size_t size, void* value); @@ -441,7 +445,7 @@ H5P__dxfr_reg_prop(H5P_genclass_t *pclass) /* Register the data transform property */ if(H5P_register_real(pclass, H5D_XFER_XFORM_NAME, H5D_XFER_XFORM_SIZE, &H5D_def_xfer_xform_g, - NULL, NULL, NULL, H5D_XFER_XFORM_ENC, H5D_XFER_XFORM_DEC, + NULL, H5D_XFER_XFORM_SET, H5D_XFER_XFORM_GET, H5D_XFER_XFORM_ENC, H5D_XFER_XFORM_DEC, H5D_XFER_XFORM_DEL, H5D_XFER_XFORM_COPY, H5D_XFER_XFORM_CMP, H5D_XFER_XFORM_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -649,6 +653,72 @@ done: /*------------------------------------------------------------------------- + * Function: H5P__dxfr_xform_set + * + * Purpose: Copies a data transform property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dxfr_xform_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of data transform */ + if(H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dxfr_xform_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__dxfr_xform_get + * + * Purpose: Copies a data transform property when it's retrieved for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dxfr_xform_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of data transform */ + if(H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__dxfr_xform_get() */ + + +/*------------------------------------------------------------------------- * Function: H5P__dxfr_xform_enc * * Purpose: Callback routine which is called whenever the data transform @@ -825,10 +895,12 @@ H5P__dxfr_xform_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size FUNC_ENTER_STATIC + /* Sanity check */ HDassert(value); + /* Make copy of data transform */ if(H5Z_xform_copy((H5Z_data_xform_t **)value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error copying the data transform info") + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info") done: FUNC_LEAVE_NOAPI(ret_value) @@ -951,7 +1023,7 @@ H5Pset_data_transform(hid_t plist_id, const char *expression) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* See if a data transform is already set, and free it if it is */ - if(H5P_get(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) + if(H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data transform expression") /* Destroy previous data transform property */ @@ -962,15 +1034,14 @@ H5Pset_data_transform(hid_t plist_id, const char *expression) if(NULL == (data_xform_prop = H5Z_xform_create(expression))) HGOTO_ERROR(H5E_PLINE, H5E_NOSPACE, FAIL, "unable to create data transform info") - /* Update property list */ - if(H5P_set(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) + /* Update property list (takes ownership of transform) */ + if(H5P_poke(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Error setting data transform expression") done: - if(ret_value < 0) { + if(ret_value < 0) if(data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0) HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") - } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Pset_data_transform() */ @@ -1014,7 +1085,7 @@ H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size) if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) + if(H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data transform expression") if(NULL == data_xform_prop) @@ -1024,6 +1095,7 @@ H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size) if(NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop))) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression") + /* Copy into application buffer */ len = HDstrlen(pexp); if(expression) { HDstrncpy(expression, pexp, MIN(len + 1, size)); @@ -1034,11 +1106,6 @@ H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size) ret_value = (ssize_t)len; done: - if(ret_value < 0) { - if(data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CLOSEERROR, FAIL, "unable to release data transform expression") - } /* end if */ - FUNC_LEAVE_API(ret_value) } /* end H5Pget_data_transform() */ diff --git a/src/H5Pencdec.c b/src/H5Pencdec.c index bd0a260..351bd52 100644 --- a/src/H5Pencdec.c +++ b/src/H5Pencdec.c @@ -796,7 +796,7 @@ H5P__decode(const void *buf) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "no decode callback for property: '%s', name") /* Set the value for the property */ - if(H5P_set(plist, name, value_buf) < 0) + if(H5P_poke(plist, name, value_buf) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value for property: '%s'", name) } /* end while */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index aa79885..c163dd7 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -110,12 +110,16 @@ #define H5F_ACS_GARBG_COLCT_REF_DEF 0 #define H5F_ACS_GARBG_COLCT_REF_ENC H5P__encode_unsigned #define H5F_ACS_GARBG_COLCT_REF_DEC H5P__decode_unsigned -/* Definition for file driver ID */ -#define H5F_ACS_FILE_DRV_ID_SIZE sizeof(hid_t) -#define H5F_ACS_FILE_DRV_ID_DEF H5_DEFAULT_VFD -/* Definition for file driver info */ -#define H5F_ACS_FILE_DRV_INFO_SIZE sizeof(void*) -#define H5F_ACS_FILE_DRV_INFO_DEF NULL +/* Definition for file driver ID & info*/ +#define H5F_ACS_FILE_DRV_SIZE sizeof(H5FD_driver_prop_t) +#define H5F_ACS_FILE_DRV_DEF {H5_DEFAULT_VFD, NULL} +#define H5F_ACS_FILE_DRV_CRT H5P__facc_file_driver_create +#define H5F_ACS_FILE_DRV_SET H5P__facc_file_driver_set +#define H5F_ACS_FILE_DRV_GET H5P__facc_file_driver_get +#define H5F_ACS_FILE_DRV_DEL H5P__facc_file_driver_del +#define H5F_ACS_FILE_DRV_COPY H5P__facc_file_driver_copy +#define H5F_ACS_FILE_DRV_CMP H5P__facc_file_driver_cmp +#define H5F_ACS_FILE_DRV_CLOSE H5P__facc_file_driver_close /* Definition for file close degree */ #define H5F_CLOSE_DEGREE_SIZE sizeof(H5F_close_degree_t) #define H5F_CLOSE_DEGREE_DEF H5F_CLOSE_DEFAULT @@ -157,9 +161,12 @@ /* Definition of pointer to initial file image info */ #define H5F_ACS_FILE_IMAGE_INFO_SIZE sizeof(H5FD_file_image_info_t) #define H5F_ACS_FILE_IMAGE_INFO_DEF H5FD_DEFAULT_FILE_IMAGE_INFO -#define H5F_ACS_FILE_IMAGE_INFO_DEL H5P_file_image_info_del -#define H5F_ACS_FILE_IMAGE_INFO_COPY H5P_file_image_info_copy -#define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P_file_image_info_close +#define H5F_ACS_FILE_IMAGE_INFO_SET H5P__facc_file_image_info_set +#define H5F_ACS_FILE_IMAGE_INFO_GET H5P__facc_file_image_info_get +#define H5F_ACS_FILE_IMAGE_INFO_DEL H5P__facc_file_image_info_del +#define H5F_ACS_FILE_IMAGE_INFO_COPY H5P__facc_file_image_info_copy +#define H5F_ACS_FILE_IMAGE_INFO_CMP H5P__facc_file_image_info_cmp +#define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P__facc_file_image_info_close /* Definition of core VFD write tracking flag */ #define H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE sizeof(hbool_t) #define H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEF FALSE @@ -217,14 +224,26 @@ /********************/ /* Property class callbacks */ -static herr_t H5P_facc_reg_prop(H5P_genclass_t *pclass); -static herr_t H5P_facc_create(hid_t fapl_id, void *copy_data); -static herr_t H5P_facc_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); +static herr_t H5P__facc_reg_prop(H5P_genclass_t *pclass); + +/* File driver ID & info property callbacks */ +static herr_t H5P__facc_file_driver_create(const char *name, size_t size, void *value); +static herr_t H5P__facc_file_driver_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_file_driver_get(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_file_driver_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_file_driver_copy(const char *name, size_t size, void *value); +static int H5P__facc_file_driver_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__facc_file_driver_close(const char *name, size_t size, void *value); /* File image info property callbacks */ -static herr_t H5P_file_image_info_del(hid_t prop_id, const char *name, size_t size, void *value); -static herr_t H5P_file_image_info_copy(const char *name, size_t size, void *value); -static herr_t H5P_file_image_info_close(const char *name, size_t size, void *value); +static herr_t H5P__file_image_info_copy(void *value); +static herr_t H5P__file_image_info_free(void *value); +static herr_t H5P__facc_file_image_info_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_file_image_info_get(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_file_image_info_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_file_image_info_copy(const char *name, size_t size, void *value); +static int H5P__facc_file_image_info_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__facc_file_image_info_close(const char *name, size_t size, void *value); /* encode & decode callbacks */ static herr_t H5P__facc_cache_config_enc(const void *value, void **_pp, size_t *size); @@ -257,13 +276,13 @@ const H5P_libclass_t H5P_CLS_FACC[1] = {{ &H5P_CLS_FILE_ACCESS_g, /* Pointer to class */ &H5P_CLS_FILE_ACCESS_ID_g, /* Pointer to class ID */ &H5P_LST_FILE_ACCESS_ID_g, /* Pointer to default property list ID */ - H5P_facc_reg_prop, /* Default property registration routine */ + H5P__facc_reg_prop, /* Default property registration routine */ - H5P_facc_create, /* Class creation callback */ + NULL, /* Class creation callback */ NULL, /* Class creation callback info */ - H5P_facc_copy, /* Class copy callback */ + NULL, /* Class copy callback */ NULL, /* Class copy callback info */ - H5P_facc_close, /* Class close callback */ + NULL, /* Class close callback */ NULL /* Class close callback info */ }}; @@ -288,7 +307,6 @@ static const hsize_t H5F_def_meta_block_size_g = H5F_ACS_META_BLOCK_SIZE_DEF; static const size_t H5F_def_sieve_buf_size_g = H5F_ACS_SIEVE_BUF_SIZE_DEF; /* Default raw data I/O sieve buffer size */ static const hsize_t H5F_def_sdata_block_size_g = H5F_ACS_SDATA_BLOCK_SIZE_DEF; /* Default small data allocation block size */ static const unsigned H5F_def_gc_ref_g = H5F_ACS_GARBG_COLCT_REF_DEF; /* Default garbage collection for references setting */ -static const void *H5F_def_driver_info_g = H5F_ACS_FILE_DRV_INFO_DEF; /* Default VFL driver info */ static const H5F_close_degree_t H5F_def_close_degree_g = H5F_CLOSE_DEGREE_DEF; /* Default file close degree */ static const hsize_t H5F_def_family_offset_g = H5F_ACS_FAMILY_OFFSET_DEF; /* Default offset for family VFD */ static const hsize_t H5F_def_family_newsize_g = H5F_ACS_FAMILY_NEWSIZE_DEF; /* Default size of new files for family VFD */ @@ -307,9 +325,10 @@ static const hbool_t H5F_def_use_mdc_logging_g = H5F_ACS_USE_MDC_LOGGING_DEF; static const char *H5F_def_mdc_log_location_g = H5F_ACS_MDC_LOG_LOCATION_DEF; /* Default mdc log location */ static const hbool_t H5F_def_start_mdc_log_on_access_g = H5F_ACS_START_MDC_LOG_ON_ACCESS_DEF; /* Default mdc log start on access flag */ + /*------------------------------------------------------------------------- - * Function: H5P_facc_reg_prop + * Function: H5P__facc_reg_prop * * Purpose: Register the file access property list class's properties * @@ -320,12 +339,12 @@ static const hbool_t H5F_def_start_mdc_log_on_access_g = H5F_ACS_START_MDC_LOG_O *------------------------------------------------------------------------- */ static herr_t -H5P_facc_reg_prop(H5P_genclass_t *pclass) +H5P__facc_reg_prop(H5P_genclass_t *pclass) { - const hid_t def_driver_id = H5F_ACS_FILE_DRV_ID_DEF; /* Default VFL driver ID (initialized from a variable) */ + const H5FD_driver_prop_t def_driver_prop = H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Register the initial metadata cache resize configuration */ if(H5P_register_real(pclass, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, H5F_ACS_META_CACHE_INIT_CONFIG_SIZE, &H5F_def_mdc_initCacheCfg_g, @@ -387,16 +406,11 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the file driver ID */ + /* Register the file driver ID & info */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P_register_real(pclass, H5F_ACS_FILE_DRV_ID_NAME, H5F_ACS_FILE_DRV_ID_SIZE, &def_driver_id, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the file driver info */ - /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P_register_real(pclass, H5F_ACS_FILE_DRV_INFO_NAME, H5F_ACS_FILE_DRV_INFO_SIZE, &H5F_def_driver_info_g, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if(H5P_register_real(pclass, H5F_ACS_FILE_DRV_NAME, H5F_ACS_FILE_DRV_SIZE, &def_driver_prop, + H5F_ACS_FILE_DRV_CRT, H5F_ACS_FILE_DRV_SET, H5F_ACS_FILE_DRV_GET, NULL, NULL, + H5F_ACS_FILE_DRV_DEL, H5F_ACS_FILE_DRV_COPY, H5F_ACS_FILE_DRV_CMP, H5F_ACS_FILE_DRV_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the file close degree */ @@ -451,8 +465,8 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) /* Register the initial file image info */ /* (Note: this property should not have an encode/decode callback -QAK) */ if(H5P_register_real(pclass, H5F_ACS_FILE_IMAGE_INFO_NAME, H5F_ACS_FILE_IMAGE_INFO_SIZE, &H5F_def_file_image_info_g, - NULL, NULL, NULL, NULL, NULL, - H5F_ACS_FILE_IMAGE_INFO_DEL, H5F_ACS_FILE_IMAGE_INFO_COPY, NULL, H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0) + NULL, H5F_ACS_FILE_IMAGE_INFO_SET, H5F_ACS_FILE_IMAGE_INFO_GET, NULL, NULL, + H5F_ACS_FILE_IMAGE_INFO_DEL, H5F_ACS_FILE_IMAGE_INFO_COPY, H5F_ACS_FILE_IMAGE_INFO_CMP, H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the core VFD backing store write tracking flag */ @@ -474,6 +488,7 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register object flush callback */ + /* (Note: this property should not have an encode/decode callback -QAK) */ if(H5P_register_real(pclass, H5F_ACS_OBJECT_FLUSH_CB_NAME, H5F_ACS_OBJECT_FLUSH_CB_SIZE, &H5F_def_object_flush_cb_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -501,159 +516,7 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_facc_reg_prop() */ - - -/*---------------------------------------------------------------------------- - * Function: H5P_facc_create - * - * Purpose: Callback routine which is called whenever a file access - * property list is closed. This routine performs any generic - * initialization needed on the properties the library put into - * the list. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Raymond Lu - * Tuesday, Oct 23, 2001 - * - *---------------------------------------------------------------------------- - */ -/* ARGSUSED */ -static herr_t -H5P_facc_create(hid_t fapl_id, void H5_ATTR_UNUSED *copy_data) -{ - hid_t driver_id; - H5P_genplist_t *plist; /* Property list */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* Check argument */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Retrieve driver ID property */ - if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") - - if(driver_id > 0) { - void *driver_info; - - /* Retrieve driver info property */ - if(H5P_get(plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver info") - - /* Set the driver for the property list */ - if(H5FD_fapl_open(plist, driver_id, driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_facc_create() */ - - -/*-------------------------------------------------------------------------- - * Function: H5P_facc_copy - * - * Purpose: Callback routine which is called whenever a file access - * property list is copied. This routine performs any generic - * copy needed on the properties. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Raymond Lu - * Tuesday, Oct 23, 2001 - * - *-------------------------------------------------------------------------- - */ -/* ARGSUSED */ -static herr_t -H5P_facc_copy(hid_t dst_fapl_id, hid_t src_fapl_id, void H5_ATTR_UNUSED *copy_data) -{ - hid_t driver_id; - H5P_genplist_t *src_plist; /* Source property list */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* Get driver ID from source property list */ - if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - if(H5P_get(src_plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") - - if(driver_id > 0) { - H5P_genplist_t *dst_plist; /* Destination property list */ - void *driver_info; - - /* Get driver info from source property list */ - if(H5P_get(src_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver info") - - /* Set the driver for the destination property list */ - if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - if(H5FD_fapl_open(dst_plist, driver_id, driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_facc_copy() */ - - -/*-------------------------------------------------------------------------- - * Function: H5P_facc_close - * - * Purpose: Callback routine which is called whenever a file access - * property list is closed. This routine performs any generic - * cleanup needed on the properties. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Raymond Lu - * Tuesday, Oct 23, 2001 - * - *--------------------------------------------------------------------------- - */ -/* ARGSUSED */ -herr_t -H5P_facc_close(hid_t fapl_id, void H5_ATTR_UNUSED *close_data) -{ - hid_t driver_id; - H5P_genplist_t *plist; /* Property list */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Check argument */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Get driver ID property */ - if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ - - if(driver_id > 0) { - void *driver_info; - - /* Get driver info property */ - if(H5P_get(plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) - HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ - - /* Close the driver for the property list */ - if(H5FD_fapl_close(driver_id, driver_info) < 0) - HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_facc_close() */ +} /* end H5P__facc_reg_prop() */ /*------------------------------------------------------------------------- @@ -777,9 +640,7 @@ done: herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info) { - hid_t driver_id; /* VFL driver ID */ - void *driver_info; /* VFL driver info */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -787,19 +648,15 @@ H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_drive HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID") if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - /* Get the current driver information */ - if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") - if(H5P_get(plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL,"can't get driver info") + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ - /* Close the driver for the property list */ - if(H5FD_fapl_close(driver_id, driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset driver") + /* Prepare the driver property */ + driver_prop.driver_id = new_driver_id; + driver_prop.driver_info = new_driver_info; - /* Set the driver for the property list */ - if(H5FD_fapl_open(plist, new_driver_id, new_driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") + /* Set the driver ID & info property */ + if(H5P_set(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver ID & info") } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") @@ -853,7 +710,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5P_get_driver + * Function: H5P_peek_driver * * Purpose: Return the ID of the low-level file driver. PLIST_ID should * be a file access property list. @@ -871,7 +728,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5P_get_driver(H5P_genplist_t *plist) +H5P_peek_driver(H5P_genplist_t *plist) { hid_t ret_value = FAIL; /* Return value */ @@ -879,18 +736,21 @@ H5P_get_driver(H5P_genplist_t *plist) /* Get the current driver ID */ if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &ret_value) < 0) + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + + if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") + ret_value = driver_prop.driver_id; } /* end if */ else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access property list") if(H5FD_VFD_DEFAULT == ret_value) ret_value = H5_DEFAULT_VFD; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_get_driver() */ +} /* end H5P_peek_driver() */ /*------------------------------------------------------------------------- @@ -899,6 +759,8 @@ done: * Purpose: Return the ID of the low-level file driver. PLIST_ID should * be a file access property list. * + * Note: The ID returned should not be closed. + * * Return: Success: A low-level driver ID which is the same ID * used when the driver was set for the property * list. The driver ID is only valid as long as @@ -924,7 +786,7 @@ H5Pget_driver(hid_t plist_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") /* Get the driver */ - if((ret_value = H5P_get_driver(plist)) < 0) + if((ret_value = H5P_peek_driver(plist)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver") done: @@ -933,7 +795,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5P_get_driver_info + * Function: H5P_peek_driver_info * * Purpose: Returns a pointer directly to the file driver-specific * information of a file access. @@ -951,8 +813,8 @@ done: * *------------------------------------------------------------------------- */ -void * -H5P_get_driver_info(H5P_genplist_t *plist) +const void * +H5P_peek_driver_info(H5P_genplist_t *plist) { void *ret_value = NULL; /* Return value */ @@ -960,15 +822,18 @@ H5P_get_driver_info(H5P_genplist_t *plist) /* Get the current driver info */ if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - if(H5P_get(plist, H5F_ACS_FILE_DRV_INFO_NAME, &ret_value) < 0) + H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ + + if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info") + ret_value = (void *)driver_prop.driver_info; } /* end if */ else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a file access property list") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_get_driver_info() */ +} /* end H5P_peek_driver_info() */ /*------------------------------------------------------------------------- @@ -1003,7 +868,7 @@ H5Pget_driver_info(hid_t plist_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") /* Get the driver info */ - if(NULL == (ret_value = H5P_get_driver_info(plist))) + if(NULL == (ret_value = (void *)H5P_peek_driver_info(plist))) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver info") done: @@ -1012,6 +877,365 @@ done: /*------------------------------------------------------------------------- + * Function: H5P__file_driver_copy + * + * Purpose: Copy file driver ID & info. + * + * Note: This is an "in-place" copy, since this routine gets called + * after the top-level copy has been performed and this routine + * finishes the "deep" part of the copy. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, Sept 8, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__file_driver_copy(void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + if(value) { + H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */ + + /* Copy the driver & info, if there is one */ + if(info->driver_id > 0) { + /* Increment the reference count on driver and copy driver info */ + if(H5I_inc_ref(info->driver_id, FALSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") + + /* Copy driver info, if it exists */ + if(info->driver_info) { + H5FD_class_t *driver; /* Pointer to driver */ + void *new_pl; /* Copy of driver info */ + + /* Retrieve the driver for the ID */ + if(NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a driver ID") + + /* Allow the driver to copy or do it ourselves */ + if(driver->fapl_copy) { + if(NULL == (new_pl = (driver->fapl_copy)(info->driver_info))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "driver info copy failed") + } /* end if */ + else if(driver->fapl_size > 0) { + if(NULL == (new_pl = H5MM_malloc(driver->fapl_size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "driver info allocation failed") + HDmemcpy(new_pl, info->driver_info, driver->fapl_size); + } /* end else-if */ + else + HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "no way to copy driver info") + + /* Set the driver info for the copy */ + info->driver_info = new_pl; + } /* end if */ + } /* end if */ + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__file_driver_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__file_driver_free + * + * Purpose: Free file driver ID & info. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, Sept 8, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__file_driver_free(void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + if(value) { + H5FD_driver_prop_t *info = (H5FD_driver_prop_t *)value; /* Driver ID & info struct */ + + /* Copy the driver & info, if there is one */ + if(info->driver_id > 0) { + if(info->driver_info) { + H5FD_class_t *driver; /* Pointer to driver */ + + /* Retrieve the driver for the ID */ + if(NULL == (driver = (H5FD_class_t *)H5I_object(info->driver_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a driver ID") + + /* Allow driver to free info or do it ourselves */ + if(driver->fapl_free) { + if((driver->fapl_free)((void *)info->driver_info) < 0) /* Casting away const OK -QAK */ + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed") + } /* end if */ + else + H5MM_xfree((void *)info->driver_info); /* Casting away const OK -QAK */ + } /* end if */ + + /* Decrement reference count for driver */ + if(H5I_dec_ref(info->driver_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement reference count for driver ID") + } /* end if */ + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__file_driver_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_driver_create + * + * Purpose: Create callback for the file driver ID & info property. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, September 8, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_driver_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Make copy of file driver */ + if(H5P__file_driver_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_driver_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_driver_set + * + * Purpose: Copies a file driver property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, Sept 7, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_driver_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of file driver ID & info */ + if(H5P__file_driver_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_driver_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_driver_get + * + * Purpose: Copies a file driver property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, Sept 7, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_driver_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of file driver */ + if(H5P__file_driver_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_driver_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_driver_del + * + * Purpose: Frees memory used to store the driver ID & info property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, September 8, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_driver_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Free the file driver ID & info */ + if(H5P__file_driver_free(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_driver_del() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_driver_copy + * + * Purpose: Copy callback for the file driver ID & info property. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, September 8, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_driver_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Make copy of file driver */ + if(H5P__file_driver_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_driver_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_driver_cmp + * + * Purpose: Callback routine which is called whenever the file driver ID & info + * property in the file access property list is compared. + * + * Return: positive if VALUE1 is greater than VALUE2, negative if + * VALUE2 is greater than VALUE1 and zero if VALUE1 and + * VALUE2 are equal. + * + * Programmer: Quincey Koziol + * Monday, September 8, 2015 + * + *------------------------------------------------------------------------- + */ +static int +H5P__facc_file_driver_cmp(const void *_info1, const void *_info2, + size_t H5_ATTR_UNUSED size) +{ + const H5FD_driver_prop_t *info1 = (const H5FD_driver_prop_t *)_info1, /* Create local aliases for values */ + *info2 = (const H5FD_driver_prop_t *)_info2; + H5FD_class_t *cls1, *cls2; /* Driver class for each property */ + int cmp_value; /* Value from comparison */ + herr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(info1); + HDassert(info2); + HDassert(size == sizeof(H5FD_driver_prop_t)); + + /* Compare drivers */ + if(NULL == (cls1 = H5FD_get_class(info1->driver_id))) + HGOTO_DONE(-1) + if(NULL == (cls2 = H5FD_get_class(info2->driver_id))) + HGOTO_DONE(1) + if(cls1->name == NULL && cls2->name != NULL) HGOTO_DONE(-1); + if(cls1->name != NULL && cls2->name == NULL) HGOTO_DONE(1); + if(0 != (cmp_value = HDstrcmp(cls1->name, cls2->name))) + HGOTO_DONE(cmp_value); + + /* Compare driver infos */ + if(cls1->fapl_size < cls2->fapl_size) HGOTO_DONE(-1) + if(cls1->fapl_size > cls2->fapl_size) HGOTO_DONE(1) + HDassert(cls1->fapl_size == cls2->fapl_size); + if(info1->driver_info == NULL && info2->driver_info != NULL) HGOTO_DONE(-1); + if(info1->driver_info != NULL && info2->driver_info == NULL) HGOTO_DONE(1); + if(info1->driver_info) { + HDassert(cls1->fapl_size > 0); + if(0 != (cmp_value = HDmemcmp(info1->driver_info, info2->driver_info, cls1->fapl_size))) + HGOTO_DONE(cmp_value); + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_driver_cmp() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_driver_close + * + * Purpose: Close callback for the file driver ID & info property. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, September 8, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_driver_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Free the file driver */ + if(H5P__file_driver_free(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_driver_close() */ + + +/*------------------------------------------------------------------------- * Function: H5Pset_family_offset * * Purpose: Set offset for family driver. This file access property @@ -2084,7 +2308,7 @@ H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get old image info */ - if(H5P_get(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) + if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get old file image pointer") /* Release previous buffer, if it exists */ @@ -2125,7 +2349,7 @@ H5Pset_file_image(hid_t fapl_id, void *buf_ptr, size_t buf_len) image_info.size = buf_len; /* Set values */ - if(H5P_set(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) + if(H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file image info") done: @@ -2177,7 +2401,7 @@ H5Pget_file_image(hid_t fapl_id, void **buf_ptr_ptr, size_t *buf_len_ptr) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get values */ - if(H5P_get(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) + if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &image_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file image info") /* verify file image field consistancy */ @@ -2253,7 +2477,7 @@ H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callback HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get old info */ - if(H5P_get(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) + if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get old file image info") /* verify file image field consistancy */ @@ -2291,7 +2515,7 @@ H5Pset_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callback } /* end if */ /* Set values */ - if(H5P_set(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) + if(H5P_poke(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file image info") done: @@ -2329,7 +2553,7 @@ H5Pget_file_image_callbacks(hid_t fapl_id, H5FD_file_image_callbacks_t *callback HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get old info */ - if(H5P_get(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) + if(H5P_peek(fapl, H5F_ACS_FILE_IMAGE_INFO_NAME, &info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file image info") /* verify file image field consistancy */ @@ -2356,80 +2580,30 @@ done: /*------------------------------------------------------------------------- - * Function: H5P_file_image_info_del - * - * Purpose: Delete callback for the file image info property, called - * when the property is deleted from the plist. The buffer - * and udata may need to be freed, possibly using their - * respective callbacks so the default free won't work. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Jacob Gruber - * Thurday, August 11, 2011 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5P_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) -{ - H5FD_file_image_info_t info; /* Image info struct */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(value) { - info = *(H5FD_file_image_info_t *)value; - - /* verify file image field consistancy */ - HDassert(((info.buffer != NULL) && (info.size > 0)) || - ((info.buffer == NULL) && (info.size == 0))); - - if(info.buffer && info.size > 0) { - /* Free buffer */ - if(info.callbacks.image_free) { - if(info.callbacks.image_free(info.buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, info.callbacks.udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "image_free callback failed") - } /* end if */ - else - HDfree(info.buffer); - } /* end if */ - - /* Free udata if it exists */ - if(info.callbacks.udata) { - if(NULL == info.callbacks.udata_free) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_free not defined") - - if(info.callbacks.udata_free(info.callbacks.udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed") - } /* end if */ - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_file_image_info_del() */ - - -/*------------------------------------------------------------------------- - * Function: H5P_file_image_info_copy + * Function: H5P__file_image_info_copy * - * Purpose: Copy callback for the file image info property. The buffer + * Purpose: Copy file image info. The buffer * and udata may need to be copied, possibly using their * respective callbacks so the default copy won't work. * - * Return: Non-negative on success/Negative on failure + * Note: This is an "in-place" copy, since this routine gets called + * after the top-level copy has been performed and this routine + * finishes the "deep" part of the copy. * - * Programmer: Jacob Gruber - * Thurday, August 11, 2011 + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 * *------------------------------------------------------------------------- */ static herr_t -H5P_file_image_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__file_image_info_copy(void *value) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if(value) { H5FD_file_image_info_t *info; /* Image info struct */ @@ -2450,19 +2624,18 @@ H5P_file_image_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED if(info->callbacks.image_malloc) { if(NULL == (info->buffer = info->callbacks.image_malloc(info->size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, info->callbacks.udata))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "image malloc callback failed") + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "image malloc callback failed") } /* end if */ else { if(NULL == (info->buffer = H5MM_malloc(info->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block") + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "unable to allocate memory block") } /* end else */ /* Copy data to new buffer */ if(info->callbacks.image_memcpy) { if(info->buffer != info->callbacks.image_memcpy(info->buffer, old_buffer, - info->size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, - info->callbacks.udata)) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") + info->size, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_COPY, info->callbacks.udata)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "image_memcpy callback failed") } /* end if */ else HDmemcpy(info->buffer, old_buffer, info->size); @@ -2473,50 +2646,53 @@ H5P_file_image_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED void *old_udata = info->callbacks.udata; if(NULL == info->callbacks.udata_copy) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_copy not defined") + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "udata_copy not defined") info->callbacks.udata = info->callbacks.udata_copy(old_udata); } /* end if */ - } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_file_image_info_copy() */ +} /* end H5P__file_image_info_copy() */ /*------------------------------------------------------------------------- - * Function: H5P_file_image_info_close + * Function: H5P__file_image_info_free * - * Purpose: Close callback for the file image info property. The buffer - * and udata may need to be freed, possibly using their - * respective callbacks so the standard free won't work. + * Purpose: Free file image info. The buffer and udata may need to be + * freed, possibly using their respective callbacks, so the + * default free won't work. * - * Return: Non-negative on success/Negative on failure + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Jacob Gruber - * Thurday, August 11, 2011 + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 * *------------------------------------------------------------------------- */ static herr_t -H5P_file_image_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__file_image_info_free(void *value) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC if(value) { H5FD_file_image_info_t *info; /* Image info struct */ info = (H5FD_file_image_info_t *)value; + /* Verify file image field consistancy */ + HDassert(((info->buffer != NULL) && (info->size > 0)) || + ((info->buffer == NULL) && (info->size == 0))); + + /* Free buffer */ if(info->buffer != NULL && info->size > 0) { - /* Free buffer */ if(info->callbacks.image_free) { - if(info->callbacks.image_free(info->buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, - info->callbacks.udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "image_free callback failed") + if((*info->callbacks.image_free)(info->buffer, H5FD_FILE_IMAGE_OP_PROPERTY_LIST_CLOSE, info->callbacks.udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "image_free callback failed") } /* end if */ else H5MM_xfree(info->buffer); @@ -2525,15 +2701,231 @@ H5P_file_image_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED /* Free udata if it exists */ if(info->callbacks.udata) { if(NULL == info->callbacks.udata_free) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata_free not defined") - if(info->callbacks.udata_free(info->callbacks.udata) < 0) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTFREE, FAIL, "udata_free callback failed") + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "udata_free not defined") + if((*info->callbacks.udata_free)(info->callbacks.udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "udata_free callback failed") } /* end if */ } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_file_image_info_close() */ +} /* end H5P__file_image_info_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_image_info_set + * + * Purpose: Copies a file image property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_image_info_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of file image info */ + if(H5P__file_image_info_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_image_info_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_image_info_get + * + * Purpose: Copies a file image property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_image_info_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of file image info */ + if(H5P__file_image_info_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_image_info_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_image_info_del + * + * Purpose: Delete callback for the file image info property, called + * when the property is deleted from the plist. The buffer + * and udata may need to be freed, possibly using their + * respective callbacks so the default free won't work. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Jacob Gruber + * Thurday, August 11, 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_image_info_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Free the file image info */ + if(H5P__file_image_info_free(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file image info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_image_info_del() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_image_info_copy + * + * Purpose: Copy callback for the file image info property. The buffer + * and udata may need to be copied, possibly using their + * respective callbacks so the default copy won't work. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Jacob Gruber + * Thurday, August 11, 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_image_info_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Make copy of file image info */ + if(H5P__file_image_info_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy file image info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_image_info_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_image_info_cmp + * + * Purpose: Callback routine which is called whenever the file image info + * property in the file access property list is compared. + * + * Return: positive if VALUE1 is greater than VALUE2, negative if + * VALUE2 is greater than VALUE1 and zero if VALUE1 and + * VALUE2 are equal. + * + * Programmer: Quincey Koziol + * Thursday, September 3, 2015 + * + *------------------------------------------------------------------------- + */ +static int +H5P__facc_file_image_info_cmp(const void *_info1, const void *_info2, + size_t H5_ATTR_UNUSED size) +{ + const H5FD_file_image_info_t *info1 = (const H5FD_file_image_info_t *)_info1, /* Create local aliases for values */ + *info2 = (const H5FD_file_image_info_t *)_info2; + herr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(info1); + HDassert(info2); + HDassert(size == sizeof(H5FD_file_image_info_t)); + + /* Check for different buffer sizes */ + if(info1->size < info2->size) HGOTO_DONE(-1) + if(info1->size > info2->size) HGOTO_DONE(1) + + /* Check for different callbacks */ + /* (Order in memory is fairly meaningless, so just check for equality) */ + if(info1->callbacks.image_malloc != info2->callbacks.image_malloc) HGOTO_DONE(1) + if(info1->callbacks.image_memcpy != info2->callbacks.image_memcpy) HGOTO_DONE(-1) + if(info1->callbacks.image_realloc != info2->callbacks.image_realloc) HGOTO_DONE(1) + if(info1->callbacks.image_free != info2->callbacks.image_free) HGOTO_DONE(-1) + if(info1->callbacks.udata_copy != info2->callbacks.udata_copy) HGOTO_DONE(1) + if(info1->callbacks.udata_free != info2->callbacks.udata_free) HGOTO_DONE(-1) + + /* Check for different udata */ + /* (Don't know how big it is, so can't check contents) */ + if(info1->callbacks.udata < info2->callbacks.udata) HGOTO_DONE(-1) + if(info1->callbacks.udata > info2->callbacks.udata) HGOTO_DONE(1) + + /* Check buffer contents (instead of buffer pointers) */ + if(info1->buffer != NULL && info2->buffer == NULL) HGOTO_DONE(-1) + if(info1->buffer == NULL && info2->buffer != NULL) HGOTO_DONE(1) + if(info1->buffer != NULL && info2->buffer != NULL) + ret_value = HDmemcmp(info1->buffer, info2->buffer, size); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_image_info_cmp() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_file_image_info_close + * + * Purpose: Close callback for the file image info property. The buffer + * and udata may need to be freed, possibly using their + * respective callbacks so the standard free won't work. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Jacob Gruber + * Thurday, August 11, 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_file_image_info_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Free the file image info */ + if(H5P__file_image_info_free(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release file image info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_file_image_info_close() */ /*------------------------------------------------------------------------- diff --git a/src/H5Pint.c b/src/H5Pint.c index e25b686..099d531 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -79,6 +79,22 @@ typedef struct { int cmp_value; /* Value from property comparison */ } H5P_plist_cmp_ud_t; +/* Typedef for property list set/poke callbacks */ +typedef struct { + const void *value; /* Pointer to value to set */ +} H5P_prop_set_ud_t; + +/* Typedef for property list get/peek callbacks */ +typedef struct { + void *value; /* Pointer for retrieved value */ +} H5P_prop_get_ud_t; + +/* Typedef for H5P__do_prop() callbacks */ +typedef herr_t (*H5P_do_plist_op_t)(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, + void *udata); +typedef herr_t (*H5P_do_pclass_op_t)(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, + void *udata); + /********************/ /* Local Prototypes */ @@ -88,6 +104,8 @@ typedef struct { static H5P_genprop_t *H5P_dup_prop(H5P_genprop_t *oprop, H5P_prop_within_t type); static herr_t H5P_free_prop(H5P_genprop_t *prop); static int H5P_cmp_prop(const H5P_genprop_t *prop1, const H5P_genprop_t *prop2); +static herr_t H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op, + H5P_do_pclass_op_t pclass_op, void *udata); /*********************/ @@ -312,75 +330,6 @@ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ -/*-------------------------------------------------------------------------- - NAME - H5P_do_prop_cb1 - PURPOSE - Internal routine to call a property list callback routine and update - the property list accordingly. - USAGE - herr_t H5P_do_prop_cb1(slist,prop,cb) - H5SL_t *slist; IN/OUT: Skip list to hold changed properties - H5P_genprop_t *prop; IN: Property to call callback for - H5P_prp_cb1_t *cb; IN: Callback routine to call - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Calls the callback routine passed in. If the callback routine changes - the property value, then the property is duplicated and added to skip list. - - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5P_do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb) -{ - void *tmp_value=NULL; /* Temporary value buffer */ - H5P_genprop_t *pcopy=NULL; /* Copy of property to insert into skip list */ - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Allocate space for a temporary copy of the property value */ - if(NULL == (tmp_value = H5MM_malloc(prop->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for temporary property value") - HDmemcpy(tmp_value,prop->value,prop->size); - - /* Call "type 1" callback ('create', 'copy' or 'close') */ - if(cb(prop->name,prop->size,tmp_value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL,"Property callback failed") - - /* Check if the property value changed */ - if((prop->cmp)(tmp_value,prop->value,prop->size)) { - /* Make a copy of the class's property */ - if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST)) == NULL) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't copy property") - - /* Copy the changed value into the new property */ - HDmemcpy(pcopy->value,tmp_value,prop->size); - - /* Insert the changed property into the property list */ - if(H5P_add_prop(slist,pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert property into skip list") - } /* end if */ - -done: - /* Release the temporary value buffer */ - if(tmp_value!=NULL) - H5MM_xfree(tmp_value); - - /* Cleanup on failure */ - if(ret_value<0) { - if(pcopy!=NULL) - H5P_free_prop(pcopy); - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_do_prop_cb1() */ - - /*------------------------------------------------------------------------- * Function: H5P_init * @@ -620,6 +569,77 @@ H5P_term_interface(void) /*-------------------------------------------------------------------------- NAME + H5P__do_prop_cb1 + PURPOSE + Internal routine to call a property list callback routine and update + the property list accordingly. + USAGE + herr_t H5P__do_prop_cb1(slist,prop,cb) + H5SL_t *slist; IN/OUT: Skip list to hold changed properties + H5P_genprop_t *prop; IN: Property to call callback for + H5P_prp_cb1_t *cb; IN: Callback routine to call + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Calls the callback routine passed in. If the callback routine changes + the property value, then the property is duplicated and added to skip list. + + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static herr_t +H5P__do_prop_cb1(H5SL_t *slist, H5P_genprop_t *prop, H5P_prp_cb1_t cb) +{ + void *tmp_value = NULL; /* Temporary value buffer */ + H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(slist); + HDassert(prop); + HDassert(prop->cmp); + HDassert(cb); + + /* Allocate space for a temporary copy of the property value */ + if(NULL == (tmp_value = H5MM_malloc(prop->size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary property value") + HDmemcpy(tmp_value, prop->value, prop->size); + + /* Call "type 1" callback ('create', 'copy' or 'close') */ + if(cb(prop->name, prop->size, tmp_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL,"Property callback failed") + + /* Make a copy of the class's property */ + if(NULL == (pcopy = H5P_dup_prop(prop, H5P_PROP_WITHIN_LIST))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") + + /* Copy the changed value into the new property */ + HDmemcpy(pcopy->value, tmp_value, prop->size); + + /* Insert the changed property into the property list */ + if(H5P_add_prop(slist, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "Can't insert property into skip list") + +done: + /* Release the temporary value buffer */ + if(tmp_value) + H5MM_xfree(tmp_value); + + /* Cleanup on failure */ + if(ret_value < 0) + if(pcopy) + H5P_free_prop(pcopy); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__do_prop_cb1() */ + + +/*-------------------------------------------------------------------------- + NAME H5P_copy_pclass PURPOSE Internal routine to copy a generic property class @@ -838,10 +858,10 @@ H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref) /* Only "copy" properties we haven't seen before */ if(nseen==0 || H5SL_search(seen,tmp->name) == NULL) { - /* Call property creation callback, if it exists */ + /* Call property copy callback, if it exists */ if(tmp->copy) { /* Call the callback & insert changed value into skip list (if necessary) */ - if(H5P_do_prop_cb1(new_plist->props,tmp,tmp->copy) < 0) + if(H5P__do_prop_cb1(new_plist->props, tmp, tmp->copy) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL,"Can't create property") } /* end if */ @@ -1694,7 +1714,7 @@ H5P_create(H5P_genclass_t *pclass) /* Call property creation callback, if it exists */ if(tmp->create) { /* Call the callback & insert changed value into skip list (if necessary) */ - if(H5P_do_prop_cb1(plist->props,tmp,tmp->create) < 0) + if(H5P__do_prop_cb1(plist->props, tmp, tmp->create) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, NULL,"Can't create property") } /* end if */ @@ -2561,316 +2581,603 @@ done: /*-------------------------------------------------------------------------- NAME - H5P_set + H5P__do_prop PURPOSE - Internal routine to set a property's value in a property list. + Internal routine to perform an operation on a property in a property list USAGE - herr_t H5P_set(plist, name, value) + herr_t H5P__do_prop(plist, name, cb, udata) H5P_genplist_t *plist; IN: Property list to find property in const char *name; IN: Name of property to set - void *value; IN: Pointer to the value for the property + H5P_do_plist_op_t plist_op; IN: Pointer to the callback to invoke when the + property is found in the property list + H5P_do_pclass_op_t pclass_op; IN: Pointer to the callback to invoke when the + property is found in the property class + void *udata; IN: Pointer to the user data for the callback RETURNS Returns non-negative on success, negative on failure. DESCRIPTION - Sets a new value for a property in a property list. The property name - must exist or this routine will fail. If there is a 'set' callback routine - registered for this property, the 'value' will be passed to that routine and - any changes to the 'value' will be used when setting the property value. - The information pointed at by the 'value' pointer (possibly modified by the - 'set' callback) is copied into the property list value and may be changed - by the application making the H5Pset call without affecting the property - value. - - If the 'set' callback routine returns an error, the property value will - not be modified. This routine may not be called for zero-sized properties - and will return an error in that case. - + Finds a property in a property list and calls the callback with it. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t -H5P_set(H5P_genplist_t *plist, const char *name, const void *value) +static herr_t +H5P__do_prop(H5P_genplist_t *plist, const char *name, H5P_do_plist_op_t plist_op, + H5P_do_pclass_op_t pclass_op, void *udata) { H5P_genclass_t *tclass; /* Temporary class pointer */ H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(plist); HDassert(name); - HDassert(value); + HDassert(plist_op); + HDassert(pclass_op); /* Check if the property has been deleted */ - if(H5SL_search(plist->del,name)!=NULL) + if(NULL != H5SL_search(plist->del, name)) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Find property in changed list */ if(NULL != (prop = (H5P_genprop_t *)H5SL_search(plist->props, name))) { - /* Check for property size >0 */ - if(prop->size==0) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") - - /* Make a copy of the value and pass to 'set' callback */ - if(prop->set!=NULL) { - void *tmp_value; /* Temporary value for property */ - - /* Make a copy of the current value, in case the callback fails */ - if(NULL==(tmp_value=H5MM_malloc(prop->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed temporary property value") - HDmemcpy(tmp_value,value,prop->size); - - /* Call user's callback */ - if((*(prop->set))(plist->plist_id,name,prop->size,tmp_value) < 0) { - H5MM_xfree(tmp_value); - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") - } /* end if */ - - /* Copy new [possibly unchanged] value into property value */ - HDmemcpy(prop->value,tmp_value,prop->size); - - /* Free the temporary value buffer */ - H5MM_xfree(tmp_value); - } /* end if */ - /* No 'set' callback, just copy value */ - else - HDmemcpy(prop->value,value,prop->size); + /* Call the 'found in propery list' callback */ + if((*plist_op)(plist, name, prop, udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on property") } /* end if */ else { /* * Check if we should set class properties (up through list of parent classes also), * & make property 'set' callback. */ - tclass=plist->pclass; - while(tclass!=NULL) { - if(tclass->nprops>0) { + tclass = plist->pclass; + while(NULL != tclass) { + if(tclass->nprops > 0) { /* Find the property in the class */ - if((prop = (H5P_genprop_t *)H5SL_search(tclass->props,name))!=NULL) { - H5P_genprop_t *pcopy; /* Copy of property to insert into skip list */ - - /* Check for property size >0 */ - if(prop->size==0) - HGOTO_ERROR(H5E_PLIST,H5E_BADVALUE,FAIL,"property has zero size") - - /* Make a copy of the value and pass to 'set' callback */ - if(prop->set!=NULL) { - void *tmp_value; /* Temporary value for property */ - - /* Make a copy of the current value, in case the callback fails */ - if(NULL==(tmp_value=H5MM_malloc(prop->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed temporary property value") - HDmemcpy(tmp_value,value,prop->size); - - /* Call user's callback */ - if((*(prop->set))(plist->plist_id,name,prop->size,tmp_value) < 0) { - H5MM_xfree(tmp_value); - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") - } /* end if */ - - if((prop->cmp)(tmp_value,prop->value,prop->size)) { - /* Make a copy of the class's property */ - if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCOPY,FAIL,"Can't copy property") - - /* Copy new value into property value */ - HDmemcpy(pcopy->value,tmp_value,pcopy->size); - - /* Insert the changed property into the property list */ - if(H5P_add_prop(plist->props,pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list") - } /* end if */ - - /* Free the temporary value buffer */ - H5MM_xfree(tmp_value); - } /* end if */ - /* No 'set' callback, just copy value */ - else { - if((prop->cmp)(value,prop->value,prop->size)) { - /* Make a copy of the class's property */ - if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCOPY,FAIL,"Can't copy property") - - HDmemcpy(pcopy->value,value,pcopy->size); - - /* Insert the changed property into the property list */ - if(H5P_add_prop(plist->props,pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list") - } /* end if */ - } /* end else */ + if(NULL != (prop = (H5P_genprop_t *)H5SL_search(tclass->props, name))) { + /* Call the 'found in class' callback */ + if((*pclass_op)(plist, name, prop, udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on property") /* Leave */ - HGOTO_DONE(SUCCEED); - } /* end while */ + break; + } /* end if */ } /* end if */ /* Go up to parent class */ - tclass=tclass->parent; + tclass = tclass->parent; } /* end while */ /* If we get this far, then it wasn't in the list of changed properties, * nor in the properties in the class hierarchy, indicate an error */ - HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list") + if(NULL == tclass) + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "can't find property in skip list") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_set() */ +} /* H5P__do_prop() */ /*-------------------------------------------------------------------------- NAME - H5P_exist_plist + H5P__poke_plist_cb PURPOSE - Internal routine to query the existance of a property in a property list. + Internal callback for H5P__do_prop, to overwrite a property's value in a property list. USAGE - htri_t H5P_exist_plist(plist, name) - const H5P_genplist_t *plist; IN: Property list to check - const char *name; IN: Name of property to check for + herr_t H5P__poke_plist_cb(plist, name, value) + H5P_genplist_t *plist; IN: Property list to overwrite property in + const char *name; IN: Name of property to overwrite + H5P_genprop_t *prop; IN: Property to overwrite + void *udata; IN: User data for operation RETURNS - Success: Positive if the property exists in the property list, zero - if the property does not exist. - Failure: negative value + Returns non-negative on success, negative on failure. DESCRIPTION - This routine checks if a property exists within a property list. - + Overwrite a value for a property in a property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS + Called when the property is found in the property list. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t -H5P_exist_plist(const H5P_genplist_t *plist, const char *name) +static herr_t +H5P__poke_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, + void *_udata) { - htri_t ret_value = FAIL; /* return value */ + H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(plist); HDassert(name); + HDassert(prop); - /* Check for property in deleted property list */ - if(H5SL_search(plist->del, name) != NULL) - ret_value = FALSE; - else { - /* Check for property in changed property list */ - if(H5SL_search(plist->props, name) != NULL) - ret_value = TRUE; - else { - H5P_genclass_t *tclass; /* Temporary class pointer */ - - tclass = plist->pclass; - while(tclass != NULL) { - if(H5SL_search(tclass->props, name) != NULL) - HGOTO_DONE(TRUE) - - /* Go up to parent class */ - tclass = tclass->parent; - } /* end while */ + /* Check for property size >0 */ + if(0 == prop->size) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") - /* If we've reached here, we couldn't find the property */ - ret_value = FALSE; - } /* end else */ - } /* end else */ + /* Overwrite value in property */ + HDmemcpy(prop->value, udata->value, prop->size); done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_exist_plist() */ +} /* H5P__poke_plist_cb() */ /*-------------------------------------------------------------------------- NAME - H5P_exist_pclass + H5P__poke_pclass_cb PURPOSE - Internal routine to query the existance of a property in a property class. + Internal callback for H5P__do_prop, to overwrite a property's value in a property list. USAGE - herr_t H5P_exist_pclass(pclass, name) - H5P_genclass_t *pclass; IN: Property class to check - const char *name; IN: Name of property to check for + herr_t H5P__poke_pclass_cb(plist, name, value) + H5P_genplist_t *plist; IN: Property list to overwrite property in + const char *name; IN: Name of property to overwrite + H5P_genprop_t *prop; IN: Property to overwrite + void *udata; IN: User data for operation RETURNS - Success: Positive if the property exists in the property class, zero - if the property does not exist. - Failure: negative value + Returns non-negative on success, negative on failure. DESCRIPTION - This routine checks if a property exists within a property class. - + Overwrite a value for a property in a property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS + Called when the property is found in the property class. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -htri_t -H5P_exist_pclass(H5P_genclass_t *pclass, const char *name) +static herr_t +H5P__poke_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, + void *_udata) { - htri_t ret_value = FAIL; /* return value */ + H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ + H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC - HDassert(pclass); + /* Sanity check */ + HDassert(plist); HDassert(name); + HDassert(prop); + HDassert(prop->cmp); - /* Check for property in property list */ - if(H5SL_search(pclass->props, name) != NULL) - ret_value = TRUE; - else { - H5P_genclass_t *tclass; /* Temporary class pointer */ + /* Check for property size >0 */ + if(0 == prop->size) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") - tclass = pclass->parent; - while(tclass != NULL) { - if(H5SL_search(tclass->props, name) != NULL) - HGOTO_DONE(TRUE) + /* Make a copy of the class's property */ + if(NULL == (pcopy = H5P_dup_prop(prop, H5P_PROP_WITHIN_LIST))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") - /* Go up to parent class */ - tclass = tclass->parent; - } /* end while */ + HDmemcpy(pcopy->value, udata->value, pcopy->size); - /* If we've reached here, we couldn't find the property */ - ret_value = FALSE; - } /* end else */ + /* Insert the changed property into the property list */ + if(H5P_add_prop(plist->props, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list") done: + /* Cleanup on failure */ + if(ret_value < 0) + if(pcopy) + H5P_free_prop(pcopy); + FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_exist_pclass() */ +} /* H5P__poke_pclass_cb() */ /*-------------------------------------------------------------------------- NAME - H5P_get_size_plist + H5P_poke PURPOSE - Internal routine to query the size of a property in a property list. + Internal routine to overwrite a property's value in a property list. USAGE - herr_t H5P_get_size_plist(plist, name) - const H5P_genplist_t *plist; IN: Property list to check - const char *name; IN: Name of property to query - size_t *size; OUT: Size of property + herr_t H5P_poke(plist, name, value) + H5P_genplist_t *plist; IN: Property list to find property in + const char *name; IN: Name of property to overwrite + void *value; IN: Pointer to the value for the property RETURNS - Success: non-negative value - Failure: negative value + Returns non-negative on success, negative on failure. DESCRIPTION - This routine retrieves the size of a property's value in bytes. Zero- - sized properties are allowed and return a value of 0. - + Overwrites a property in a property list (i.e. a "shallow" copy over + the property value). The property name must exist or this routine will + fail. If there is a setget' callback routine registered for this property, + it is _NOT_ called. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS + This routine may not be called for zero-sized properties and will + return an error in that case. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P_get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size) +H5P_poke(H5P_genplist_t *plist, const char *name, const void *value) { - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value=SUCCEED; /* return value */ + H5P_prop_set_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_NOAPI(FAIL) + /* Sanity check */ HDassert(plist); HDassert(name); - HDassert(size); + HDassert(value); - /* Find property */ - if(NULL == (prop = H5P__find_prop_plist(plist, name))) + /* Find the property and set the value */ + udata.value = value; + if(H5P__do_prop(plist, name, H5P__poke_plist_cb, H5P__poke_pclass_cb, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to overwrite value") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P_poke() */ + + +/*-------------------------------------------------------------------------- + NAME + H5P__set_plist_cb + PURPOSE + Internal callback for H5P__do_prop, to set a property's value in a property list. + USAGE + herr_t H5P__set_plist_cb(plist, name, value) + H5P_genplist_t *plist; IN: Property list to set property in + const char *name; IN: Name of property to set + H5P_genprop_t *prop; IN: Property to set + void *udata; IN: User data for operation + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Sets a new value for a property in a property list. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Called when the property is found in the property list. + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static herr_t +H5P__set_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, + void *_udata) +{ + H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ + void *tmp_value = NULL; /* Temporary value for property */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(plist); + HDassert(name); + HDassert(prop); + + /* Check for property size >0 */ + if(0 == prop->size) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") + + /* Make a copy of the value and pass to 'set' callback */ + if(NULL != prop->set) { + /* Make a copy of the current value, in case the callback fails */ + if(NULL == (tmp_value = H5MM_malloc(prop->size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") + HDmemcpy(tmp_value, udata->value, prop->size); + + /* Call user's callback */ + if((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") + } /* end if */ + /* No 'set' callback, just copy value */ + else + tmp_value = (void *)udata->value; /* Casting away const OK -QAK */ + + /* Free any previous value for the property */ + if(NULL != prop->del) { + /* Call user's 'delete' callback */ + if((*(prop->del))(plist->plist_id, name, prop->size, prop->value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't release property value") + } /* end if */ + + /* Copy new [possibly unchanged] value into property value */ + HDmemcpy(prop->value, tmp_value, prop->size); + +done: + /* Free the temporary value buffer */ + if(tmp_value != NULL && tmp_value != udata->value) + H5MM_xfree(tmp_value); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P__set_plist_cb() */ + + +/*-------------------------------------------------------------------------- + NAME + H5P__set_pclass_cb + PURPOSE + Internal callback for H5P__do_prop, to set a property's value in a property list. + USAGE + herr_t H5P__set_pclass_cb(plist, name, value) + H5P_genplist_t *plist; IN: Property list to set property in + const char *name; IN: Name of property to set + H5P_genprop_t *prop; IN: Property to set + void *udata; IN: User data for operation + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Sets a new value for a property in a property list. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Called when the property is found in the property class. + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static herr_t +H5P__set_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, + void *_udata) +{ + H5P_prop_set_ud_t *udata = (H5P_prop_set_ud_t *)_udata; /* User data for callback */ + H5P_genprop_t *pcopy = NULL; /* Copy of property to insert into skip list */ + void *tmp_value = NULL; /* Temporary value for property */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(plist); + HDassert(name); + HDassert(prop); + HDassert(prop->cmp); + + /* Check for property size >0 */ + if(0 == prop->size) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") + + /* Make a copy of the value and pass to 'set' callback */ + if(NULL != prop->set) { + /* Make a copy of the current value, in case the callback fails */ + if(NULL == (tmp_value = H5MM_malloc(prop->size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") + HDmemcpy(tmp_value, udata->value, prop->size); + + /* Call user's callback */ + if((*(prop->set))(plist->plist_id, name, prop->size, tmp_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") + } /* end if */ + /* No 'set' callback, just copy value */ + else + tmp_value = (void *)udata->value; /* Casting away const OK -QAK */ + + /* Make a copy of the class's property */ + if(NULL == (pcopy = H5P_dup_prop(prop, H5P_PROP_WITHIN_LIST))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "Can't copy property") + + HDmemcpy(pcopy->value, tmp_value, pcopy->size); + + /* Insert the changed property into the property list */ + if(H5P_add_prop(plist->props, pcopy) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list") + +done: + /* Free the temporary value buffer */ + if(tmp_value != NULL && tmp_value != udata->value) + H5MM_xfree(tmp_value); + + /* Cleanup on failure */ + if(ret_value < 0) + if(pcopy) + H5P_free_prop(pcopy); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P__set_pclass_cb() */ + + +/*-------------------------------------------------------------------------- + NAME + H5P_set + PURPOSE + Internal routine to set a property's value in a property list. + USAGE + herr_t H5P_set(plist, name, value) + H5P_genplist_t *plist; IN: Property list to find property in + const char *name; IN: Name of property to set + void *value; IN: Pointer to the value for the property + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Sets a new value for a property in a property list. The property name + must exist or this routine will fail. If there is a 'set' callback routine + registered for this property, the 'value' will be passed to that routine and + any changes to the 'value' will be used when setting the property value. + The information pointed at by the 'value' pointer (possibly modified by the + 'set' callback) is copied into the property list value and may be changed + by the application making the H5Pset call without affecting the property + value. + + If the 'set' callback routine returns an error, the property value will + not be modified. This routine may not be called for zero-sized properties + and will return an error in that case. + + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5P_set(H5P_genplist_t *plist, const char *name, const void *value) +{ + H5P_prop_set_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(plist); + HDassert(name); + HDassert(value); + + /* Find the property and set the value */ + udata.value = value; + if(H5P__do_prop(plist, name, H5P__set_plist_cb, H5P__set_pclass_cb, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to set value") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P_set() */ + + +/*-------------------------------------------------------------------------- + NAME + H5P_exist_plist + PURPOSE + Internal routine to query the existance of a property in a property list. + USAGE + htri_t H5P_exist_plist(plist, name) + const H5P_genplist_t *plist; IN: Property list to check + const char *name; IN: Name of property to check for + RETURNS + Success: Positive if the property exists in the property list, zero + if the property does not exist. + Failure: negative value + DESCRIPTION + This routine checks if a property exists within a property list. + + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +htri_t +H5P_exist_plist(const H5P_genplist_t *plist, const char *name) +{ + htri_t ret_value = FAIL; /* return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(plist); + HDassert(name); + + /* Check for property in deleted property list */ + if(H5SL_search(plist->del, name) != NULL) + ret_value = FALSE; + else { + /* Check for property in changed property list */ + if(H5SL_search(plist->props, name) != NULL) + ret_value = TRUE; + else { + H5P_genclass_t *tclass; /* Temporary class pointer */ + + tclass = plist->pclass; + while(tclass != NULL) { + if(H5SL_search(tclass->props, name) != NULL) + HGOTO_DONE(TRUE) + + /* Go up to parent class */ + tclass = tclass->parent; + } /* end while */ + + /* If we've reached here, we couldn't find the property */ + ret_value = FALSE; + } /* end else */ + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P_exist_plist() */ + + +/*-------------------------------------------------------------------------- + NAME + H5P_exist_pclass + PURPOSE + Internal routine to query the existance of a property in a property class. + USAGE + herr_t H5P_exist_pclass(pclass, name) + H5P_genclass_t *pclass; IN: Property class to check + const char *name; IN: Name of property to check for + RETURNS + Success: Positive if the property exists in the property class, zero + if the property does not exist. + Failure: negative value + DESCRIPTION + This routine checks if a property exists within a property class. + + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +htri_t +H5P_exist_pclass(H5P_genclass_t *pclass, const char *name) +{ + htri_t ret_value = FAIL; /* return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(pclass); + HDassert(name); + + /* Check for property in property list */ + if(H5SL_search(pclass->props, name) != NULL) + ret_value = TRUE; + else { + H5P_genclass_t *tclass; /* Temporary class pointer */ + + tclass = pclass->parent; + while(tclass != NULL) { + if(H5SL_search(tclass->props, name) != NULL) + HGOTO_DONE(TRUE) + + /* Go up to parent class */ + tclass = tclass->parent; + } /* end while */ + + /* If we've reached here, we couldn't find the property */ + ret_value = FALSE; + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P_exist_pclass() */ + + +/*-------------------------------------------------------------------------- + NAME + H5P_get_size_plist + PURPOSE + Internal routine to query the size of a property in a property list. + USAGE + herr_t H5P_get_size_plist(plist, name) + const H5P_genplist_t *plist; IN: Property list to check + const char *name; IN: Name of property to query + size_t *size; OUT: Size of property + RETURNS + Success: non-negative value + Failure: negative value + DESCRIPTION + This routine retrieves the size of a property's value in bytes. Zero- + sized properties are allowed and return a value of 0. + + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5P_get_size_plist(const H5P_genplist_t *plist, const char *name, size_t *size) +{ + H5P_genprop_t *prop; /* Temporary property pointer */ + herr_t ret_value=SUCCEED; /* return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(plist); + HDassert(name); + HDassert(size); + + /* Find property */ + if(NULL == (prop = H5P__find_prop_plist(plist, name))) HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") /* Get property size */ @@ -3856,330 +4163,359 @@ done: /*-------------------------------------------------------------------------- NAME - H5P_peek_unsigned + H5P__peek_cb PURPOSE - Internal routine to quickly retrieve the value of a property in a property list. + Internal callback for H5P__do_prop, to peek at a property's value in a property list. USAGE - int H5P_peek_unsigned(plist, name) - H5P_genplist_t *plist; IN: Property list to check - const char *name; IN: Name of property to query + herr_t H5P__peek_plist_cb(plist, name, value) + H5P_genplist_t *plist; IN: Property list to peek property in + const char *name; IN: Name of property to peek + H5P_genprop_t *prop; IN: Property to peek + void *udata; IN: User data for operation RETURNS - Directly returns the value of the property in the list + Returns non-negative on success, negative on failure. DESCRIPTION - This function directly returns the value of a property in a property - list. Because this function is only able to just copy a particular property - value to the return value, there is no way to check for errors. We attempt - to make certain that bad things don't happen by validating that the size of - the property is the same as the size of the return type, but that can't - catch all errors. - This function does call the user's 'get' callback routine still. - + Peeks at a new value for a property in a property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS - No error checking! - Use with caution! + Called when the property is found in the property list and when it's found + for the property class. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -unsigned -H5P_peek_unsigned(H5P_genplist_t *plist, const char *name) +static herr_t +H5P__peek_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, + void *_udata) { - unsigned ret_value; /* return value */ + H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(UFAIL) + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(plist); HDassert(name); + HDassert(prop); + + /* Check for property size >0 */ + if(0 == prop->size) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") - /* Get the value to return, don't worry about the return value, we can't return it */ - H5P_get(plist,name,&ret_value); + /* Make a (shallow) copy of the value */ + HDmemcpy(udata->value, prop->value, prop->size); done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_peek_unsigned() */ +} /* H5P__peek_cb() */ /*-------------------------------------------------------------------------- NAME - H5P_peek_hid_t + H5P_peek PURPOSE - Internal routine to quickly retrieve the value of a property in a property list. + Internal routine to look at the value of a property in a property list. USAGE - hid_t H5P_peek_hid_t(plist, name) + herr_t H5P_peek(plist, name, value) H5P_genplist_t *plist; IN: Property list to check const char *name; IN: Name of property to query + void *value; OUT: Pointer to the buffer for the property value RETURNS - Directly returns the value of the property in the list + Returns non-negative on success, negative on failure. DESCRIPTION - This function directly returns the value of a property in a property - list. Because this function is only able to just copy a particular property - value to the return value, there is no way to check for errors. We attempt - to make certain that bad things don't happen by validating that the size of - the property is the same as the size of the return type, but that can't - catch all errors. - This function does call the user's 'get' callback routine still. - + Retrieves a "shallow" copy of the value for a property in a property + list. The property name must exist or this routine will fail. If there + is a 'get' callback routine registered for this property, it is _NOT_ + called. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS - No error checking! - Use with caution! + This routine may not be called for zero-sized properties and will + return an error in that case. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -hid_t -H5P_peek_hid_t(H5P_genplist_t *plist, const char *name) +herr_t +H5P_peek(H5P_genplist_t *plist, const char *name, void *value) { - hid_t ret_value; /* return value */ + H5P_prop_get_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + /* Sanity check */ HDassert(plist); HDassert(name); + HDassert(value); - /* Get the value to return, don't worry about the return value, we can't return it */ - H5P_get(plist,name,&ret_value); + /* Find the property and peek at the value */ + udata.value = value; + if(H5P__do_prop(plist, name, H5P__peek_cb, H5P__peek_cb, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to peek at value") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_peek_hid_t() */ +} /* H5P_peek() */ /*-------------------------------------------------------------------------- NAME - H5P_peek_voidp + H5P__get_cb PURPOSE - Internal routine to quickly retrieve the value of a property in a property list. + Internal callback for H5P__do_prop, to get a property's value in a property list. USAGE - void *H5P_peek_voidp(plist, name) - H5P_genplist_t *plist; IN: Property list to check - const char *name; IN: Name of property to query + herr_t H5P__get_plist_cb(plist, name, value) + H5P_genplist_t *plist; IN: Property list to get property in + const char *name; IN: Name of property to get + H5P_genprop_t *prop; IN: Property to get + void *udata; IN: User data for operation RETURNS - Directly returns the value of the property in the list + Returns non-negative on success, negative on failure. DESCRIPTION - This function directly returns the value of a property in a property - list. Because this function is only able to just copy a particular property - value to the return value, there is no way to check for errors. We attempt - to make certain that bad things don't happen by validating that the size of - the property is the same as the size of the return type, but that can't - catch all errors. - This function does call the user's 'get' callback routine still. - + Gets a new value for a property in a property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS - No error checking! - Use with caution! + Called when the property is found in the property list and when it's found + for the property class. EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -void * -H5P_peek_voidp(H5P_genplist_t *plist, const char *name) +static herr_t +H5P__get_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, + void *_udata) { - void * ret_value; /* return value */ + H5P_prop_get_ud_t *udata = (H5P_prop_get_ud_t *)_udata; /* User data for callback */ + void *tmp_value = NULL; /* Temporary value for property */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(plist); HDassert(name); + HDassert(prop); + + /* Check for property size >0 */ + if(0 == prop->size) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") + + /* Call the 'get' callback, if there is one */ + if(NULL != prop->get) { + /* Make a copy of the current value, in case the callback fails */ + if(NULL == (tmp_value = H5MM_malloc(prop->size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed temporary property value") + HDmemcpy(tmp_value, prop->value, prop->size); - /* Get the value to return, don't worry about the return value, we can't return it */ - H5P_get(plist,name,&ret_value); + /* Call user's callback */ + if((*(prop->get))(plist->plist_id, name, prop->size, tmp_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") + + /* Copy new [possibly unchanged] value into return value */ + HDmemcpy(udata->value, tmp_value, prop->size); + } /* end if */ + /* No 'get' callback, just copy value */ + else + HDmemcpy(udata->value, prop->value, prop->size); done: + /* Free the temporary value buffer */ + if(tmp_value) + H5MM_xfree(tmp_value); + FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_peek_voidp() */ +} /* H5P__get_cb() */ /*-------------------------------------------------------------------------- NAME - H5P_peek_size_t + H5P_get PURPOSE - Internal routine to quickly retrieve the value of a property in a property list. + Internal routine to query the value of a property in a property list. USAGE - hsize_t H5P_peek_size_t(plist, name) + herr_t H5P_get(plist, name, value) H5P_genplist_t *plist; IN: Property list to check const char *name; IN: Name of property to query + void *value; OUT: Pointer to the buffer for the property value RETURNS - Directly returns the value of the property in the list + Returns non-negative on success, negative on failure. DESCRIPTION - This function directly returns the value of a property in a property - list. Because this function is only able to just copy a particular property - value to the return value, there is no way to check for errors. We attempt - to make certain that bad things don't happen by validating that the size of - the property is the same as the size of the return type, but that can't - catch all errors. - This function does call the user's 'get' callback routine still. + Retrieves a copy of the value for a property in a property list. The + property name must exist or this routine will fail. If there is a + 'get' callback routine registered for this property, the copy of the + value of the property will first be passed to that routine and any changes + to the copy of the value will be used when returning the property value + from this routine. + If the 'get' callback routine returns an error, 'value' will not be + modified and this routine will return an error. This routine may not be + called for zero-sized properties. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS - No error checking! - Use with caution! EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -size_t -H5P_peek_size_t(H5P_genplist_t *plist, const char *name) +herr_t +H5P_get(H5P_genplist_t *plist, const char *name, void *value) { - size_t ret_value; /* return value */ + H5P_prop_get_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(UFAIL) + FUNC_ENTER_NOAPI(FAIL) + /* Sanity check */ HDassert(plist); HDassert(name); + HDassert(value); - /* Get the value to return, don't worry about the return value, we can't return it */ - H5P_get(plist,name,&ret_value); + /* Find the property and get the value */ + udata.value = value; + if(H5P__do_prop(plist, name, H5P__get_cb, H5P__get_cb, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to get value") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_peek_size_t() */ +} /* H5P_get() */ /*-------------------------------------------------------------------------- NAME - H5P_get + H5P__del_plist_cb PURPOSE - Internal routine to query the value of a property in a property list. + Internal callback for H5P__do_prop, to remove a property's value in a property list. USAGE - herr_t H5P_get(plist, name, value) - H5P_genplist_t *plist; IN: Property list to check - const char *name; IN: Name of property to query - void *value; OUT: Pointer to the buffer for the property value + herr_t H5P__del_plist_cb(plist, name, value) + H5P_genplist_t *plist; IN: Property list to remove property from + const char *name; IN: Name of property to remove + H5P_genprop_t *prop; IN: Property to remove + void *udata; IN: User data for operation RETURNS Returns non-negative on success, negative on failure. DESCRIPTION - Retrieves a copy of the value for a property in a property list. The - property name must exist or this routine will fail. If there is a - 'get' callback routine registered for this property, the copy of the - value of the property will first be passed to that routine and any changes - to the copy of the value will be used when returning the property value - from this routine. - If the 'get' callback routine returns an error, 'value' will not be - modified and this routine will return an error. This routine may not be - called for zero-sized properties. - + Remove a property in a property list. Called when the + property is found in the property list. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -herr_t -H5P_get(const H5P_genplist_t *plist, const char *name, void *value) +static herr_t +H5P__del_plist_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, + void H5_ATTR_UNUSED *_udata) { - H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genprop_t *prop; /* Temporary property pointer */ - herr_t ret_value=SUCCEED; /* Return value */ + char *del_name = NULL; /* Pointer to deleted name */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(plist); HDassert(name); - HDassert(value); + HDassert(prop); - /* Check if the property has been deleted */ - if(H5SL_search(plist->del,name)!=NULL) - HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, FAIL, "property doesn't exist") + /* Pass value to 'close' callback, if it exists */ + if(NULL != prop->del) { + /* Call user's callback */ + if((*(prop->del))(plist->plist_id, name, prop->size, prop->value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't release property value") + } /* end if */ - /* Find property */ - if((prop = (H5P_genprop_t *)H5SL_search(plist->props,name))!=NULL) { - /* Check for property size >0 */ - if(prop->size==0) - HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "property has zero size") + /* Duplicate string for insertion into new deleted property skip list */ + if(NULL == (del_name = H5MM_xstrdup(name))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") - /* Make a copy of the value and pass to 'get' callback */ - if(prop->get!=NULL) { - void *tmp_value; /* Temporary value for property */ + /* Insert property name into deleted list */ + if(H5SL_insert(plist->del, del_name, del_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into deleted skip list") - /* Make a copy of the current value, in case the callback fails */ - if(NULL==(tmp_value=H5MM_malloc(prop->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed temporary property value") - HDmemcpy(tmp_value,prop->value,prop->size); + /* Remove the property from the skip list */ + if(NULL == H5SL_remove(plist->props, prop->name)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove property from skip list") - /* Call user's callback */ - if((*(prop->get))(plist->plist_id,name,prop->size,tmp_value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't get property value") + /* Free the property, ignoring return value, nothing we can do */ + H5P_free_prop(prop); - /* Copy new [possibly unchanged] value into return value */ - HDmemcpy(value,tmp_value,prop->size); + /* Decrement the number of properties in list */ + plist->nprops--; - /* Free the temporary value buffer */ - H5MM_xfree(tmp_value); - } /* end if */ - /* No 'get' callback, just copy value */ - else - HDmemcpy(value,prop->value,prop->size); - } /* end if */ - else { - /* - * Check if we should get class properties (up through list of parent classes also), - * & make property 'get' callback. - */ - tclass=plist->pclass; - while(tclass!=NULL) { - if(tclass->nprops>0) { - /* Find the property in the class */ - if((prop = (H5P_genprop_t *)H5SL_search(tclass->props,name))!=NULL) { - /* Check for property size >0 */ - if(prop->size==0) - HGOTO_ERROR(H5E_PLIST,H5E_BADVALUE,FAIL,"property has zero size") +done: + /* Error cleanup */ + if(ret_value < 0) + if(del_name) + H5MM_xfree(del_name); - /* Call the 'get' callback, if there is one */ - if(prop->get!=NULL) { - void *tmp_value; /* Temporary value for property */ + FUNC_LEAVE_NOAPI(ret_value) +} /* H5P__del_plist_cb() */ - /* Make a copy of the current value, in case the callback fails */ - if(NULL==(tmp_value=H5MM_malloc(prop->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed temporary property value") - HDmemcpy(tmp_value,prop->value,prop->size); + +/*-------------------------------------------------------------------------- + NAME + H5P__del_pclass_cb + PURPOSE + Internal callback for H5P__do_prop, to remove a property's value in a property list. + USAGE + herr_t H5P__del_pclass_cb(plist, name, value) + H5P_genplist_t *plist; IN: Property list to remove property from + const char *name; IN: Name of property to remove + H5P_genprop_t *prop; IN: Property to remove + void *udata; IN: User data for operation + RETURNS + Returns non-negative on success, negative on failure. + DESCRIPTION + Remove a property in a property list. Called when the + property is found in the property class. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static herr_t +H5P__del_pclass_cb(H5P_genplist_t *plist, const char *name, H5P_genprop_t *prop, + void H5_ATTR_UNUSED *_udata) +{ + char *del_name = NULL; /* Pointer to deleted name */ + void *tmp_value = NULL; /* Temporary value for property */ + herr_t ret_value = SUCCEED; /* Return value */ - /* Call user's callback */ - if((*(prop->get))(plist->plist_id,name,prop->size,tmp_value) < 0) { - H5MM_xfree(tmp_value); - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set property value") - } /* end if */ + FUNC_ENTER_STATIC - if((prop->cmp)(tmp_value,prop->value,prop->size)) { - H5P_genprop_t *pcopy; /* Copy of property to insert into skip list */ + /* Sanity check */ + HDassert(plist); + HDassert(name); + HDassert(prop); - /* Make a copy of the class's property */ - if((pcopy=H5P_dup_prop(prop,H5P_PROP_WITHIN_LIST)) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTCOPY,FAIL,"Can't copy property") + /* Pass value to 'del' callback, if it exists */ + if(NULL != prop->del) { + /* Allocate space for a temporary copy of the property value */ + if(NULL == (tmp_value = H5MM_malloc(prop->size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary property value") + HDmemcpy(tmp_value, prop->value, prop->size); - /* Copy new value into property value */ - HDmemcpy(pcopy->value,tmp_value,prop->size); + /* Call user's callback */ + if((*(prop->del))(plist->plist_id, name, prop->size, tmp_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't close property value") + } /* end if */ - /* Insert the changed property into the property list */ - if(H5P_add_prop(plist->props,pcopy) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL,"Can't insert changed property into skip list") - } /* end if */ + /* Duplicate string for insertion into new deleted property skip list */ + if(NULL == (del_name = H5MM_xstrdup(name))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") - /* Copy new [possibly unchanged] value into return value */ - HDmemcpy(value,tmp_value,prop->size); + /* Insert property name into deleted list */ + if(H5SL_insert(plist->del, del_name, del_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into deleted skip list") - /* Free the temporary value buffer */ - H5MM_xfree(tmp_value); - } /* end if */ - /* No 'get' callback, just copy value */ - else - HDmemcpy(value,prop->value,prop->size); - - /* Leave */ - HGOTO_DONE(SUCCEED); - } /* end while */ - } /* end if */ + /* Decrement the number of properties in list */ + plist->nprops--; - /* Go up to parent class */ - tclass=tclass->parent; - } /* end while */ +done: + /* Free the temporary value buffer */ + if(tmp_value) + H5MM_xfree(tmp_value); - /* If we get this far, then it wasn't in the list of changed properties, - * nor in the properties in the class hierarchy, indicate an error - */ - HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list") - } /* end else */ + /* Error cleanup */ + if(ret_value < 0) + if(del_name) + H5MM_xfree(del_name); -done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5P_get() */ +} /* H5P__del_pclass_cb() */ /*-------------------------------------------------------------------------- @@ -4209,104 +4545,19 @@ done: REVISION LOG --------------------------------------------------------------------------*/ herr_t -H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name) +H5P_remove(H5P_genplist_t *plist, const char *name) { - H5P_genclass_t *tclass; /* Temporary class pointer */ - H5P_genprop_t *prop; /* Temporary property pointer */ - char *del_name; /* Pointer to deleted name */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + /* Sanity check */ HDassert(plist); HDassert(name); - /* Indicate that the property isn't in the list if it has been deleted already */ - if(H5SL_search(plist->del,name)!=NULL) - HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list") - - /* Get the property node from the changed property skip list */ - if((prop = (H5P_genprop_t *)H5SL_search(plist->props,name))!=NULL) { - /* Pass value to 'close' callback, if it exists */ - if(prop->del!=NULL) { - /* Call user's callback */ - if((*(prop->del))(plist_id,name,prop->size,prop->value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't close property value") - } /* end if */ - - /* Duplicate string for insertion into new deleted property skip list */ - if((del_name=H5MM_xstrdup(name)) == NULL) - HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,FAIL,"memory allocation failed") - - /* Insert property name into deleted list */ - if(H5SL_insert(plist->del,del_name,del_name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into deleted skip list") - - /* Remove the property from the skip list */ - if(H5SL_remove(plist->props,prop->name) == NULL) - HGOTO_ERROR(H5E_PLIST,H5E_CANTDELETE,FAIL,"can't remove property from skip list") - - /* Free the property, ignoring return value, nothing we can do */ - H5P_free_prop(prop); - - /* Decrement the number of properties in list */ - plist->nprops--; - } /* end if */ - /* Walk through all the properties in the class hierarchy, looking for the property */ - else { - /* - * Check if we should delete class properties (up through list of parent classes also), - * & make property 'delete' callback. - */ - tclass=plist->pclass; - while(tclass!=NULL) { - if(tclass->nprops>0) { - /* Find the property in the class */ - if((prop=H5P_find_prop_pclass(tclass,name))!=NULL) { - /* Pass value to 'del' callback, if it exists */ - if(prop->del!=NULL) { - void *tmp_value; /* Temporary value buffer */ - - /* Allocate space for a temporary copy of the property value */ - if(NULL==(tmp_value=H5MM_malloc(prop->size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for temporary property value") - HDmemcpy(tmp_value,prop->value,prop->size); - - /* Call user's callback */ - if((*(prop->del))(plist_id,name,prop->size,tmp_value) < 0) { - H5MM_xfree(tmp_value); - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't close property value") - } /* end if */ - - /* Release the temporary value buffer */ - H5MM_xfree(tmp_value); - } /* end if */ - - /* Duplicate string for insertion into new deleted property skip list */ - if((del_name=H5MM_xstrdup(name)) == NULL) - HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,FAIL,"memory allocation failed") - - /* Insert property name into deleted list */ - if(H5SL_insert(plist->del,del_name,del_name) < 0) - HGOTO_ERROR(H5E_PLIST,H5E_CANTINSERT,FAIL,"can't insert property into deleted skip list") - - /* Decrement the number of properties in list */ - plist->nprops--; - - /* Leave */ - HGOTO_DONE(SUCCEED); - } /* end while */ - } /* end if */ - - /* Go up to parent class */ - tclass=tclass->parent; - } /* end while */ - - /* If we get this far, then it wasn't in the list of changed properties, - * nor in the properties in the class hierarchy, indicate an error - */ - HGOTO_ERROR(H5E_PLIST,H5E_NOTFOUND,FAIL,"can't find property in skip list") - } /* end else */ + /* Find the property and get the value */ + if(H5P__do_prop(plist, name, H5P__del_plist_cb, H5P__del_pclass_cb, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTOPERATE, FAIL, "can't operate on plist to remove value") done: FUNC_LEAVE_NOAPI(ret_value) @@ -4364,7 +4615,7 @@ H5P_copy_prop_plist(hid_t dst_id, hid_t src_id, const char *name) /* If the property exists in the destination alread */ if(NULL != H5P__find_prop_plist(dst_plist, name)) { /* Delete the property from the destination list, calling the 'close' callback if necessary */ - if(H5P_remove(dst_id,dst_plist,name) < 0) + if(H5P_remove(dst_plist, name) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "unable to remove property") /* Get the pointer to the source property */ diff --git a/src/H5Plapl.c b/src/H5Plapl.c index e3b3c4f..93e2531 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -55,22 +55,26 @@ /* Definitions for external link prefix */ #define H5L_ACS_ELINK_PREFIX_SIZE sizeof(char *) #define H5L_ACS_ELINK_PREFIX_DEF NULL /*default is no prefix */ -#define H5L_ACS_ELINK_PREFIX_ENC H5P_lacc_elink_pref_enc -#define H5L_ACS_ELINK_PREFIX_DEC H5P_lacc_elink_pref_dec -#define H5L_ACS_ELINK_PREFIX_DEL H5P_lacc_elink_pref_del -#define H5L_ACS_ELINK_PREFIX_COPY H5P_lacc_elink_pref_copy -#define H5L_ACS_ELINK_PREFIX_CMP H5P_lacc_elink_pref_cmp -#define H5L_ACS_ELINK_PREFIX_CLOSE H5P_lacc_elink_pref_close +#define H5L_ACS_ELINK_PREFIX_SET H5P__lacc_elink_pref_set +#define H5L_ACS_ELINK_PREFIX_GET H5P__lacc_elink_pref_get +#define H5L_ACS_ELINK_PREFIX_ENC H5P__lacc_elink_pref_enc +#define H5L_ACS_ELINK_PREFIX_DEC H5P__lacc_elink_pref_dec +#define H5L_ACS_ELINK_PREFIX_DEL H5P__lacc_elink_pref_del +#define H5L_ACS_ELINK_PREFIX_COPY H5P__lacc_elink_pref_copy +#define H5L_ACS_ELINK_PREFIX_CMP H5P__lacc_elink_pref_cmp +#define H5L_ACS_ELINK_PREFIX_CLOSE H5P__lacc_elink_pref_close /* Definitions for setting fapl of external link access */ #define H5L_ACS_ELINK_FAPL_SIZE sizeof(hid_t) #define H5L_ACS_ELINK_FAPL_DEF H5P_DEFAULT -#define H5L_ACS_ELINK_FAPL_ENC H5P_lacc_elink_fapl_enc -#define H5L_ACS_ELINK_FAPL_DEC H5P_lacc_elink_fapl_dec -#define H5L_ACS_ELINK_FAPL_DEL H5P_lacc_elink_fapl_del -#define H5L_ACS_ELINK_FAPL_COPY H5P_lacc_elink_fapl_copy -#define H5L_ACS_ELINK_FAPL_CMP H5P_lacc_elink_fapl_cmp -#define H5L_ACS_ELINK_FAPL_CLOSE H5P_lacc_elink_fapl_close +#define H5L_ACS_ELINK_FAPL_SET H5P__lacc_elink_fapl_set +#define H5L_ACS_ELINK_FAPL_GET H5P__lacc_elink_fapl_get +#define H5L_ACS_ELINK_FAPL_ENC H5P__lacc_elink_fapl_enc +#define H5L_ACS_ELINK_FAPL_DEC H5P__lacc_elink_fapl_dec +#define H5L_ACS_ELINK_FAPL_DEL H5P__lacc_elink_fapl_del +#define H5L_ACS_ELINK_FAPL_COPY H5P__lacc_elink_fapl_copy +#define H5L_ACS_ELINK_FAPL_CMP H5P__lacc_elink_fapl_cmp +#define H5L_ACS_ELINK_FAPL_CLOSE H5P__lacc_elink_fapl_close /* Definitions for file access flags for external link traversal */ #define H5L_ACS_ELINK_FLAGS_SIZE sizeof(unsigned) @@ -98,21 +102,25 @@ /********************/ /* Property class callbacks */ -static herr_t H5P_lacc_reg_prop(H5P_genclass_t *pclass); +static herr_t H5P__lacc_reg_prop(H5P_genclass_t *pclass); /* Property list callbacks */ -static herr_t H5P_lacc_elink_pref_enc(const void *value, void **_pp, size_t *size); -static herr_t H5P_lacc_elink_pref_dec(const void **_pp, void *value); -static herr_t H5P_lacc_elink_pref_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P_lacc_elink_pref_copy(const char* name, size_t size, void* value); -static int H5P_lacc_elink_pref_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P_lacc_elink_pref_close(const char* name, size_t size, void* value); -static herr_t H5P_lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size); -static herr_t H5P_lacc_elink_fapl_dec(const void **_pp, void *value); -static herr_t H5P_lacc_elink_fapl_del(hid_t prop_id, const char* name, size_t size, void* value); -static herr_t H5P_lacc_elink_fapl_copy(const char* name, size_t size, void* value); -static int H5P_lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t size); -static herr_t H5P_lacc_elink_fapl_close(const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_set(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_enc(const void *value, void **_pp, size_t *size); +static herr_t H5P__lacc_elink_pref_dec(const void **_pp, void *value); +static herr_t H5P__lacc_elink_pref_del(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_pref_copy(const char* name, size_t size, void* value); +static int H5P__lacc_elink_pref_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__lacc_elink_pref_close(const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_fapl_set(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_fapl_get(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size); +static herr_t H5P__lacc_elink_fapl_dec(const void **_pp, void *value); +static herr_t H5P__lacc_elink_fapl_del(hid_t prop_id, const char* name, size_t size, void* value); +static herr_t H5P__lacc_elink_fapl_copy(const char* name, size_t size, void* value); +static int H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__lacc_elink_fapl_close(const char* name, size_t size, void* value); /*********************/ @@ -128,7 +136,7 @@ const H5P_libclass_t H5P_CLS_LACC[1] = {{ &H5P_CLS_LINK_ACCESS_g, /* Pointer to class */ &H5P_CLS_LINK_ACCESS_ID_g, /* Pointer to class ID */ &H5P_LST_LINK_ACCESS_ID_g, /* Pointer to default property list ID */ - H5P_lacc_reg_prop, /* Default property registration routine */ + H5P__lacc_reg_prop, /* Default property registration routine */ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ @@ -158,7 +166,7 @@ static const H5L_elink_cb_t H5L_def_elink_cb_g = H5L_ACS_ELINK_CB_DEF; /* Defaul /*------------------------------------------------------------------------- - * Function: H5P_lacc_reg_prop + * Function: H5P__lacc_reg_prop * * Purpose: Register the dataset creation property list class's properties * @@ -167,18 +175,14 @@ static const H5L_elink_cb_t H5L_def_elink_cb_g = H5L_ACS_ELINK_CB_DEF; /* Defaul * Programmer: Quincey Koziol * October 31, 2006 * - * Modifications: - * Vailin Choi, Sept. 12th 2008 - * Register the setting of file access property list for link access - * *------------------------------------------------------------------------- */ static herr_t -H5P_lacc_reg_prop(H5P_genclass_t *pclass) +H5P__lacc_reg_prop(H5P_genclass_t *pclass) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Register property for number of links traversed */ if(H5P_register_real(pclass, H5L_ACS_NLINKS_NAME, H5L_ACS_NLINKS_SIZE, &H5L_def_nlinks_g, @@ -188,13 +192,13 @@ H5P_lacc_reg_prop(H5P_genclass_t *pclass) /* Register property for external link prefix */ if(H5P_register_real(pclass, H5L_ACS_ELINK_PREFIX_NAME, H5L_ACS_ELINK_PREFIX_SIZE, &H5L_def_elink_prefix_g, - NULL, NULL, NULL, H5L_ACS_ELINK_PREFIX_ENC, H5L_ACS_ELINK_PREFIX_DEC, + NULL, H5L_ACS_ELINK_PREFIX_SET, H5L_ACS_ELINK_PREFIX_GET, H5L_ACS_ELINK_PREFIX_ENC, H5L_ACS_ELINK_PREFIX_DEC, H5L_ACS_ELINK_PREFIX_DEL, H5L_ACS_ELINK_PREFIX_COPY, H5L_ACS_ELINK_PREFIX_CMP, H5L_ACS_ELINK_PREFIX_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register fapl for link access */ if(H5P_register_real(pclass, H5L_ACS_ELINK_FAPL_NAME, H5L_ACS_ELINK_FAPL_SIZE, &H5L_def_fapl_id_g, - NULL, NULL, NULL, H5L_ACS_ELINK_FAPL_ENC, H5L_ACS_ELINK_FAPL_DEC, + NULL, H5L_ACS_ELINK_FAPL_SET, H5L_ACS_ELINK_FAPL_GET, H5L_ACS_ELINK_FAPL_ENC, H5L_ACS_ELINK_FAPL_DEC, H5L_ACS_ELINK_FAPL_DEL, H5L_ACS_ELINK_FAPL_COPY, H5L_ACS_ELINK_FAPL_CMP, H5L_ACS_ELINK_FAPL_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -212,11 +216,97 @@ H5P_lacc_reg_prop(H5P_genclass_t *pclass) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_reg_prop() */ +} /* end H5P__lacc_reg_prop() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_enc + * Function: H5P__lacc_elink_fapl_set + * + * Purpose: Copies an external link FAPL property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__lacc_elink_fapl_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Get the FAPL ID */ + l_fapl_id = *(const hid_t *)value; + + /* Duplicate the FAPL, if it's non-default */ + if(l_fapl_id != H5P_DEFAULT) { + H5P_genplist_t *l_fapl_plist; + + if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") + if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__lacc_elink_fapl_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__lacc_elink_fapl_get + * + * Purpose: Copies an external link FAPL property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__lacc_elink_fapl_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + hid_t l_fapl_id; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Get the FAPL ID */ + l_fapl_id = *(const hid_t *)value; + + /* Duplicate the FAPL, if it's non-default */ + if(l_fapl_id != H5P_DEFAULT) { + H5P_genplist_t *l_fapl_plist; + + if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") + if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__lacc_elink_fapl_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__lacc_elink_fapl_enc * * Purpose: Callback routine which is called whenever the elink FAPL * property in the dataset access property list is @@ -231,7 +321,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) +H5P__lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) { const hid_t *elink_fapl = (const hid_t *)value; /* Property to encode */ uint8_t **pp = (uint8_t **)_pp; @@ -240,7 +330,7 @@ H5P_lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) size_t fapl_size = 0; /* FAPL's encoded size */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check for non-default FAPL */ if(*elink_fapl != H5P_DEFAULT) { @@ -284,11 +374,11 @@ H5P_lacc_elink_fapl_enc(const void *value, void **_pp, size_t *size) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_enc() */ +} /* end H5P__lacc_elink_fapl_enc() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_dec + * Function: H5P__lacc_elink_fapl_dec * * Purpose: Callback routine which is called whenever the elink FAPL * property in the dataset access property list is @@ -303,15 +393,16 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_lacc_elink_fapl_dec(const void **_pp, void *_value) +H5P__lacc_elink_fapl_dec(const void **_pp, void *_value) { hid_t *elink_fapl = (hid_t *)_value; /* The elink FAPL value */ const uint8_t **pp = (const uint8_t **)_pp; hbool_t non_default_fapl; /* Whether the FAPL is non-default */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(pp); HDassert(*pp); HDassert(elink_fapl); @@ -342,11 +433,11 @@ H5P_lacc_elink_fapl_dec(const void **_pp, void *_value) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_dec() */ +} /* end H5P__lacc_elink_fapl_dec() */ /*-------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_del + * Function: H5P__lacc_elink_fapl_del * * Purpose: Close the FAPL for link access * @@ -360,27 +451,30 @@ done: */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_fapl_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { hid_t l_fapl_id; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(value); + /* Get the FAPL ID */ l_fapl_id = (*(const hid_t *)value); - if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) + /* Close the FAPL */ + if(l_fapl_id != H5P_DEFAULT && H5I_dec_ref(l_fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_del() */ +} /* end H5P__lacc_elink_fapl_del() */ /*-------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_copy + * Function: H5P__lacc_elink_fapl_copy * * Purpose: Copy the FAPL for link access * @@ -394,34 +488,36 @@ done: */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_fapl_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { hid_t l_fapl_id; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(value); + /* Get the FAPL ID */ l_fapl_id = (*(const hid_t *)value); - if(l_fapl_id > H5P_DEFAULT) { + /* Duplicate the FAPL, if it's non-default */ + if(l_fapl_id != H5P_DEFAULT) { H5P_genplist_t *l_fapl_plist; if(NULL == (l_fapl_plist = (H5P_genplist_t *)H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "can't get property list") if(((*(hid_t *)value) = H5P_copy_plist(l_fapl_plist, FALSE)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file access properties") + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy file access property list") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_copy() */ +} /* end H5P__lacc_elink_fapl_copy() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_cmp + * Function: H5P__lacc_elink_fapl_cmp * * Purpose: Callback routine which is called whenever the elink FAPL * property in the link access property list is @@ -435,14 +531,14 @@ done: *------------------------------------------------------------------------- */ static int -H5P_lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) +H5P__lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { const hid_t *fapl1 = (const hid_t *)value1; const hid_t *fapl2 = (const hid_t *)value2; H5P_genplist_t *obj1, *obj2; /* Property lists to compare */ int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check for comparison with default value */ if(*fapl1 == 0 && *fapl2 > 0) HGOTO_DONE(1); @@ -464,11 +560,11 @@ H5P_lacc_elink_fapl_cmp(const void *value1, const void *value2, size_t H5_ATTR_U done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_cmp() */ +} /* end H5P__lacc_elink_fapl_cmp() */ /*-------------------------------------------------------------------------- - * Function: H5P_lacc_elink_fapl_close + * Function: H5P__lacc_elink_fapl_close * * Purpose: Close the FAPL for link access * @@ -482,26 +578,88 @@ done: */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_fapl_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { hid_t l_fapl_id; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC + /* Sanity check */ HDassert(value); + /* Get the FAPL ID */ l_fapl_id = (*(const hid_t *)value); + + /* Close the FAPL */ if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_fapl_close() */ +} /* end H5P__lacc_elink_fapl_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__lacc_elink_pref_set + * + * Purpose: Copies an external link prefix property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__lacc_elink_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(value); + + /* Copy the prefix */ + *(char **)value = H5MM_xstrdup(*(const char **)value); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__lacc_elink_pref_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__lacc_elink_pref_get + * + * Purpose: Copies an external link prefix property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__lacc_elink_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(value); + + /* Copy the prefix */ + *(char **)value = H5MM_xstrdup(*(const char **)value); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__lacc_elink_pref_get() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_enc + * Function: H5P__lacc_elink_pref_enc * * Purpose: Callback routine which is called whenever the elink flags * property in the dataset access property list is @@ -516,7 +674,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5P_lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) +H5P__lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) { const char *elink_pref = *(const char * const *)value; uint8_t **pp = (uint8_t **)_pp; @@ -524,7 +682,7 @@ H5P_lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) uint64_t enc_value; unsigned enc_size; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t)); @@ -553,11 +711,11 @@ H5P_lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) *size += len; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_lacc_elink_pref_enc() */ +} /* end H5P__lacc_elink_pref_enc() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_dec + * Function: H5P__lacc_elink_pref_dec * * Purpose: Callback routine which is called whenever the elink prefix * property in the dataset access property list is @@ -572,7 +730,7 @@ H5P_lacc_elink_pref_enc(const void *value, void **_pp, size_t *size) *------------------------------------------------------------------------- */ static herr_t -H5P_lacc_elink_pref_dec(const void **_pp, void *_value) +H5P__lacc_elink_pref_dec(const void **_pp, void *_value) { char **elink_pref = (char **)_value; const uint8_t **pp = (const uint8_t **)_pp; @@ -581,7 +739,7 @@ H5P_lacc_elink_pref_dec(const void **_pp, void *_value) unsigned enc_size; /* Size of encoded property */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(pp); HDassert(*pp); @@ -610,11 +768,11 @@ H5P_lacc_elink_pref_dec(const void **_pp, void *_value) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_pref_dec() */ +} /* end H5P__lacc_elink_pref_dec() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_del + * Function: H5P__lacc_elink_pref_del * * Purpose: Frees memory used to store the external link prefix string * @@ -627,20 +785,20 @@ done: */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(value); H5MM_xfree(*(void **)value); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_lacc_elink_pref_del() */ +} /* end H5P__lacc_elink_pref_del() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_copy + * Function: H5P__lacc_elink_pref_copy * * Purpose: Creates a copy of the external link prefix string * @@ -653,20 +811,20 @@ H5P_lacc_elink_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(value); *(char **)value = H5MM_xstrdup(*(const char **)value); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_lacc_elink_pref_copy() */ +} /* end H5P__lacc_elink_pref_copy() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_cmp + * Function: H5P__lacc_elink_pref_cmp * * Purpose: Callback routine which is called whenever the elink prefix * property in the dataset creation property list is @@ -680,13 +838,13 @@ H5P_lacc_elink_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED *------------------------------------------------------------------------- */ static int -H5P_lacc_elink_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) +H5P__lacc_elink_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_UNUSED size) { const char *pref1 = *(const char * const *)value1; const char *pref2 = *(const char * const *)value2; int ret_value = 0; - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR if(NULL == pref1 && NULL != pref2) HGOTO_DONE(1); @@ -697,11 +855,11 @@ H5P_lacc_elink_pref_cmp(const void *value1, const void *value2, size_t H5_ATTR_U done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_lacc_elink_pref_cmp() */ +} /* end H5P__lacc_elink_pref_cmp() */ /*------------------------------------------------------------------------- - * Function: H5P_lacc_elink_pref_close + * Function: H5P__lacc_elink_pref_close * * Purpose: Frees memory used to store the external link prefix string * @@ -714,16 +872,16 @@ done: */ /* ARGSUSED */ static herr_t -H5P_lacc_elink_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +H5P__lacc_elink_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(value); H5MM_xfree(*(void **)value); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P_lacc_elink_pref_close() */ +} /* end H5P__lacc_elink_pref_close() */ /*------------------------------------------------------------------------- @@ -831,7 +989,6 @@ herr_t H5Pset_elink_prefix(hid_t plist_id, const char *prefix) { H5P_genplist_t *plist; /* Property list pointer */ - char *my_prefix; /* Copy of prefix string */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -841,19 +998,8 @@ H5Pset_elink_prefix(hid_t plist_id, const char *prefix) if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - /* Get current prefix value */ - if(H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get prefix info") - - /* Free existing prefix, if there is one */ - H5MM_xfree(my_prefix); - - /* Make a copy of the user's prefix string */ - if(NULL == (my_prefix = H5MM_xstrdup(prefix))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy prefix") - /* Set prefix */ - if(H5P_set(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) + if(H5P_set(plist, H5L_ACS_ELINK_PREFIX_NAME, &prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set prefix info") done: @@ -893,7 +1039,7 @@ H5Pget_elink_prefix(hid_t plist_id, char *prefix, size_t size) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the current prefix */ - if(H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) + if(H5P_peek(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix") /* Check for prefix being set */ @@ -931,9 +1077,8 @@ done: herr_t H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id) { - H5P_genplist_t *plist, *fapl_plist; /* Property list pointer */ - hid_t l_fapl_id, new_fapl_id; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ii", lapl_id, fapl_id); @@ -942,23 +1087,8 @@ H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id) if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link access property list"); - /* Get the current file access property list for the link access */ - if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &l_fapl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl") - - /* Close the current file access property list if set */ - if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") - - if(NULL == (fapl_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access property list"); - - /* Make a copy of the property list for FAPL_ID */ - if((new_fapl_id = H5P_copy_plist(fapl_plist, FALSE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file access properties") - /* Set the file access property list for the link access */ - if(H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &new_fapl_id) < 0) + if(H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fapl for link") done: @@ -982,9 +1112,8 @@ done: hid_t H5Pget_elink_fapl(hid_t lapl_id) { - H5P_genplist_t *plist, *fapl_plist; /* Property list pointer */ - hid_t l_fapl_id; - hid_t ret_value=FAIL; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", lapl_id); @@ -993,18 +1122,9 @@ H5Pget_elink_fapl(hid_t lapl_id) if(NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &l_fapl_id) < 0) + if(H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links") - if(l_fapl_id > H5P_DEFAULT) { - if(NULL==(fapl_plist = H5P_object_verify(l_fapl_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); - - if((ret_value = H5P_copy_plist(fapl_plist, TRUE)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file access properties") - } else - ret_value = l_fapl_id; - done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_elink_fapl() */ @@ -1017,7 +1137,7 @@ done: * external link. This should be either H5F_ACC_RDONLY or * H5F_ACC_RDWR, or H5F_ACC_DEFAULT to unset the value. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner * Tuesday, December 9, 2008 @@ -1056,7 +1176,7 @@ done: * Purpose: Gets the file access flags to be used when traversing an * external link. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner * Tuesday, December 9, 2008 @@ -1077,8 +1197,8 @@ H5Pget_elink_acc_flags(hid_t lapl_id, unsigned *flags) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get flags */ - if (flags) - if(H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, flags)<0) + if(flags) + if(H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, flags) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "can't get access flags") done: @@ -1093,7 +1213,7 @@ done: * external link. This should be either H5F_ACC_RDONLY or * H5F_ACC_RDWR. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner * Tuesday, December 15, 2008 @@ -1138,7 +1258,7 @@ done: * Purpose: Gets the file access flags to be used when traversing an * external link. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner * Tuesday, December 15, 2008 @@ -1160,12 +1280,11 @@ H5Pget_elink_cb(hid_t lapl_id, H5L_elink_traverse_t *func, void **op_data) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get callback_info */ - if(H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info)<0) + if(H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get callback info") if(func) *func = cb_info.func; - if(op_data) *op_data = cb_info.user_data; @@ -1173,4 +1292,3 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_elink_cb() */ - diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index 7472c49..f26b84e 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -63,9 +63,14 @@ #define H5O_CRT_OHDR_FLAGS_DEC H5P__decode_uint8_t /* Definitions for filter pipeline */ #define H5O_CRT_PIPELINE_SIZE sizeof(H5O_pline_t) +#define H5O_CRT_PIPELINE_SET H5P__ocrt_pipeline_set +#define H5O_CRT_PIPELINE_GET H5P__ocrt_pipeline_get #define H5O_CRT_PIPELINE_ENC H5P__ocrt_pipeline_enc #define H5O_CRT_PIPELINE_DEC H5P__ocrt_pipeline_dec +#define H5O_CRT_PIPELINE_DEL H5P__ocrt_pipeline_del +#define H5O_CRT_PIPELINE_COPY H5P__ocrt_pipeline_copy #define H5O_CRT_PIPELINE_CMP H5P__ocrt_pipeline_cmp +#define H5O_CRT_PIPELINE_CLOSE H5P__ocrt_pipeline_close /******************/ @@ -84,13 +89,16 @@ /* Property class callbacks */ static herr_t H5P__ocrt_reg_prop(H5P_genclass_t *pclass); -static herr_t H5P__ocrt_copy(hid_t new_plist_t, hid_t old_plist_t, void *copy_data); -static herr_t H5P__ocrt_close(hid_t dxpl_id, void *close_data); /* Property callbacks */ static herr_t H5P__ocrt_pipeline_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__ocrt_pipeline_dec(const void **_pp, void *value); +static herr_t H5P__ocrt_pipeline_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__ocrt_pipeline_get(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__ocrt_pipeline_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__ocrt_pipeline_copy(const char *name, size_t size, void *value); static int H5P__ocrt_pipeline_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__ocrt_pipeline_close(const char *name, size_t size, void *value); /* Local routines */ static herr_t H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, @@ -113,9 +121,9 @@ const H5P_libclass_t H5P_CLS_OCRT[1] = {{ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ - H5P__ocrt_copy, /* Class copy callback */ + NULL, /* Class copy callback */ NULL, /* Class copy callback info */ - H5P__ocrt_close, /* Class close callback */ + NULL, /* Class close callback */ NULL /* Class close callback info */ }}; @@ -177,8 +185,8 @@ H5P__ocrt_reg_prop(H5P_genclass_t *pclass) /* Register the pipeline property */ if(H5P_register_real(pclass, H5O_CRT_PIPELINE_NAME, H5O_CRT_PIPELINE_SIZE, &H5O_def_pline_g, - NULL, NULL, NULL, H5O_CRT_PIPELINE_ENC, H5O_CRT_PIPELINE_DEC, - NULL, NULL, H5O_CRT_PIPELINE_CMP, NULL) < 0) + NULL, H5O_CRT_PIPELINE_SET, H5O_CRT_PIPELINE_GET, H5O_CRT_PIPELINE_ENC, H5O_CRT_PIPELINE_DEC, + H5O_CRT_PIPELINE_DEL, H5O_CRT_PIPELINE_COPY, H5O_CRT_PIPELINE_CMP, H5O_CRT_PIPELINE_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: @@ -187,97 +195,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5P__ocrt_copy - * - * Purpose: Callback routine which is called whenever any object - * creation property list is copied. This routine copies - * the properties from the old list to the new list. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Neil Fortner - * Monday, September 21, 2009 - * - *------------------------------------------------------------------------- - */ -/* ARGSUSED */ -static herr_t -H5P__ocrt_copy(hid_t dst_plist_id, hid_t src_plist_id, void H5_ATTR_UNUSED *copy_data) -{ - H5O_pline_t src_pline, dst_pline; /* Source & destination pipelines */ - H5P_genplist_t *src_plist; /* Pointer to source property list */ - H5P_genplist_t *dst_plist; /* Pointer to destination property list */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Verify property list IDs */ - if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object creation property list") - if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object creation property list") - - /* Get the link pipeline property from the old property list */ - if(H5P_get(src_plist, H5O_CRT_PIPELINE_NAME, &src_pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - - /* Make copy of link pipeline */ - if(NULL == H5O_msg_copy(H5O_PLINE_ID, &src_pline, &dst_pline)) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't copy link pipeline") - - /* Set the link pipeline property for the destination property list */ - if(H5P_set(dst_plist, H5O_CRT_PIPELINE_NAME, &dst_pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__ocrt_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5P__ocrt_close - * - * Purpose: Callback routine which is called whenever any object create - * property list is closed. This routine performs any generic - * cleanup needed on the properties the library put into the list. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Neil Fortner - * Monday, September 21, 2009 - * - *------------------------------------------------------------------------- - */ -/* ARGSUSED */ -static herr_t -H5P__ocrt_close(hid_t dcpl_id, void H5_ATTR_UNUSED *close_data) -{ - H5O_pline_t pline; /* I/O pipeline */ - H5P_genplist_t *plist; /* Property list */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check arguments */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object creation property list") - - /* Get the link pipeline property from the old property list */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") - - /* Clean up any values set for the link pipeline */ - if(H5O_msg_reset(H5O_PLINE_ID, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't release pipeline info") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__ocrt_close() */ - - -/*------------------------------------------------------------------------- * Function: H5Pset_attr_phase_change * * Purpose: Sets the cutoff values for indexes storing attributes @@ -615,7 +532,7 @@ H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned flags, FUNC_ENTER_NOAPI(FAIL) /* Get the pipeline property to modify */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Modify the filter parameters of the I/O pipeline */ @@ -623,7 +540,7 @@ H5P_modify_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned flags, HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: @@ -841,7 +758,7 @@ H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, } /* end if */ /* Get the pipeline property to append to */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Add the filter to the I/O pipeline */ @@ -849,7 +766,7 @@ H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: @@ -899,7 +816,7 @@ H5Pget_nfilters(hid_t plist_id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to query */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Set return value */ @@ -982,7 +899,7 @@ H5Pget_filter2(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_FILTER_ERROR, "can't find object for ID") /* Get the pipeline property to query */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline") /* Check index */ @@ -1038,7 +955,7 @@ H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsigned int *flags FUNC_ENTER_NOAPI(FAIL) /* Get pipeline info */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Get pointer to filter in pipeline */ @@ -1167,7 +1084,7 @@ H5Pall_filters_avail(hid_t plist_id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to query */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Check if all filters are available */ @@ -1203,7 +1120,7 @@ H5P_filter_in_pline(H5P_genplist_t *plist, H5Z_filter_t id) FUNC_ENTER_NOAPI(FAIL) /* Get pipeline info */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Check if the file is in the pipeline */ @@ -1250,7 +1167,7 @@ H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to modify */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Check if there are any filters */ @@ -1260,7 +1177,7 @@ H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't delete filter") /* Put the I/O pipeline information back into the property list */ - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") } /* end if */ @@ -1318,7 +1235,7 @@ H5Pset_deflate(hid_t plist_id, unsigned level) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to append to */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Add the filter */ @@ -1326,7 +1243,7 @@ H5Pset_deflate(hid_t plist_id, unsigned level) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add deflate filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: @@ -1369,7 +1286,7 @@ H5Pset_fletcher32(hid_t plist_id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get the pipeline property to append to */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get pipeline") /* Add the Fletcher32 checksum as a filter */ @@ -1377,7 +1294,7 @@ H5Pset_fletcher32(hid_t plist_id) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to add fletcher32 filter to pipeline") /* Put the I/O pipeline information back into the property list */ - if(H5P_set(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_poke(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set pipeline") done: @@ -1462,6 +1379,82 @@ H5P_get_filter(const H5Z_filter_info_t *filter, unsigned int *flags/*out*/, /*------------------------------------------------------------------------- + * Function: H5P__ocrt_pipeline_set + * + * Purpose: Copies an I/O pipeline property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, Sept 3, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__ocrt_pipeline_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ + H5O_pline_t new_pline; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of I/O pipeline */ + if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy I/O pipeline") + + /* Copy new I/O pipeline message over old one */ + *pline = new_pline; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__ocrt_pipeline_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__ocrt_pipeline_get + * + * Purpose: Copies a layout property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Tuesday, Sept 1, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__ocrt_pipeline_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ + H5O_pline_t new_pline; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of I/O pipeline */ + if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy I/O pipeline") + + /* Copy new I/O pipeline message over old one */ + *pline = new_pline; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__ocrt_pipeline_get() */ + + +/*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_enc * * Purpose: Callback routine which is called whenever the pipeline @@ -1650,6 +1643,77 @@ done: /*------------------------------------------------------------------------- + * Function: H5P__ocrt_pipeline_del + * + * Purpose: Frees memory used to store the I/O pipeline property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, Sept 3, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__ocrt_pipeline_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Reset the old I/O pipeline */ + if(H5O_msg_reset(H5O_PLINE_ID, value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release I/O pipeline message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__ocrt_pipeline_del() */ + + +/*-------------------------------------------------------------------------- + * Function: H5P__ocrt_pipeline_copy + * + * Purpose: Copy the I/O pipeline property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, Sept 3, 2015 + * + *-------------------------------------------------------------------------- + */ +static herr_t +H5P__ocrt_pipeline_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + H5O_pline_t *pline = (H5O_pline_t *)value; /* Create local aliases for values */ + H5O_pline_t new_pline; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(pline); + + /* Make copy of I/O pipeline */ + if(NULL == H5O_msg_copy(H5O_PLINE_ID, pline, &new_pline)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy I/O pipeline") + + /* Copy new I/O pipeline message over old one */ + *pline = new_pline; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__ocrt_pipeline_copy() */ + + +/*------------------------------------------------------------------------- * Function: H5P__ocrt_pipeline_cmp * * Purpose: Callback routine which is called whenever a filter pipeline @@ -1730,6 +1794,39 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocrt_pipeline_cmp() */ + +/*------------------------------------------------------------------------- + * Function: H5P__ocrt_pipeline_close + * + * Purpose: Frees memory used to store the I/O pipeline property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, Sept 3, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__ocrt_pipeline_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, + void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Reset the old I/O pipeline */ + if(H5O_msg_reset(H5O_PLINE_ID, value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRESET, FAIL, "can't release I/O pipeline message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__ocrt_pipeline_close() */ + #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- @@ -1795,7 +1892,7 @@ H5Pget_filter1(hid_t plist_id, unsigned idx, unsigned int *flags/*out*/, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5Z_FILTER_ERROR, "can't find object for ID") /* Get pipeline info */ - if(H5P_get(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + if(H5P_peek(plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5Z_FILTER_ERROR, "can't get pipeline") /* Check more args */ diff --git a/src/H5Pocpypl.c b/src/H5Pocpypl.c index 7683ee9..338ecc3 100644 --- a/src/H5Pocpypl.c +++ b/src/H5Pocpypl.c @@ -53,10 +53,13 @@ #define H5O_CPY_OPTION_ENC H5P__encode_unsigned #define H5O_CPY_OPTION_DEC H5P__decode_unsigned /* Definitions for merge committed dtype list */ -#define H5O_CPY_MERGE_COMM_DT_LIST_SIZE sizeof(char *) +#define H5O_CPY_MERGE_COMM_DT_LIST_SIZE sizeof(H5O_copy_dtype_merge_list_t *) #define H5O_CPY_MERGE_COMM_DT_LIST_DEF NULL +#define H5O_CPY_MERGE_COMM_DT_LIST_SET H5P__ocpy_merge_comm_dt_list_set +#define H5O_CPY_MERGE_COMM_DT_LIST_GET H5P__ocpy_merge_comm_dt_list_get #define H5O_CPY_MERGE_COMM_DT_LIST_ENC H5P__ocpy_merge_comm_dt_list_enc #define H5O_CPY_MERGE_COMM_DT_LIST_DEC H5P__ocpy_merge_comm_dt_list_dec +#define H5O_CPY_MERGE_COMM_DT_LIST_DEL H5P__ocpy_merge_comm_dt_list_del #define H5O_CPY_MERGE_COMM_DT_LIST_COPY H5P__ocpy_merge_comm_dt_list_copy #define H5O_CPY_MERGE_COMM_DT_LIST_CMP H5P__ocpy_merge_comm_dt_list_cmp #define H5O_CPY_MERGE_COMM_DT_LIST_CLOSE H5P__ocpy_merge_comm_dt_list_close @@ -81,13 +84,17 @@ /* General routines */ static H5O_copy_dtype_merge_list_t *H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list); +static herr_t H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value); /* Property class callbacks */ static herr_t H5P__ocpy_reg_prop(H5P_genclass_t *pclass); /* Property callbacks */ +static herr_t H5P__ocpy_merge_comm_dt_list_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__ocpy_merge_comm_dt_list_get(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__ocpy_merge_comm_dt_list_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__ocpy_merge_comm_dt_list_dec(const void **_pp, void *value); +static herr_t H5P__ocpy_merge_comm_dt_list_del(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__ocpy_merge_comm_dt_list_copy(const char* name, size_t size, void* value); static int H5P__ocpy_merge_comm_dt_list_cmp(const void *value1, const void *value2, size_t size); static herr_t H5P__ocpy_merge_comm_dt_list_close(const char* name, size_t size, void* value); @@ -162,8 +169,8 @@ H5P__ocpy_reg_prop(H5P_genclass_t *pclass) /* Register merge named dtype list property */ if(H5P_register_real(pclass, H5O_CPY_MERGE_COMM_DT_LIST_NAME, H5O_CPY_MERGE_COMM_DT_LIST_SIZE, &H5O_def_merge_comm_dtype_list_g, - NULL, NULL, NULL, H5O_CPY_MERGE_COMM_DT_LIST_ENC, H5O_CPY_MERGE_COMM_DT_LIST_DEC, - NULL, H5O_CPY_MERGE_COMM_DT_LIST_COPY, H5O_CPY_MERGE_COMM_DT_LIST_CMP, H5O_CPY_MERGE_COMM_DT_LIST_CLOSE) < 0) + NULL, H5O_CPY_MERGE_COMM_DT_LIST_SET, H5O_CPY_MERGE_COMM_DT_LIST_GET, H5O_CPY_MERGE_COMM_DT_LIST_ENC, H5O_CPY_MERGE_COMM_DT_LIST_DEC, + H5O_CPY_MERGE_COMM_DT_LIST_DEL, H5O_CPY_MERGE_COMM_DT_LIST_COPY, H5O_CPY_MERGE_COMM_DT_LIST_CMP, H5O_CPY_MERGE_COMM_DT_LIST_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for callback when completing the search for a matching named datatype from the named dtype list */ @@ -186,20 +193,23 @@ done: * * Programmer: Neil Fortner * October 27, 2011 + * *------------------------------------------------------------------------- */ static H5O_copy_dtype_merge_list_t * H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list) { - H5O_copy_dtype_merge_list_t *tmp_node; - FUNC_ENTER_STATIC_NOERR /* Free the list */ while(dt_list) { + H5O_copy_dtype_merge_list_t *tmp_node; + tmp_node = dt_list->next; + (void)H5MM_xfree(dt_list->path); (void)H5FL_FREE(H5O_copy_dtype_merge_list_t, dt_list); + dt_list = tmp_node; } /* end while */ @@ -207,6 +217,138 @@ H5P__free_merge_comm_dtype_list(H5O_copy_dtype_merge_list_t *dt_list) } /* H5P__free_merge_comm_dtype_list */ +/*-------------------------------------------------------------------------- + * Function: H5P__copy_merge_comm_dt_list + * + * Purpose: Copy a merge committed datatype list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, September 2, 2015 + * + *-------------------------------------------------------------------------- + */ +static herr_t +H5P__copy_merge_comm_dt_list(H5O_copy_dtype_merge_list_t **value) +{ + const H5O_copy_dtype_merge_list_t *src_dt_list; /* Source merge named datatype lists */ + H5O_copy_dtype_merge_list_t *dst_dt_list = NULL; /* Destination merge named datatype lists */ + H5O_copy_dtype_merge_list_t *dst_dt_list_tail = NULL, *tmp_dt_list = NULL; /* temporary merge named datatype lists */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of merge committed dtype list */ + src_dt_list = *value; + while(src_dt_list) { + /* Copy src_dt_list */ + if(NULL == (tmp_dt_list = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") + if(NULL == (tmp_dt_list->path = H5MM_strdup(src_dt_list->path))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed") + + /* Add copied node to dest dtype list */ + if(dst_dt_list_tail) { + dst_dt_list_tail->next = tmp_dt_list; + dst_dt_list_tail = tmp_dt_list; + } /* end if */ + else { + dst_dt_list = tmp_dt_list; + dst_dt_list_tail = tmp_dt_list; + } /* end else */ + tmp_dt_list = NULL; + + /* Advance src_dt_list pointer */ + src_dt_list = src_dt_list->next; + } /* end while */ + + /* Set the merge named dtype list property for the destination property list */ + *value = dst_dt_list; + +done: + if(ret_value < 0) { + dst_dt_list = H5P__free_merge_comm_dtype_list(dst_dt_list); + if(tmp_dt_list) { + tmp_dt_list->path = (char *)H5MM_xfree(tmp_dt_list->path); + tmp_dt_list = H5FL_FREE(H5O_copy_dtype_merge_list_t, tmp_dt_list); + } /* end if */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__copy_merge_comm_dt_list() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__ocpy_merge_comm_dt_list_set + * + * Purpose: Copies a merge committed datatype list property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__ocpy_merge_comm_dt_list_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of merge committed dtype list */ + if(H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy merge committed dtype list") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__ocpy_merge_comm_dt_list_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__ocpy_merge_comm_dt_list_get + * + * Purpose: Copies a merge committed datatype list property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, Sept 2, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__ocpy_merge_comm_dt_list_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of merge committed dtype list */ + if(H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy merge committed dtype list") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__ocpy_merge_comm_dt_list_get() */ + + /*------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_enc * @@ -342,6 +484,36 @@ done: /*-------------------------------------------------------------------------- + * Function: H5P__ocpy_merge_comm_dt_list_del + * + * Purpose: Frees memory used to store the merge committed datatype list property + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Wednesday, September 2, 2015 + * + *-------------------------------------------------------------------------- + */ +/* ARGSUSED */ +static herr_t +H5P__ocpy_merge_comm_dt_list_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(value); + + /* Free the merge named dtype list */ + H5P__free_merge_comm_dtype_list(*(H5O_copy_dtype_merge_list_t **)value); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__ocpy_merge_comm_dt_list_del() */ + + +/*-------------------------------------------------------------------------- * Function: H5P__ocpy_merge_comm_dt_list_copy * * Purpose: Copy the merge committed datatype list @@ -359,51 +531,18 @@ static herr_t H5P__ocpy_merge_comm_dt_list_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) { - const H5O_copy_dtype_merge_list_t *src_dt_list; /* Source merge named datatype lists */ - H5O_copy_dtype_merge_list_t *dst_dt_list = NULL; /* Destination merge named datatype lists */ - H5O_copy_dtype_merge_list_t *dst_dt_list_tail = NULL, *tmp_dt_list = NULL; /* temporary merge named datatype lists */ herr_t ret_value = SUCCEED; FUNC_ENTER_STATIC + /* Sanity check */ HDassert(value); /* Make copy of merge committed dtype list */ - src_dt_list = *(const H5O_copy_dtype_merge_list_t **)value; - while(src_dt_list) { - /* Copy src_dt_list */ - if(NULL == (tmp_dt_list = H5FL_CALLOC(H5O_copy_dtype_merge_list_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - if(NULL == (tmp_dt_list->path = H5MM_strdup(src_dt_list->path))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Add copied node to dest dtype list */ - if(dst_dt_list_tail) { - dst_dt_list_tail->next = tmp_dt_list; - dst_dt_list_tail = tmp_dt_list; - } /* end if */ - else { - dst_dt_list = tmp_dt_list; - dst_dt_list_tail = tmp_dt_list; - } /* end else */ - tmp_dt_list = NULL; - - /* Advance src_dt_list pointer */ - src_dt_list = src_dt_list->next; - } /* end while */ - - /* Set the merge named dtype list property for the destination property list */ - *(H5O_copy_dtype_merge_list_t **)value = dst_dt_list; + if(H5P__copy_merge_comm_dt_list((H5O_copy_dtype_merge_list_t **)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy merge committed dtype list") done: - if(ret_value < 0) { - dst_dt_list = H5P__free_merge_comm_dtype_list(dst_dt_list); - if(tmp_dt_list) { - tmp_dt_list->path = (char *)H5MM_xfree(tmp_dt_list->path); - tmp_dt_list = H5FL_FREE(H5O_copy_dtype_merge_list_t, tmp_dt_list); - } /* end if */ - } /* end if */ - FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__ocpy_merge_comm_dt_list_copy() */ @@ -615,7 +754,7 @@ H5Padd_merge_committed_dtype_path(hid_t plist_id, const char *path) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get dtype list */ - if(H5P_get(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &old_list) < 0) + if(H5P_peek(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &old_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get merge named dtype list") /* Add the new path to the list */ @@ -626,7 +765,7 @@ H5Padd_merge_committed_dtype_path(hid_t plist_id, const char *path) new_obj->next = old_list; /* Update the list stored in the property list */ - if(H5P_set(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &new_obj) < 0) + if(H5P_poke(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &new_obj) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set merge named dtype list") done: @@ -671,14 +810,14 @@ H5Pfree_merge_committed_dtype_paths(hid_t plist_id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Get dtype list */ - if(H5P_get(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) + if(H5P_peek(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get merge committed dtype list") /* Free dtype list */ dt_list = H5P__free_merge_comm_dtype_list(dt_list); /* Update the list stored in the property list (to NULL) */ - if(H5P_set(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) + if(H5P_poke(plist, H5O_CPY_MERGE_COMM_DT_LIST_NAME, &dt_list) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set merge committed dtype list") done: diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 7233818..e27401d 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -111,21 +111,23 @@ H5_DLL herr_t H5P_init(void); H5_DLL herr_t H5P_close(void *_plist); H5_DLL hid_t H5P_create_id(H5P_genclass_t *pclass, hbool_t app_ref); H5_DLL hid_t H5P_copy_plist(const H5P_genplist_t *old_plist, hbool_t app_ref); -H5_DLL herr_t H5P_get(const H5P_genplist_t *plist, const char *name, void *value); +H5_DLL herr_t H5P_get(H5P_genplist_t *plist, const char *name, void *value); H5_DLL herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value); +H5_DLL herr_t H5P_peek(H5P_genplist_t *plist, const char *name, void *value); +H5_DLL herr_t H5P_poke(H5P_genplist_t *plist, const char *name, const void *value); H5_DLL herr_t H5P_insert(H5P_genplist_t *plist, const char *name, size_t size, void *value, H5P_prp_set_func_t prp_set, H5P_prp_get_func_t prp_get, H5P_prp_encode_func_t prp_encode, H5P_prp_decode_func_t prp_decode, H5P_prp_delete_func_t prp_delete, H5P_prp_copy_func_t prp_copy, H5P_prp_compare_func_t prp_cmp, H5P_prp_close_func_t prp_close); -H5_DLL herr_t H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name); +H5_DLL herr_t H5P_remove(H5P_genplist_t *plist, const char *name); H5_DLL htri_t H5P_exist_plist(const H5P_genplist_t *plist, const char *name); H5_DLL htri_t H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); H5_DLL char *H5P_get_class_name(H5P_genclass_t *pclass); H5_DLL herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recurse); -H5_DLL hid_t H5P_get_driver(H5P_genplist_t *plist); -H5_DLL void * H5P_get_driver_info(H5P_genplist_t *plist); +H5_DLL hid_t H5P_peek_driver(H5P_genplist_t *plist); +H5_DLL const void *H5P_peek_driver_info(H5P_genplist_t *plist); H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info); H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, diff --git a/src/H5Ptest.c b/src/H5Ptest.c index 0463299..dead67e 100644 --- a/src/H5Ptest.c +++ b/src/H5Ptest.c @@ -156,7 +156,7 @@ H5P_reset_external_file_test(hid_t dcpl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* get external file list */ - if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if(H5P_peek(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list") /* Clean up any values set for the external file-list */ @@ -164,7 +164,7 @@ H5P_reset_external_file_test(hid_t dcpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release external file list info") /* set external file list */ - if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) + if(H5P_poke(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set external file list") done: @@ -202,7 +202,7 @@ H5P_reset_layout_test(hid_t dcpl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list") /* Get layout message */ - if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if(H5P_peek(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout") /* Clean up any values set for the layout */ @@ -210,13 +210,9 @@ H5P_reset_layout_test(hid_t dcpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't release layout info") /* Set layout message */ - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if(H5P_poke(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout") - /* Remove layout message */ - if(H5P_remove(dcpl_id, plist, H5D_CRT_LAYOUT_NAME) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't delete layout message property") - done: FUNC_LEAVE_NOAPI(ret_value) } /* H5P_reset_layout_test() */ diff --git a/src/H5T.c b/src/H5T.c index d69d3a4..0e70053 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -4412,7 +4412,9 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, /* Sanity check */ HDassert(src); + HDassert(src->shared); HDassert(dst); + HDassert(dst->shared); /* * Make sure the first entry in the table is the no-op conversion path. diff --git a/src/H5Z.c b/src/H5Z.c index 01f5216..2ae97c7 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -825,8 +825,8 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") - /* Get layout information */ - if(H5P_get(dc_plist, H5D_CRT_LAYOUT_NAME, &dcpl_layout) < 0) + /* Peek at the layout information */ + if(H5P_peek(dc_plist, H5D_CRT_LAYOUT_NAME, &dcpl_layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Check if the dataset is chunked */ @@ -834,7 +834,7 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type H5O_pline_t dcpl_pline; /* Object's I/O pipeline information */ /* Get I/O pipeline information */ - if(H5P_get(dc_plist, H5O_CRT_PIPELINE_NAME, &dcpl_pline) < 0) + if(H5P_peek(dc_plist, H5O_CRT_PIPELINE_NAME, &dcpl_pline) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve pipeline filter") /* Check if the chunks have filters */ diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index db61cc5..ee15b52 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -255,8 +255,14 @@ static void H5Z_print(H5Z_node *tree, FILE *stream); else \ { \ ret_value->type = (TYPE); \ - ret_value->lchild = (H5Z_node*) H5Z_xform_copy_tree(tree->lchild, dat_val_pointers, new_dat_val_pointers); \ - ret_value->rchild = (H5Z_node*) H5Z_xform_copy_tree(tree->rchild, dat_val_pointers, new_dat_val_pointers); \ + if(tree->lchild) \ + ret_value->lchild = (H5Z_node*) H5Z_xform_copy_tree(tree->lchild, dat_val_pointers, new_dat_val_pointers); \ + else \ + ret_value->lchild = NULL; \ + if(tree->rchild) \ + ret_value->rchild = (H5Z_node*) H5Z_xform_copy_tree(tree->rchild, dat_val_pointers, new_dat_val_pointers); \ + else \ + ret_value->rchild = NULL; \ } \ } @@ -787,7 +793,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) if (!factor) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") - sscanf(current->tok_begin, "%ld", &factor->value.int_val); + sscanf(current->tok_begin, "%ld", &factor->value.int_val); break; case H5Z_XFORM_FLOAT: @@ -795,7 +801,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) if (!factor) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") - sscanf(current->tok_begin, "%lf", &factor->value.float_val); + sscanf(current->tok_begin, "%lf", &factor->value.float_val); break; case H5Z_XFORM_SYMBOL: @@ -804,7 +810,7 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) if (!factor) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") - factor->value.dat_val = &(dat_val_pointers->ptr_dat_val[dat_val_pointers->num_ptrs]); + factor->value.dat_val = &(dat_val_pointers->ptr_dat_val[dat_val_pointers->num_ptrs]); dat_val_pointers->num_ptrs++; break; @@ -814,11 +820,11 @@ H5Z_parse_factor(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers) if (!factor) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "Unable to allocate new node") - current = H5Z_get_token(current); + current = H5Z_get_token(current); if (current->tok_type != H5Z_XFORM_RPAREN) { - H5Z_xform_destroy_parse_tree(factor); - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Syntax error in data transform expression") + H5Z_xform_destroy_parse_tree(factor); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Syntax error in data transform expression") } break; @@ -1296,14 +1302,11 @@ H5Z_xform_copy_tree(H5Z_node* tree, H5Z_datval_ptrs* dat_val_pointers, H5Z_datva H5Z_XFORM_DO_OP4(H5Z_XFORM_MINUS) else if(tree->type == H5Z_XFORM_DIVIDE) H5Z_XFORM_DO_OP4(H5Z_XFORM_DIVIDE) - else HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error in parse tree while trying to copy") - - - done: - FUNC_LEAVE_NOAPI(ret_value) +done: + FUNC_LEAVE_NOAPI(ret_value) } @@ -1513,7 +1516,7 @@ H5Z_xform_create(const char *expr) * of the data we have for polynomial transforms */ data_xform_prop->dat_val_pointers->num_ptrs = 0; - /* we generate the parse tree right here and store a poitner to its root in the property. */ + /* we generate the parse tree right here and store a pointer to its root in the property. */ if((data_xform_prop->parse_root = (H5Z_node *)H5Z_xform_parse(expr, data_xform_prop->dat_val_pointers))==NULL) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to generate parse tree from expression") @@ -1609,8 +1612,6 @@ H5Z_xform_destroy(H5Z_data_xform_t *data_xform_prop) * after the top-level copy has been performed and this routine finishes * the "deep" part of the copy. * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5err.txt b/src/H5err.txt index 31b18a5..a156316 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -176,6 +176,8 @@ MINOR, CACHE, H5E_CANTDEPEND, Unable to create a flush dependency MINOR, CACHE, H5E_CANTUNDEPEND, Unable to destroy a flush dependency MINOR, CACHE, H5E_CANTNOTIFY, Unable to notify object about action MINOR, CACHE, H5E_LOGFAIL, Failure in the cache logging framework +MINOR, CACHE, H5E_CANTCORK, Unable to cork an object +MINOR, CACHE, H5E_CANTUNCORK, Unable to uncork an object # B-tree related errors MINOR, BTREE, H5E_NOTFOUND, Object not found diff --git a/test/links.c b/test/links.c index 5242b7b..43088f1 100644 --- a/test/links.c +++ b/test/links.c @@ -3887,11 +3887,8 @@ external_set_elink_fapl3(hbool_t new_format) if(H5Pget(lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR if(H5Pclose(lapl_id) < 0) TEST_ERROR - /* Try closing out_fapl should fail since H5Pclose(lapl_id) should also close its fapl */ - H5E_BEGIN_TRY { - ret = H5Pclose(out_fapl); - } H5E_END_TRY; - if(ret != FAIL) TEST_ERROR + /* Try closing out_fapl, should succeed since H5Pget() should clone its fapl */ + if(H5Pclose(out_fapl) < 0) TEST_ERROR /* Verify that the driver for the copied link's fapl is the "core" driver */ if((l_fapl = H5Pget_elink_fapl(new_lapl_id)) < 0) TEST_ERROR @@ -3901,11 +3898,8 @@ external_set_elink_fapl3(hbool_t new_format) if(H5Pget(new_lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR if(H5Premove(new_lapl_id, "external link fapl") < 0) TEST_ERROR - /* Try closing out_fapl should fail since the property is removed from new_lapl_id */ - H5E_BEGIN_TRY { - ret = H5Pclose(out_fapl); - } H5E_END_TRY; - if(ret != FAIL) TEST_ERROR + /* Try closing out_fapl, should succeed since H5Pget() should clone its fapl */ + if(H5Pclose(out_fapl) < 0) TEST_ERROR if(H5Pclose(l_fapl) < 0) TEST_ERROR if(H5Pclose(new_lapl_id) < 0) TEST_ERROR diff --git a/test/testframe.c b/test/testframe.c index 2dd181b..daa27c5 100644 --- a/test/testframe.c +++ b/test/testframe.c @@ -213,6 +213,7 @@ void TestInfo(const char *ProgName) */ void TestParseCmdLine(int argc, char *argv[]) { + hbool_t skipped_all = FALSE; int ret_code; while (argv++, --argc > 0){ @@ -248,14 +249,20 @@ void TestParseCmdLine(int argc, char *argv[]) } else if (((HDstrcmp(*argv, "-only") == 0) || (HDstrcmp(*argv, "-o") == 0))) { - if (argc > 0){ + if(argc > 0) { int Loop; + --argc; ++argv; + /* Skip all tests, then activate only one. */ - for (Loop = 0; Loop < Index; Loop++) - Test[Loop].SkipFlag = 1; + if(!skipped_all) { + for(Loop = 0; Loop < Index; Loop++) + Test[Loop].SkipFlag = 1; + skipped_all = TRUE; + } /* end if */ SetTest(*argv, ONLYTEST); - }else{ + } /* end if */ + else { TestUsage(); exit(EXIT_FAILURE); } @@ -548,6 +555,7 @@ TestErrPrintf(const char *format, ...) void SetTest(const char *testname, int action) { int Loop; + switch (action){ case SKIPTEST: for (Loop = 0; Loop < Index; Loop++) @@ -569,17 +577,12 @@ void SetTest(const char *testname, int action) break; case ONLYTEST: for (Loop = 0; Loop < Index; Loop++) { - if (HDstrcmp(testname, Test[Loop].Name) != 0) - Test[Loop].SkipFlag = 1; - else { + if (HDstrcmp(testname, Test[Loop].Name) == 0) { /* Found it. Set it to run. Break to skip the rest. */ Test[Loop].SkipFlag = 0; break; } } - /* skip the rest */ - while (++Loop < Index) - Test[Loop].SkipFlag = 1; break; default: /* error */ diff --git a/test/tfile.c b/test/tfile.c index 064045f..7e1b337 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -2813,6 +2813,10 @@ test_free_sections(hid_t fapl, char *fname) file = H5Fcreate(fname, H5F_ACC_TRUNC, fcpl, fapl); CHECK(file, FAIL, "H5Fcreate"); + /* Close the FCPL */ + ret = H5Pclose(fcpl); + CHECK(ret, FAIL, "H5Pclose"); + /* Create dataspace for datasets */ dspace = H5Screate(H5S_SCALAR); CHECK(dspace, FAIL, "H5Screate"); @@ -2937,9 +2941,6 @@ test_free_sections(hid_t fapl, char *fname) ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); - ret = H5Pclose(fcpl); - CHECK(fcpl, FAIL, "H5Pclose"); - HDfree(saved_sect_info); } /* end test_free_sections() */ @@ -3017,6 +3018,7 @@ test_filespace_sects(void) /* close fapl and remove the file */ h5_cleanup(FILENAME, fapl_stdio); + /* CORE */ MESSAGE(5, ("Testing File free space information for a core file\n")); diff --git a/test/tgenprop.c b/test/tgenprop.c index fda4161..f5c4a53 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -784,7 +784,7 @@ test_genprop_basic_list_prop(void) ret = H5Pget(lid1, PROP4_NAME,&prop4_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ - if(!H5_FLT_ABS_EQUAL(prop4_value,*PROP4_DEF_VALUE)) + if(!H5_FLT_ABS_EQUAL(prop4_value,(double)*PROP4_DEF_VALUE)) printf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", "H5Pget", *PROP4_DEF_VALUE, prop4_value, (int)__LINE__, __FILE__); @@ -1203,9 +1203,9 @@ test_genprop_list_callback(void) lid1 = H5Pcreate(cid1); CHECK_I(lid1, "H5Pcreate"); - /* The compare callback should have been called once on property 1 (to check - * if the create callback modified the value) */ - VERIFY(prop1_cb_info.cmp_count, 1, "H5Pcreate"); + /* The compare callback should not have been called once on property 1, as + * the property is always copied */ + VERIFY(prop1_cb_info.cmp_count, 0, "H5Pcreate"); /* The compare callback should not have been called on property 3, as there * is no create callback */ VERIFY(prop3_cb_info.cmp_count, 0, "H5Pcreate"); @@ -1221,9 +1221,8 @@ test_genprop_list_callback(void) ret = H5Pget(lid1, PROP1_NAME,&prop1_value); CHECK_I(ret, "H5Pget"); VERIFY(prop1_value, *PROP1_DEF_VALUE, "H5Pget"); - /* The compare callback should have been called once (to check if the get - * callback modified the value) */ - VERIFY(prop1_cb_info.cmp_count, 2, "H5Pget"); + /* The compare callback should not have been called */ + VERIFY(prop1_cb_info.cmp_count, 0, "H5Pget"); ret = H5Pget(lid1, PROP2_NAME,&prop2_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ @@ -1242,7 +1241,7 @@ test_genprop_list_callback(void) ret = H5Pget(lid1, PROP4_NAME,&prop4_value); CHECK_I(ret, "H5Pget"); /* Verify the floating-poing value in this way to avoid compiler warning. */ - if(!H5_FLT_ABS_EQUAL(prop4_value,*PROP4_DEF_VALUE)) + if(!H5_FLT_ABS_EQUAL(prop4_value,(double)*PROP4_DEF_VALUE)) printf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", "H5Pget", *PROP4_DEF_VALUE, prop4_value, (int)__LINE__, __FILE__); @@ -1266,17 +1265,15 @@ test_genprop_list_callback(void) if(HDmemcmp(prop1_cb_info.set_value,&prop1_new_value, PROP1_SIZE)!=0) TestErrPrintf("Property #1 value doesn't match!, line=%d\n",__LINE__); - /* The compare callback should have been called once (to check if the new - * value needed to be copied onto the property list) */ - VERIFY(prop1_cb_info.cmp_count, 3, "H5Pset"); + /* The compare callback should not have been called */ + VERIFY(prop1_cb_info.cmp_count, 0, "H5Pset"); /* Set value of property #3 to different value */ ret = H5Pset(lid1, PROP3_NAME,prop3_new_value); CHECK_I(ret, "H5Pset"); - /* The compare callback should have been called once (to check if the new - * value needed to be copied onto the property list) */ - VERIFY(prop3_cb_info.cmp_count, 1, "H5Pset"); + /* The compare callback should not have been called */ + VERIFY(prop3_cb_info.cmp_count, 0, "H5Pset"); /* Check new value of tracked properties */ ret = H5Pget(lid1, PROP1_NAME,&prop1_value); @@ -1323,8 +1320,8 @@ test_genprop_list_callback(void) VERIFY(ret, 1, "H5Pequal"); /* Verify compare callback information for properties tracked */ - VERIFY(prop1_cb_info.cmp_count, 4, "H5Pequal"); - VERIFY(prop3_cb_info.cmp_count, 2, "H5Pequal"); + VERIFY(prop1_cb_info.cmp_count, 1, "H5Pequal"); + VERIFY(prop3_cb_info.cmp_count, 1, "H5Pequal"); /* Close first list */ ret = H5Pclose(lid1); -- cgit v0.12