summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-12-05 01:52:42 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-12-05 02:10:00 (GMT)
commitad6581194d7eddf27ff12496cb9d5c83ce3d6193 (patch)
treee1e0cea4f4ac550ebe82a7611928f5c6d68b671f /src
parent3d84163ad37960ff1ecdd5782af88b442832fd99 (diff)
parent585cf69c56ea3411c0e661ad71b208ecac7732a7 (diff)
downloadhdf5-ad6581194d7eddf27ff12496cb9d5c83ce3d6193.zip
hdf5-ad6581194d7eddf27ff12496cb9d5c83ce3d6193.tar.gz
hdf5-ad6581194d7eddf27ff12496cb9d5c83ce3d6193.tar.bz2
Merge branch changes from hdf5_1_10.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/H5Dchunk.c78
-rw-r--r--src/H5Dcompact.c2
-rw-r--r--src/H5Dcontig.c2
-rw-r--r--src/H5Dio.c4
-rw-r--r--src/H5FSint.c3
-rw-r--r--src/H5Gnode.c6
-rw-r--r--src/H5HFcache.c88
-rw-r--r--src/H5HFhuge.c12
-rw-r--r--src/H5MF.c5
-rw-r--r--src/H5MM.c8
-rw-r--r--src/H5O.c2686
-rw-r--r--src/H5Oint.c2713
-rw-r--r--src/H5Oprivate.h7
-rw-r--r--src/H5PLint.c62
-rw-r--r--src/H5PLpath.c4
-rw-r--r--src/H5PLpkg.h8
-rw-r--r--src/H5PLplugin_cache.c14
-rw-r--r--src/H5PLprivate.h7
-rw-r--r--src/H5PLpublic.h6
-rw-r--r--src/H5R.c766
-rw-r--r--src/H5Rdeprec.c118
-rw-r--r--src/H5Rint.c767
-rw-r--r--src/H5Rmodule.h11
-rw-r--r--src/H5Rpkg.h14
-rw-r--r--src/H5Rprivate.h34
-rw-r--r--src/H5Rpublic.h73
-rw-r--r--src/H5Sprivate.h4
-rw-r--r--src/H5Tdbg.c227
-rw-r--r--src/H5Tprivate.h4
-rw-r--r--src/H5Z.c266
-rw-r--r--src/H5Zprivate.h7
-rw-r--r--src/H5Zpublic.h20
-rw-r--r--src/H5Zszip.c46
-rw-r--r--src/H5system.c2
-rw-r--r--src/Makefile.am4
-rw-r--r--src/libhdf5.settings.in1
37 files changed, 4147 insertions, 3934 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 31155a2..b163b8a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -454,6 +454,7 @@ set (H5O_SOURCES
${HDF5_SRC_DIR}/H5Oflush.c
${HDF5_SRC_DIR}/H5Ofsinfo.c
${HDF5_SRC_DIR}/H5Oginfo.c
+ ${HDF5_SRC_DIR}/H5Oint.c
${HDF5_SRC_DIR}/H5Olayout.c
${HDF5_SRC_DIR}/H5Olinfo.c
${HDF5_SRC_DIR}/H5Olink.c
@@ -532,6 +533,7 @@ IDE_GENERATED_PROPERTIES ("H5PL" "${H5PL_HDRS}" "${H5PL_SOURCES}" )
set (H5R_SOURCES
${HDF5_SRC_DIR}/H5R.c
${HDF5_SRC_DIR}/H5Rdeprec.c
+ ${HDF5_SRC_DIR}/H5Rint.c
)
set (H5R_HDRS
${HDF5_SRC_DIR}/H5Rpkg.h
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index af6599a..be3b678 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -5661,7 +5661,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
/* needed for commpressed variable length data */
hbool_t must_filter = FALSE; /* Whether chunk must be filtered during copy */
size_t nbytes; /* Size of chunk in file (in bytes) */
- H5Z_cb_t cb_struct; /* Filter failure callback struct */
+ H5Z_cb_t filter_cb; /* Filter failure callback struct */
int ret_value = H5_ITER_CONT; /* Return value */
@@ -5670,6 +5670,10 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
/* Get 'size_t' local value for number of bytes in chunk */
H5_CHECKED_ASSIGN(nbytes, size_t, chunk_rec->nbytes, uint32_t);
+ /* Initialize the filter callback struct */
+ filter_cb.op_data = NULL;
+ filter_cb.func = NULL; /* no callback function when failed */
+
/* Check for filtered chunks */
/* Check for an edge chunk that is not filtered */
if(pline && pline->nused) {
@@ -5716,11 +5720,12 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
HDassert(!H5F_addr_defined(chunk_rec->chunk_addr));
HDmemcpy(buf, udata->chunk, nbytes);
udata->chunk = NULL;
- } else {
+ }
+ else {
H5D_rdcc_ent_t *ent = NULL; /* Cache entry */
unsigned idx; /* Index of chunk in cache, if present */
unsigned u; /* Counter */
- H5D_shared_t *shared_fo = udata->cpy_info->shared_fo;
+ H5D_shared_t *shared_fo = (H5D_shared_t *)udata->cpy_info->shared_fo;
/* See if the written chunk is in the chunk cache */
if(shared_fo && shared_fo->cache.chunk.nslots > 0) {
@@ -5748,7 +5753,8 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
H5_CHECKED_ASSIGN(nbytes, size_t, shared_fo->layout.u.chunk.size, uint32_t);
HDmemcpy(buf, ent->chunk, nbytes);
- } else {
+ }
+ else {
/* read chunk data from the source file */
if(H5F_block_read(udata->file_src, H5FD_MEM_DRAW, chunk_rec->chunk_addr, nbytes, H5AC_rawdata_dxpl_id, buf) < 0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk")
@@ -5759,8 +5765,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
if(must_filter && (is_vlen || fix_ref) && !udata->chunk_in_cache) {
unsigned filter_mask = chunk_rec->filter_mask;
- cb_struct.func = NULL; /* no callback function when failed */
- if(H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, cb_struct, &nbytes, &buf_size, &buf) < 0)
+ if(H5Z_pipeline(pline, H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, &buf) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "data pipeline read failed")
} /* end if */
@@ -5822,7 +5827,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
/* Need to compress variable-length or reference data elements or a chunk found in cache before writing to file */
if(must_filter && (is_vlen || fix_ref || udata->chunk_in_cache) ) {
- if(H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, cb_struct, &nbytes, &buf_size, &buf) < 0)
+ if(H5Z_pipeline(pline, 0, &(udata_dst.filter_mask), H5Z_NO_EDC, filter_cb, &nbytes, &buf_size, &buf) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed")
#if H5_SIZEOF_SIZE_T > 4
/* Check for the chunk expanding too much to encode in a 32-bit value */
@@ -6707,46 +6712,49 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
H5_CHECKED_ASSIGN(nbytes, size_t, chunk_rec->nbytes, uint32_t);
chunk_addr = chunk_rec->chunk_addr;
- if(new_idx_info->pline->nused &&
+ if (new_idx_info->pline->nused &&
(new_idx_info->layout->flags & H5O_LAYOUT_CHUNK_DONT_FILTER_PARTIAL_BOUND_CHUNKS) &&
(H5D__chunk_is_partial_edge_chunk(udata->dset_ndims, new_idx_info->layout->dim, chunk_rec->scaled, udata->dset_dims))) {
- /* This is a partial non-filtered edge chunk */
- /* Convert the chunk to a filtered edge chunk for v1 B-tree chunk index */
- unsigned filter_mask = chunk_rec->filter_mask;
- H5Z_cb_t cb_struct; /* Filter failure callback struct */
- size_t read_size = nbytes; /* Bytes to read */
+ /* This is a partial non-filtered edge chunk */
+ /* Convert the chunk to a filtered edge chunk for v1 B-tree chunk index */
- HDassert(read_size == new_idx_info->layout->size);
+ unsigned filter_mask = chunk_rec->filter_mask;
+ H5Z_cb_t filter_cb; /* Filter failure callback struct */
+ size_t read_size = nbytes; /* Bytes to read */
+
+ HDassert(read_size == new_idx_info->layout->size);
- cb_struct.func = NULL; /* no callback function when failed */
+ /* Initialize the filter callback struct */
+ filter_cb.op_data = NULL;
+ filter_cb.func = NULL; /* no callback function when failed */
- /* Allocate buffer for chunk data */
- if(NULL == (buf = H5MM_malloc(read_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk")
+ /* Allocate buffer for chunk data */
+ if (NULL == (buf = H5MM_malloc(read_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5_ITER_ERROR, "memory allocation failed for raw data chunk")
- /* Read the non-filtered edge chunk */
- if(H5F_block_read(new_idx_info->f, H5FD_MEM_DRAW, chunk_addr, read_size, H5AC_rawdata_dxpl_id, buf) < 0)
- HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk")
+ /* Read the non-filtered edge chunk */
+ if (H5F_block_read(new_idx_info->f, H5FD_MEM_DRAW, chunk_addr, read_size, H5AC_rawdata_dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, H5_ITER_ERROR, "unable to read raw data chunk")
- /* Pass the chunk through the pipeline */
- if(H5Z_pipeline(new_idx_info->pline, 0, &filter_mask, H5Z_NO_EDC, cb_struct, &nbytes, &read_size, &buf) < 0)
- HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed")
+ /* Pass the chunk through the pipeline */
+ if (H5Z_pipeline(new_idx_info->pline, 0, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &read_size, &buf) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, H5_ITER_ERROR, "output pipeline failed")
#if H5_SIZEOF_SIZE_T > 4
/* Check for the chunk expanding too much to encode in a 32-bit value */
- if(nbytes > ((size_t)0xffffffff))
- HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, H5_ITER_ERROR, "chunk too large for 32-bit length")
+ if (nbytes > ((size_t)0xffffffff))
+ HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, H5_ITER_ERROR, "chunk too large for 32-bit length")
#endif /* H5_SIZEOF_SIZE_T > 4 */
- /* Allocate space for the filtered chunk */
- if((chunk_addr = H5MF_alloc(new_idx_info->f, H5FD_MEM_DRAW, new_idx_info->dxpl_id, (hsize_t)nbytes)) == HADDR_UNDEF)
- HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, H5_ITER_ERROR, "file allocation failed for filtered chunk")
- HDassert(H5F_addr_defined(chunk_addr));
+ /* Allocate space for the filtered chunk */
+ if ((chunk_addr = H5MF_alloc(new_idx_info->f, H5FD_MEM_DRAW, new_idx_info->dxpl_id, (hsize_t)nbytes)) == HADDR_UNDEF)
+ HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, H5_ITER_ERROR, "file allocation failed for filtered chunk")
+ HDassert(H5F_addr_defined(chunk_addr));
- /* Write the filtered chunk to disk */
- if(H5F_block_write(new_idx_info->f, H5FD_MEM_DRAW, chunk_addr, nbytes, H5AC_rawdata_dxpl_id, buf) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, H5_ITER_ERROR, "unable to write raw data to file")
+ /* Write the filtered chunk to disk */
+ if (H5F_block_write(new_idx_info->f, H5FD_MEM_DRAW, chunk_addr, nbytes, H5AC_rawdata_dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, H5_ITER_ERROR, "unable to write raw data to file")
} /* end if */
/* Set up chunk information for insertion to chunk index */
@@ -6758,11 +6766,11 @@ H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata)
insert_udata.common.storage = new_idx_info->storage;
/* Insert chunk into the v1 B-tree chunk index */
- if((new_idx_info->storage->ops->insert)(new_idx_info, &insert_udata, NULL) < 0)
+ if ((new_idx_info->storage->ops->insert)(new_idx_info, &insert_udata, NULL) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, H5_ITER_ERROR, "unable to insert chunk addr into index")
done:
- if(buf)
+ if (buf)
H5MM_xfree(buf);
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index 041d28f..43e7754 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -431,7 +431,7 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds
void *bkg = NULL; /* Temporary buffer for copying data */
void *reclaim_buf = NULL; /* Buffer for reclaiming data */
hid_t buf_sid = -1; /* ID for buffer dataspace */
- H5D_shared_t *shared_fo = cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */
+ H5D_shared_t *shared_fo = (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */
H5O_storage_compact_t *storage_src = _storage_src; /* Pointer to storage_src */
herr_t ret_value = SUCCEED; /* Return value */
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index 86de017..aab4901 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -1363,7 +1363,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
hsize_t buf_dim[1] = {0}; /* Dimension for buffer */
hbool_t is_vlen = FALSE; /* Flag to indicate that VL type conversion should occur */
hbool_t fix_ref = FALSE; /* Flag to indicate that ref values should be fixed */
- H5D_shared_t *shared_fo = cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */
+ H5D_shared_t *shared_fo = (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */
hbool_t try_sieve = FALSE; /* Try to get data from the sieve buffer */
haddr_t sieve_start = HADDR_UNDEF; /* Start location of sieve buffer */
haddr_t sieve_end = HADDR_UNDEF; /* End locations of sieve buffer */
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 104a632..280d602 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -962,7 +962,9 @@ const
io_info->using_mpi_vfd = H5F_HAS_FEATURE(dset->oloc.file, H5FD_FEAT_HAS_MPI);
#endif /* H5_HAVE_PARALLEL */
-done:
+#ifdef H5_DEBUG_BUILD
+ done:
+#endif /* H5_DEBUG_BUILD */
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__ioinfo_init() */
diff --git a/src/H5FSint.c b/src/H5FSint.c
index 4297291..264950d 100644
--- a/src/H5FSint.c
+++ b/src/H5FSint.c
@@ -96,10 +96,9 @@ H5FS_init(void)
{
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI_NOERR
/* FUNC_ENTER() does all the work */
-done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FS_init() */
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index 76e2c4b..b335624 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -640,7 +640,7 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr,
while(lt < rt) {
idx = (int)((lt + rt) / 2);
if((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get symbol table name")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get symbol table name")
/* Check if symbol is already present */
if(0 == (cmp = HDstrcmp(udata->common.name, s)))
@@ -802,8 +802,8 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/,
const char *s; /* Pointer to string in local heap */
idx = (lt + rt) / 2;
- if((s = H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get symbol table name")
+ if((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get symbol table name")
cmp = HDstrcmp(udata->common.name, s);
if(cmp < 0)
rt = idx;
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index f957e2e..069bf17 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -1671,9 +1671,13 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata)
HGOTO_DONE(TRUE);
if(hdr->filter_len > 0) {
- size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */
- unsigned filter_mask; /* Excluded filters for direct block */
- H5Z_cb_t filter_cb = {NULL, NULL}; /* Filter callback structure */
+ size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */
+ unsigned filter_mask; /* Excluded filters for direct block */
+ H5Z_cb_t filter_cb; /* Filter callback structure */
+
+ /* Initialize the filter callback struct */
+ filter_cb.op_data = NULL;
+ filter_cb.func = NULL; /* no callback function when failed */
/* Allocate buffer to perform I/O filtering on and copy image into
* it. Must do this as H5Z_pipeline() may re-size the buffer
@@ -1682,17 +1686,17 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata)
if(NULL == (read_buf = H5MM_malloc(len)))
HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for pipeline buffer")
- /* Set up parameters for filter pipeline */
- nbytes = len;
- filter_mask = udata->filter_mask;
+ /* Set up parameters for filter pipeline */
+ nbytes = len;
+ filter_mask = udata->filter_mask;
HDmemcpy(read_buf, image, len);
- /* Push direct block data through I/O filter pipeline */
- if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, FAIL, "output pipeline failed")
+ /* Push direct block data through I/O filter pipeline */
+ if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, FAIL, "output pipeline failed")
/* Update info about direct block */
- udata->decompressed = TRUE;
+ udata->decompressed = TRUE;
len = nbytes;
} /* end if */
else
@@ -1818,45 +1822,49 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata,
udata->dblk = NULL;
} /* end if */
else {
- H5Z_cb_t filter_cb = {NULL, NULL}; /* Filter callback structure */
+ H5Z_cb_t filter_cb; /* Filter callback structure */
size_t nbytes; /* Number of bytes used in buffer, after applying reverse filters */
unsigned filter_mask; /* Excluded filters for direct block */
/* Sanity check */
- HDassert(udata->dblk == NULL);
+ HDassert(udata->dblk == NULL);
- /* Allocate buffer to perform I/O filtering on and copy image into
- * it. Must do this as H5Z_pipeline() may resize the buffer
- * provided to it.
- */
- if(NULL == (read_buf = H5MM_malloc(len)))
- HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed for pipeline buffer")
+ /* Initialize the filter callback struct */
+ filter_cb.op_data = NULL;
+ filter_cb.func = NULL; /* no callback function when failed */
+
+ /* Allocate buffer to perform I/O filtering on and copy image into
+ * it. Must do this as H5Z_pipeline() may resize the buffer
+ * provided to it.
+ */
+ if (NULL == (read_buf = H5MM_malloc(len)))
+ HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, NULL, "memory allocation failed for pipeline buffer")
/* Copy compressed image into buffer */
- HDmemcpy(read_buf, image, len);
+ HDmemcpy(read_buf, image, len);
- /* Push direct block data through I/O filter pipeline */
- nbytes = len;
- filter_mask = udata->filter_mask;
- if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0)
- HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, NULL, "output pipeline failed")
+ /* Push direct block data through I/O filter pipeline */
+ nbytes = len;
+ filter_mask = udata->filter_mask;
+ if (H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_ENABLE_EDC, filter_cb, &nbytes, &len, &read_buf) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTFILTER, NULL, "output pipeline failed")
- /* Sanity check */
- HDassert(nbytes == dblock->size);
+ /* Sanity check */
+ HDassert(nbytes == dblock->size);
- /* Copy un-filtered data into block's buffer */
- HDmemcpy(dblock->blk, read_buf, dblock->size);
- } /* end if */
+ /* Copy un-filtered data into block's buffer */
+ HDmemcpy(dblock->blk, read_buf, dblock->size);
+ } /* end if */
} /* end if */
else {
/* Sanity checks */
- HDassert(udata->dblk == NULL);
- HDassert(!udata->decompressed);
+ HDassert(udata->dblk == NULL);
+ HDassert(!udata->decompressed);
- /* Allocate block buffer */
-/* XXX: Change to using free-list factories */
- if(NULL == (dblock->blk = H5FL_BLK_MALLOC(direct_block, (size_t)dblock->size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ /* Allocate block buffer */
+ /* XXX: Change to using free-list factories */
+ if (NULL == (dblock->blk = H5FL_BLK_MALLOC(direct_block, (size_t)dblock->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy image to dblock->blk */
HDassert(dblock->size == len);
@@ -1895,9 +1903,9 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata,
/* Decode checksum on direct block, if requested */
if(hdr->checksum_dblocks) {
- uint32_t stored_chksum; /* Metadata checksum value */
+ uint32_t stored_chksum; /* Metadata checksum value */
- /* checksum verification already done in verify_chksum cb */
+ /* checksum verification already done in verify_chksum cb */
/* Metadata checksum */
UINT32DECODE(image, stored_chksum);
@@ -2188,10 +2196,14 @@ H5HF__cache_dblock_pre_serialize(H5F_t *f, hid_t dxpl_id, void *_thing,
/* Check for I/O filters on this heap */
if(hdr->filter_len > 0) {
- H5Z_cb_t filter_cb = {NULL, NULL}; /* Filter callback structure */
+ H5Z_cb_t filter_cb; /* Filter callback structure */
size_t nbytes; /* Number of bytes used */
unsigned filter_mask = 0; /* Filter mask for block */
+ /* Initialize the filter callback struct */
+ filter_cb.op_data = NULL;
+ filter_cb.func = NULL; /* no callback function when failed */
+
/* Allocate buffer to perform I/O filtering on */
write_size = dblock->size;
if(NULL == (write_buf = H5MM_malloc(write_size)))
diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c
index b2a1e68..350100e 100644
--- a/src/H5HFhuge.c
+++ b/src/H5HFhuge.c
@@ -345,9 +345,13 @@ HDfprintf(stderr, "%s: obj_size = %Zu\n", FUNC, obj_size);
/* Check for I/O pipeline filter on heap */
if(hdr->filter_len > 0) {
- H5Z_cb_t filter_cb = {NULL, NULL}; /* Filter callback structure */
+ H5Z_cb_t filter_cb; /* Filter callback structure */
size_t nbytes; /* Number of bytes used */
+ /* Initialize the filter callback struct */
+ filter_cb.op_data = NULL;
+ filter_cb.func = NULL; /* no callback function when failed */
+
/* Allocate buffer to perform I/O filtering on */
write_size = obj_size;
if(NULL == (write_buf = H5MM_malloc(write_size)))
@@ -773,10 +777,14 @@ H5HF_huge_op_real(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id,
/* Check for I/O pipeline filter on heap */
if(hdr->filter_len > 0) {
- H5Z_cb_t filter_cb = {NULL, NULL}; /* Filter callback structure */
+ H5Z_cb_t filter_cb; /* Filter callback structure */
size_t read_size; /* Object's size in the file */
size_t nbytes; /* Number of bytes used */
+ /* Initialize the filter callback struct */
+ filter_cb.op_data = NULL;
+ filter_cb.func = NULL; /* no callback function when failed */
+
/* De-filter the object */
read_size = nbytes = obj_size;
if(H5Z_pipeline(&(hdr->pline), H5Z_FLAG_REVERSE, &filter_mask, H5Z_NO_EDC, filter_cb, &nbytes, &read_size, &read_buf) < 0)
diff --git a/src/H5MF.c b/src/H5MF.c
index 49c7b77..7e06654 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -3247,7 +3247,6 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled)
/* for self referential FSMs */
haddr_t eoa_post_fsm_fsalloc; /* eoa post file space allocation */
/* for self referential FSMs */
- H5FS_stat_t fs_stat; /* Information for hdr FSM */
H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */
H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */
hbool_t reset_ring = FALSE; /* Whether we set the ring */
@@ -3310,6 +3309,9 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled)
reset_ring = TRUE;
#ifndef NDEBUG
+{
+ H5FS_stat_t fs_stat; /* Information for hdr FSM */
+
/* Verify that sm_hdr_fspace is floating if it exists */
if(sm_hdr_fspace) {
/* Query free space manager info for this type */
@@ -3357,6 +3359,7 @@ H5MF_settle_meta_data_fsm(H5F_t *f, hid_t dxpl_id, hbool_t *fsm_settled)
HDassert(fs_stat.alloc_sect_size == 0);
} /* end if */
} /* end if */
+}
#endif /* NDEBUG */
/* Free the space in the metadata aggregator. Do this via the
diff --git a/src/H5MM.c b/src/H5MM.c
index ee3b28f..866dfbe 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -268,8 +268,6 @@ H5MM_malloc(size_t size)
{
void *ret_value = NULL;
- HDassert(size);
-
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -357,8 +355,6 @@ H5MM_calloc(size_t size)
{
void *ret_value = NULL;
- HDassert(size);
-
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -407,8 +403,6 @@ H5MM_realloc(void *mem, size_t size)
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOERR
- HDassert(mem || size);
-
if(NULL == mem && 0 == size)
/* Not defined in the standard, return NULL */
ret_value = NULL;
@@ -454,7 +448,7 @@ H5MM_realloc(void *mem, size_t size)
* NULL is an acceptable value for the input string.
*
* Return: Success: Pointer to a new string (NULL if s is NULL).
- * Failure: abort()
+ * Failure: NULL
*
* Programmer: Robb Matzke
* Jul 10 1997
diff --git a/src/H5O.c b/src/H5O.c
index 152e6cc..cf84b47 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -13,11 +13,9 @@
/*-------------------------------------------------------------------------
*
- * Created: H5O.c
- * Aug 5 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5O.c
*
- * Purpose: Object header routines.
+ * Purpose: Public object header routines
*
*-------------------------------------------------------------------------
*/
@@ -32,19 +30,12 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5FLprivate.h" /* Free lists */
-#include "H5FOprivate.h" /* File objects */
-#include "H5Iprivate.h" /* IDs */
-#include "H5Lprivate.h" /* Links */
-#include "H5MFprivate.h" /* File memory management */
-#ifdef H5O_ENABLE_BOGUS
-#include "H5MMprivate.h" /* Memory management */
-#endif /* H5O_ENABLE_BOGUS */
-#include "H5Opkg.h" /* Object headers */
-#include "H5SMprivate.h" /* Shared object header messages */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Lprivate.h" /* Links */
+#include "H5Opkg.h" /* Object headers */
/****************/
@@ -56,17 +47,6 @@
/* Local Typedefs */
/******************/
-/* User data for recursive traversal over objects from a group */
-typedef struct {
- hid_t obj_id; /* The ID for the starting group */
- H5G_loc_t *start_loc; /* Location of starting group */
- hid_t lapl_id; /* LAPL for walking across links */
- hid_t dxpl_id; /* DXPL for operations */
- H5SL_t *visited; /* Skip list for tracking visited nodes */
- H5O_iterate_t op; /* Application callback */
- void *op_data; /* Application's op data */
-} H5O_iter_visit_ud_t;
-
/********************/
/* Package Typedefs */
@@ -77,136 +57,21 @@ typedef struct {
/* Local Prototypes */
/********************/
-static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh);
-static herr_t H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type);
-static herr_t H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
- H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id,
- hid_t dxpl_id);
-static herr_t H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr);
-static const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh);
-
/*********************/
/* Package Variables */
/*********************/
-/* Package initialization variable */
-hbool_t H5_PKG_INIT_VAR = FALSE;
-
-/* Header message ID to class mapping */
-
-/* Remember to increment H5O_MSG_TYPES in H5Opkg.h when adding a new
- * message.
- */
-
-const H5O_msg_class_t *const H5O_msg_class_g[] = {
- H5O_MSG_NULL, /*0x0000 Null */
- H5O_MSG_SDSPACE, /*0x0001 Dataspace */
- H5O_MSG_LINFO, /*0x0002 Link information */
- H5O_MSG_DTYPE, /*0x0003 Datatype */
- H5O_MSG_FILL, /*0x0004 Old data storage -- fill value */
- H5O_MSG_FILL_NEW, /*0x0005 New data storage -- fill value */
- H5O_MSG_LINK, /*0x0006 Link */
- H5O_MSG_EFL, /*0x0007 Data storage -- external data files */
- H5O_MSG_LAYOUT, /*0x0008 Data Layout */
-#ifdef H5O_ENABLE_BOGUS
- H5O_MSG_BOGUS_VALID, /*0x0009 "Bogus valid" (for testing) */
-#else /* H5O_ENABLE_BOGUS */
- NULL, /*0x0009 "Bogus valid" (for testing) */
-#endif /* H5O_ENABLE_BOGUS */
- H5O_MSG_GINFO, /*0x000A Group information */
- H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */
- H5O_MSG_ATTR, /*0x000C Attribute */
- H5O_MSG_NAME, /*0x000D Object name */
- H5O_MSG_MTIME, /*0x000E Object modification date and time */
- H5O_MSG_SHMESG, /*0x000F File-wide shared message table */
- H5O_MSG_CONT, /*0x0010 Object header continuation */
- H5O_MSG_STAB, /*0x0011 Symbol table */
- H5O_MSG_MTIME_NEW, /*0x0012 New Object modification date and time */
- H5O_MSG_BTREEK, /*0x0013 Non-default v1 B-tree 'K' values */
- H5O_MSG_DRVINFO, /*0x0014 Driver info settings */
- H5O_MSG_AINFO, /*0x0015 Attribute information */
- H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */
- H5O_MSG_FSINFO, /*0x0017 Free-space manager info */
- H5O_MSG_MDCI, /*0x0018 Metadata cache image */
- H5O_MSG_UNKNOWN, /*0x0019 Placeholder for unknown message */
-#ifdef H5O_ENABLE_BOGUS
- H5O_MSG_BOGUS_INVALID, /*0x001A "Bogus invalid" (for testing) */
-#else /* H5O_ENABLE_BOGUS */
- NULL, /*0x001A "Bogus invalid" (for testing) */
-#endif /* H5O_ENABLE_BOGUS */
-};
-
-/* Declare a free list to manage the H5O_t struct */
-H5FL_DEFINE(H5O_t);
-
-/* Declare a free list to manage the H5O_mesg_t sequence information */
-H5FL_SEQ_DEFINE(H5O_mesg_t);
-
-/* Declare a free list to manage the H5O_chunk_t sequence information */
-H5FL_SEQ_DEFINE(H5O_chunk_t);
-
-/* Declare a free list to manage the chunk image information */
-H5FL_BLK_DEFINE(chunk_image);
-
-/* Declare external the free list for H5O_cont_t sequences */
-H5FL_SEQ_EXTERN(H5O_cont_t);
-
/*****************************/
/* Library Private Variables */
/*****************************/
-/* Declare external the free list for time_t's */
-H5FL_EXTERN(time_t);
-
-/* Declare external the free list for H5_obj_t's */
-H5FL_EXTERN(H5_obj_t);
-
/*******************/
/* Local Variables */
/*******************/
-/* Header object ID to class mapping */
-/*
- * Initialize the object class info table. Begin with the most general types
- * and end with the most specific. For instance, any object that has a
- * datatype message is a datatype but only some of them are datasets.
- */
-static const H5O_obj_class_t *const H5O_obj_class_g[] = {
- H5O_OBJ_DATATYPE, /* Datatype object (H5O_TYPE_NAMED_DATATYPE - 2) */
- H5O_OBJ_DATASET, /* Dataset object (H5O_TYPE_DATASET - 1) */
- H5O_OBJ_GROUP, /* Group object (H5O_TYPE_GROUP - 0) */
-};
-
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O__init_package
- *
- * Purpose: Initialize information specific to H5O interface.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * Thursday, January 18, 2007
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O__init_package(void)
-{
- FUNC_ENTER_PACKAGE_NOERR
-
- /* H5O interface sanity checks */
- HDcompile_assert(H5O_MSG_TYPES == NELMTS(H5O_msg_class_g));
- HDcompile_assert(sizeof(H5O_fheap_id_t) == H5O_FHEAP_ID_LEN);
-
- HDcompile_assert(H5O_UNKNOWN_ID < H5O_MSG_TYPES);
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5O__init_package() */
/*-------------------------------------------------------------------------
@@ -302,11 +167,11 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
if(H5G_loc(loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!group_name || !*group_name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
/* Verify access property list and get correct dxpl */
if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0)
@@ -710,11 +575,11 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
if(H5G_loc(loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!group_name || !*group_name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
if(!oinfo)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct")
@@ -958,15 +823,15 @@ H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
/* Check args */
if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
if(!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified")
/* Call internal object visitation routine */
if((ret_value = H5O_visit(obj_id, ".", idx_type, order, op, op_data, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed")
+ HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1020,9 +885,9 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
if(!obj_name || !*obj_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
if(!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified")
@@ -1032,7 +897,7 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
/* Call internal object visitation routine */
if((ret_value = H5O_visit(loc_id, obj_name, idx_type, order, op, op_data, lapl_id, dxpl_id)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed")
+ HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed")
done:
FUNC_LEAVE_API(ret_value)
@@ -1212,2514 +1077,3 @@ done:
FUNC_LEAVE_API(ret_value)
} /* H5Oare_mdc_flushes_disabled() */
-
-/*-------------------------------------------------------------------------
- * Function: H5O_create
- *
- * Purpose: Creates a new object header. Allocates space for it and
- * then calls an initialization function. The object header
- * is opened for write access and should eventually be
- * closed by calling H5O_close().
- *
- * Return: Success: Non-negative, the ENT argument contains
- * information about the object header,
- * including its address.
- *
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 5 1997
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc,
- hid_t ocpl_id, H5O_loc_t *loc/*out*/)
-{
- H5P_genplist_t *oc_plist; /* Object creation property list */
- H5O_t *oh = NULL; /* Object header created */
- haddr_t oh_addr; /* Address of initial object header */
- size_t oh_size; /* Size of initial object header */
- uint8_t oh_flags; /* Object header's initial status flags */
- unsigned insert_flags = H5AC__NO_FLAGS_SET; /* Flags for inserting object header into cache */
- hbool_t store_msg_crt_idx; /* Whether to always store message creation indices for this file */
- herr_t ret_value = SUCCEED; /* return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check args */
- HDassert(f);
- HDassert(loc);
- HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE));
-
- /* Check for invalid access request */
- if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR))
- HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "no write intent on file")
-
- /* Make certain we allocate at least a reasonable size for the object header */
- size_hint = H5O_ALIGN_F(f, MAX(H5O_MIN_SIZE, size_hint));
-
- /* Get the property list */
- if(NULL == (oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id)))
- HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list")
-
- /* Get any object header status flags set by properties */
- if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags")
-
- /* Allocate the object header and zero out header fields */
- if(NULL == (oh = H5FL_CALLOC(H5O_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-
- /* Initialize file-specific information for object header */
- store_msg_crt_idx = H5F_STORE_MSG_CRT_IDX(f);
- if(H5F_USE_LATEST_FLAGS(f, H5F_LATEST_OBJ_HEADER) || store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED))
- oh->version = H5O_VERSION_LATEST;
- else
- oh->version = H5O_VERSION_1;
- oh->sizeof_size = H5F_SIZEOF_SIZE(f);
- oh->sizeof_addr = H5F_SIZEOF_ADDR(f);
- oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE);
-#ifdef H5O_ENABLE_BAD_MESG_COUNT
- /* Check whether the "bad message count" property is set */
- if(H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME) > 0) {
- /* Retrieve bad message count flag */
- if(H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get bad message count flag")
- } /* end if */
-#endif /* H5O_ENABLE_BAD_MESG_COUNT */
-
- /* Create object header proxy if doing SWMR writes */
- if(oh->swmr_write) {
- /* Create virtual entry, for use as proxy */
- if(NULL == (oh->proxy = H5AC_proxy_entry_create()))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy")
- } /* end if */
- else
- oh->proxy = NULL;
-
- /* Set initial status flags */
- oh->flags = oh_flags;
-
- /* Initialize version-specific fields */
- if(oh->version > H5O_VERSION_1) {
- /* Initialize all time fields with current time, if we are storing them */
- if(oh->flags & H5O_HDR_STORE_TIMES)
- oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now();
- else
- oh->atime = oh->mtime = oh->ctime = oh->btime = 0;
-
- /* Make certain attribute creation order tracking is enabled if
- * attributes can be shared in this file.
- */
- if(store_msg_crt_idx)
- oh->flags |= H5O_HDR_ATTR_CRT_ORDER_TRACKED;
-
- /* Retrieve attribute storage phase change values from property list */
- if(H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes")
- if(H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes")
-
- /* Check for non-default attribute storage phase change values */
- if(oh->max_compact != H5O_CRT_ATTR_MAX_COMPACT_DEF || oh->min_dense != H5O_CRT_ATTR_MIN_DENSE_DEF)
- oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE;
-
- /* Determine correct value for chunk #0 size bits */
-/* Avoid compiler warning on 32-bit machines */
-#if H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T
- if(size_hint > 4294967295UL)
- oh->flags |= H5O_HDR_CHUNK0_8;
- else
-#endif /* H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T */
- if(size_hint > 65535)
- oh->flags |= H5O_HDR_CHUNK0_4;
- else if(size_hint > 255)
- oh->flags |= H5O_HDR_CHUNK0_2;
- } /* end if */
- else {
- /* Reset unused time fields */
- oh->atime = oh->mtime = oh->ctime = oh->btime = 0;
- } /* end else */
-
- /* Compute total size of initial object header */
- /* (i.e. object header prefix and first chunk) */
- oh_size = (size_t)H5O_SIZEOF_HDR(oh) + size_hint;
-
- /* Allocate disk space for header and first chunk */
- if(HADDR_UNDEF == (oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)oh_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header")
-
- /* Create the chunk list */
- oh->nchunks = oh->alloc_nchunks = 1;
- if(NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-
- /* Initialize the first chunk */
- oh->chunk[0].addr = oh_addr;
- oh->chunk[0].size = oh_size;
- oh->chunk[0].gap = 0;
-
- /* Allocate enough space for the first chunk */
- /* (including space for serializing the object header prefix */
- if(NULL == (oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- oh->chunk[0].chunk_proxy = NULL;
-
- /* Put magic # for object header in first chunk */
- if(oh->version > H5O_VERSION_1)
- HDmemcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
-
- /* Create the message list */
- oh->nmesgs = 1;
- oh->alloc_nmesgs = H5O_NMESGS;
- if(NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-
- /* Initialize the initial "null" message, covering the entire first chunk */
- oh->mesg[0].type = H5O_MSG_NULL;
- oh->mesg[0].dirty = TRUE;
- oh->mesg[0].native = NULL;
- oh->mesg[0].raw = oh->chunk[0].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)) + H5O_SIZEOF_MSGHDR_OH(oh);
- oh->mesg[0].raw_size = size_hint - (size_t)H5O_SIZEOF_MSGHDR_OH(oh);
- oh->mesg[0].chunkno = 0;
-
- /* Check for non-zero initial refcount on the object header */
- if(initial_rc > 0) {
- /* Set the initial refcount & pin the header when its inserted */
- oh->rc = initial_rc;
- insert_flags |= H5AC__PIN_ENTRY_FLAG;
- } /* end if */
-
- /* Set metadata tag in dxpl_id */
- H5_BEGIN_TAG(dxpl_id, oh_addr, FAIL);
-
- /* Cache object header */
- if(H5AC_insert_entry(f, dxpl_id, H5AC_OHDR, oh_addr, oh, insert_flags) < 0)
- HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header")
-
- /* Reset object header pointer, now that it's been inserted into the cache */
- oh = NULL;
-
- /* Reset metadata tag in dxpl_id */
- H5_END_TAG(FAIL);
-
- /* Set up object location */
- loc->file = f;
- loc->addr = oh_addr;
-
- /* Open it */
- if(H5O_open(loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header")
-
-done:
- if(ret_value < 0 && oh)
- if(H5O__free(oh) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_create() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_open
- *
- * Purpose: Opens an object header which is described by the symbol table
- * entry OBJ_ENT.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * Monday, January 5, 1998
- *
- * Modification:
- * Raymond Lu
- * 5 November 2007
- * Turn off the holding file variable if it's on. When it's
- * needed, the caller will turn it on again.
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_open(H5O_loc_t *loc)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(loc);
- HDassert(loc->file);
-
-#ifdef H5O_DEBUG
- if(H5DEBUG(O))
- HDfprintf(H5DEBUG(O), "> %a\n", loc->addr);
-#endif
-
- /* Turn off the variable for holding file or increment open-lock counters */
- if(loc->holding_file)
- loc->holding_file = FALSE;
- else
- H5F_INCR_NOPEN_OBJS(loc->file);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_open() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_open_name
- *
- * Purpose: Opens an object within an HDF5 file.
- *
- * Return: Success: An open object identifier
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * March 5 2007
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref)
-{
- H5G_loc_t obj_loc; /* Location used to open group */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
- hbool_t loc_found = FALSE; /* Entry at 'name' found */
- hid_t ret_value = FAIL;
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(loc);
- HDassert(name && *name);
-
- /* Set up opened group location to fill in */
- obj_loc.oloc = &obj_oloc;
- obj_loc.path = &obj_path;
- H5G_loc_reset(&obj_loc);
-
- /* Find the object's location */
- if(H5G_loc_find(loc, name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
- loc_found = TRUE;
-
- /* Open the object */
- if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, app_ref)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
-
-done:
- if(ret_value < 0 && loc_found)
- if(H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_open_name() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_open_by_loc
- *
- * Purpose: Opens an object and returns an ID given its group loction.
- *
- * Return: Success: Open object identifier
- * Failure: Negative
- *
- * Programmer: James Laird
- * July 25 2006
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref)
-{
- const H5O_obj_class_t *obj_class; /* Class of object for location */
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- HDassert(obj_loc);
-
- /* Get the object class for this location */
- if(NULL == (obj_class = H5O_obj_class(obj_loc->oloc, dxpl_id)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class")
-
- /* Call the object class's 'open' routine */
- HDassert(obj_class->open);
- if((ret_value = obj_class->open(obj_loc, lapl_id, dxpl_id, app_ref)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_open_by_loc() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_close
- *
- * Purpose: Closes an object header that was previously open.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * Monday, January 5, 1998
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(loc);
- HDassert(loc->file);
- HDassert(H5F_NOPEN_OBJS(loc->file) > 0);
-
- /* Set the file_closed flag to the default value.
- * This flag lets downstream code know if the file struct is
- * still accessible and/or likely to contain useful data.
- * It's needed by the evict-on-close code. Clients can ignore
- * this value by passing in NULL.
- */
- if(file_closed)
- *file_closed = FALSE;
-
- /* Decrement open-lock counters */
- H5F_DECR_NOPEN_OBJS(loc->file);
-
-#ifdef H5O_DEBUG
- if(H5DEBUG(O)) {
- if(H5F_FILE_ID(loc->file)< 0 && 1 == H5F_NREFS(loc->file))
- HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n",
- loc->addr,
- (unsigned long)H5F_NOPEN_OBJS(loc->file));
- else
- HDfprintf(H5DEBUG(O), "< %a\n", loc->addr);
- } /* end if */
-#endif
-
- /*
- * If the file open object count has reached the number of open mount points
- * (each of which has a group open in the file) attempt to close the file.
- */
- if(H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file))
- /* Attempt to close down the file hierarchy */
- if(H5F_try_close(loc->file, file_closed) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close")
-
- /* Release location information */
- if(H5O_loc_free(loc) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "problem attempting to free location")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_close() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_link_oh
- *
- * Purpose: Adjust the link count for an open object header by adding
- * ADJUST to the link count.
- *
- * Return: Success: New link count
- *
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 5 1997
- *
- *-------------------------------------------------------------------------
- */
-int
-H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t *deleted)
-{
- haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */
- int ret_value = -1; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check args */
- HDassert(f);
- HDassert(oh);
- HDassert(deleted);
-
- /* Check for adjusting link count */
- if(adjust) {
- if(adjust < 0) {
- /* Check for too large of an adjustment */
- if((unsigned)(-adjust) > oh->nlink)
- HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative")
-
- /* Adjust the link count for the object header */
- oh->nlink = (unsigned)((int)oh->nlink + adjust);
-
- /* Mark object header as dirty in cache */
- if(H5AC_mark_entry_dirty(oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty")
-
- /* Check if the object should be deleted */
- if(oh->nlink == 0) {
- /* Check if the object is still open by the user */
- if(H5FO_opened(f, addr) != NULL) {
- /* Flag the object to be deleted when it's closed */
- if(H5FO_mark(f, addr, TRUE) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion")
- } /* end if */
- else {
- /* Mark the object header for deletion */
- *deleted = TRUE;
- } /* end else */
- } /* end if */
- } /* end if */
- else {
- /* A new object, or one that will be deleted */
- if(0 == oh->nlink) {
- /* Check if the object is currently open, but marked for deletion */
- if(H5FO_marked(f, addr)) {
- /* Remove "delete me" flag on the object */
- if(H5FO_mark(f, addr, FALSE) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion")
- } /* end if */
- } /* end if */
-
- /* Adjust the link count for the object header */
- oh->nlink = (unsigned)((int)oh->nlink + adjust);
-
- /* Mark object header as dirty in cache */
- if(H5AC_mark_entry_dirty(oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty")
- } /* end if */
-
- /* Check for operations on refcount message */
- if(oh->version > H5O_VERSION_1) {
- /* Check if the object has a refcount message already */
- if(oh->has_refcount_msg) {
- /* Check for removing refcount message */
- if(oh->nlink <= 1) {
- if(H5O_msg_remove_real(f, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete refcount message")
- oh->has_refcount_msg = FALSE;
- } /* end if */
- /* Update refcount message with new link count */
- else {
- H5O_refcount_t refcount = oh->nlink;
-
- if(H5O_msg_write_real(f, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update refcount message")
- } /* end else */
- } /* end if */
- else {
- /* Check for adding refcount message to object */
- if(oh->nlink > 1) {
- H5O_refcount_t refcount = oh->nlink;
-
- if(H5O_msg_append_real(f, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to create new refcount message")
- oh->has_refcount_msg = TRUE;
- } /* end if */
- } /* end else */
- } /* end if */
- } /* end if */
-
- /* Set return value */
- ret_value = (int)oh->nlink;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_link_oh() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_link
- *
- * Purpose: Adjust the link count for an object header by adding
- * ADJUST to the link count.
- *
- * Return: Success: New link count
- *
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 5 1997
- *
- *-------------------------------------------------------------------------
- */
-int
-H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id)
-{
- H5O_t *oh = NULL;
- hbool_t deleted = FALSE; /* Whether the object was deleted */
- int ret_value = -1; /* Return value */
-
- FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL)
-
- /* check args */
- HDassert(loc);
- HDassert(loc->file);
- HDassert(H5F_addr_defined(loc->addr));
-
- /* Pin the object header */
- if(NULL == (oh = H5O_pin(loc, dxpl_id)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header")
-
- /* Call the "real" link routine */
- if((ret_value = H5O_link_oh(loc->file, adjust, dxpl_id, oh, &deleted)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust object link count")
-
-done:
- if(oh && H5O_unpin(oh) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header")
- if(ret_value >= 0 && deleted && H5O_delete(loc->file, dxpl_id, loc->addr) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file")
-
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
-} /* end H5O_link() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_protect
- *
- * Purpose: Wrapper around H5AC_protect for use during a H5O_protect->
- * H5O_msg_append->...->H5O_msg_append->H5O_unprotect sequence of calls
- * during an object's creation.
- *
- * Return: Success: Pointer to the object header structure for the
- * object.
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Dec 31 2002
- *
- *-------------------------------------------------------------------------
- */
-H5O_t *
-H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, unsigned prot_flags,
- hbool_t pin_all_chunks)
-{
- H5O_t *oh = NULL; /* Object header protected */
- H5O_cache_ud_t udata; /* User data for protecting object header */
- H5O_cont_msgs_t cont_msg_info; /* Continuation message info */
- unsigned file_intent; /* R/W intent on file */
- H5O_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, NULL)
-
- /* check args */
- HDassert(loc);
- HDassert(loc->file);
-
- /* prot_flags may only contain the H5AC__READ_ONLY_FLAG */
- HDassert((prot_flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0);
-
- /* Check for valid address */
- if(!H5F_addr_defined(loc->addr))
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "address undefined")
-
- /* Check for write access on the file */
- file_intent = H5F_INTENT(loc->file);
- if((0 == (prot_flags & H5AC__READ_ONLY_FLAG)) && (0 == (file_intent & H5F_ACC_RDWR)))
- HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "no write intent on file")
-
- /* Construct the user data for protect callback */
- udata.made_attempt = FALSE;
- udata.v1_pfx_nmesgs = 0;
- udata.chunk0_size = 0;
- udata.oh = NULL;
- udata.common.f = loc->file;
- udata.common.dxpl_id = dxpl_id;
- udata.common.file_intent = file_intent;
- udata.common.merged_null_msgs = 0;
- HDmemset(&cont_msg_info, 0, sizeof(cont_msg_info));
- udata.common.cont_msg_info = &cont_msg_info;
- udata.common.addr = loc->addr;
-
- /* Lock the object header into the cache */
- if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, &udata, prot_flags)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header")
-
- /* Check if there are any continuation messages to process */
- if(cont_msg_info.nmsgs > 0) {
- size_t curr_msg; /* Current continuation message to process */
- H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */
-
- /* Sanity check - we should only have continuation messages to process
- * when the object header is actually loaded from the file.
- */
- HDassert(udata.made_attempt == TRUE);
- HDassert(cont_msg_info.msgs);
-
- /* Construct the user data for protecting chunks */
- chk_udata.decoding = TRUE;
- chk_udata.oh = oh;
- chk_udata.chunkno = UINT_MAX; /* Set to invalid value, for better error detection */
- chk_udata.common.f = loc->file;
- chk_udata.common.dxpl_id = dxpl_id;
- chk_udata.common.file_intent = file_intent;
- chk_udata.common.merged_null_msgs = udata.common.merged_null_msgs;
- chk_udata.common.cont_msg_info = &cont_msg_info;
-
- /* Read in continuation messages, until there are no more */
- /* (Note that loading chunks could increase the # of continuation
- * messages if new ones are found - QAK, 19/11/2016)
- */
- curr_msg = 0;
- while(curr_msg < cont_msg_info.nmsgs) {
- H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to bring it into memory */
-#ifndef NDEBUG
- size_t chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */
-#endif /* NDEBUG */
-
- /* Bring the chunk into the cache */
- /* (which adds to the object header) */
- chk_udata.common.addr = cont_msg_info.msgs[curr_msg].addr;
- chk_udata.size = cont_msg_info.msgs[curr_msg].size;
- if(NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, &chk_udata, prot_flags)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header chunk")
-
- /* Sanity check */
- HDassert(chk_proxy->oh == oh);
- HDassert(chk_proxy->chunkno == chkcnt);
- HDassert(oh->nchunks == (chkcnt + 1));
-
- /* Release the chunk from the cache */
- if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header chunk")
-
- /* Advance to next continuation message */
- curr_msg++;
- } /* end while */
-
- /* Release any continuation messages built up */
- cont_msg_info.msgs = (H5O_cont_t *)H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs);
-
- /* Pass back out some of the chunk's user data */
- udata.common.merged_null_msgs = chk_udata.common.merged_null_msgs;
- } /* end if */
-
- /* Check for incorrect # of object header messages, if we've just loaded
- * this object header from the file
- */
- if(udata.made_attempt) {
-/* Don't enforce the error on an incorrect # of object header messages bug
- * unless strict format checking is enabled. This allows for older
- * files, created with a version of the library that had a bug in tracking
- * the correct # of header messages to be read in without the library
- * erroring out here. -QAK
- */
-#ifdef H5_STRICT_FORMAT_CHECKS
- /* Check for incorrect # of messages in v1 object header */
- if(oh->version == H5O_VERSION_1 &&
- (oh->nmesgs + udata.common.merged_null_msgs) != udata.v1_pfx_nmesgs)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - incorrect # of messages")
-#endif /* H5_STRICT_FORMAT_CHECKS */
- } /* end if */
-
-#ifdef H5O_DEBUG
-H5O_assert(oh);
-#endif /* H5O_DEBUG */
-
- /* Pin the other chunks also when requested, so that the object header
- * proxy can be set up.
- */
- if(pin_all_chunks && oh->nchunks > 1) {
- unsigned u; /* Local index variable */
-
- /* Sanity check */
- HDassert(oh->swmr_write);
-
- /* Iterate over chunks > 0 */
- for(u = 1; u < oh->nchunks; u++) {
- H5O_chunk_proxy_t *chk_proxy; /* Chunk proxy */
-
- /* Protect chunk */
- if(NULL == (chk_proxy = H5O_chunk_protect(loc->file, dxpl_id, oh, u)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header chunk")
-
- /* Pin chunk proxy*/
- if(H5AC_pin_protected_entry(chk_proxy) < 0 )
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, NULL, "unable to pin object header chunk")
-
- /* Unprotect chunk */
- if(H5O_chunk_unprotect(loc->file, dxpl_id, chk_proxy, FALSE) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect object header chunk")
-
- /* Preserve chunk proxy pointer for later */
- oh->chunk[u].chunk_proxy = chk_proxy;
- } /* end for */
-
- /* Set the flag for the unprotect */
- oh->chunks_pinned = TRUE;
- } /* end if */
-
- /* Set return value */
- ret_value = oh;
-
-done:
- if(ret_value == NULL && oh)
- if(H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI_TAG(ret_value, NULL)
-} /* end H5O_protect() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_pin
- *
- * Purpose: Pin an object header down for use during a sequence of message
- * operations, which prevents the object header from being
- * evicted from the cache.
- *
- * Return: Success: Pointer to the object header structure for the
- * object.
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Jul 13 2008
- *
- *-------------------------------------------------------------------------
- */
-H5O_t *
-H5O_pin(const H5O_loc_t *loc, hid_t dxpl_id)
-{
- H5O_t *oh = NULL; /* Object header */
- H5O_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
-
- /* check args */
- HDassert(loc);
-
- /* Get header */
- if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header")
-
- /* Increment the reference count on the object header */
- /* (which will pin it, if appropriate) */
- if(H5O_inc_rc(oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "unable to increment reference count on object header")
-
- /* Set the return value */
- ret_value = oh;
-
-done:
- /* Release the object header from the cache */
- if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_pin() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_unpin
- *
- * Purpose: Unpin an object header, allowing it to be evicted from the
- * metadata cache.
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Jul 13 2008
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_unpin(H5O_t *oh)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check args */
- HDassert(oh);
-
- /* Decrement the reference count on the object header */
- /* (which will unpin it, if appropriate) */
- if(H5O_dec_rc(oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_unpin() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_unprotect
- *
- * Purpose: Wrapper around H5AC_unprotect for use during a H5O_protect->
- * H5O_msg_append->...->H5O_msg_append->H5O_unprotect sequence of calls
- * during an object's creation.
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Dec 31 2002
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_unprotect(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, unsigned oh_flags)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check args */
- HDassert(loc);
- HDassert(oh);
-
- /* Unpin the other chunks */
- if(oh->chunks_pinned && oh->nchunks > 1) {
- unsigned u; /* Local index variable */
-
- /* Sanity check */
- HDassert(oh->swmr_write);
-
- /* Iterate over chunks > 0 */
- for(u = 1; u < oh->nchunks; u++) {
- if(NULL != oh->chunk[u].chunk_proxy) {
- /* Release chunk proxy */
- if(H5AC_unpin_entry(oh->chunk[u].chunk_proxy) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header chunk")
- oh->chunk[u].chunk_proxy = NULL;
- } /* end if */
- } /* end for */
-
- /* Reet the flag from the unprotect */
- oh->chunks_pinned = FALSE;
- } /* end if */
-
- /* Unprotect the object header */
- if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, oh->chunk[0].addr, oh, oh_flags) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_unprotect() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_touch_oh
- *
- * Purpose: If FORCE is non-zero then create a modification time message
- * unless one already exists. Then update any existing
- * modification time message with the current time.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * Monday, July 27, 1998
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force)
-{
- H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
- hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */
- time_t now; /* Current time */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- HDassert(f);
- HDassert(oh);
-
- /* Check if this object header is tracking times */
- if(oh->flags & H5O_HDR_STORE_TIMES) {
- /* Get current time */
- now = H5_now();
-
- /* Check version, to determine how to store time information */
- if(oh->version == H5O_VERSION_1) {
- size_t idx; /* Index of modification time message to update */
-
- /* Look for existing message */
- for(idx = 0; idx < oh->nmesgs; idx++)
- if(H5O_MSG_MTIME == oh->mesg[idx].type || H5O_MSG_MTIME_NEW == oh->mesg[idx].type)
- break;
-
- /* Create a new message, if necessary */
- if(idx == oh->nmesgs) {
- unsigned mesg_flags = 0; /* Flags for message in object header */
-
- /* If we would have to create a new message, but we aren't 'forcing' it, get out now */
- if(!force)
- HGOTO_DONE(SUCCEED); /*nothing to do*/
-
- /* Allocate space for the modification time message */
- if(H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now, &idx) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message")
-
- /* Set the message's flags if appropriate */
- oh->mesg[idx].flags = (uint8_t)mesg_flags;
- } /* end if */
-
- /* Protect chunk */
- if(NULL == (chk_proxy = H5O_chunk_protect(f, dxpl_id, oh, oh->mesg[idx].chunkno)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk")
-
- /* Allocate 'native' space, if necessary */
- if(NULL == oh->mesg[idx].native) {
- if(NULL == (oh->mesg[idx].native = H5FL_MALLOC(time_t)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for modification time message")
- } /* end if */
-
- /* Update the message */
- *((time_t *)(oh->mesg[idx].native)) = now;
-
- /* Mark the message as dirty */
- oh->mesg[idx].dirty = TRUE;
- chk_dirtied = TRUE;
- } /* end if */
- else {
- /* XXX: For now, update access time & change fields in the object header */
- /* (will need to add some code to update modification time appropriately) */
- oh->atime = oh->ctime = now;
-
- /* Mark object header as dirty in cache */
- if(H5AC_mark_entry_dirty(oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty")
- } /* end else */
- } /* end if */
-
-done:
- /* Release chunk */
- if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, chk_proxy, chk_dirtied) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_touch_oh() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_touch
- *
- * Purpose: Touch an object by setting the modification time to the
- * current time and marking the object as dirty. Unless FORCE
- * is non-zero, nothing happens if there is no MTIME message in
- * the object header.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * Monday, July 27, 1998
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_touch(const H5O_loc_t *loc, hbool_t force, hid_t dxpl_id)
-{
- H5O_t *oh = NULL; /* Object header to modify */
- unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check args */
- HDassert(loc);
-
- /* Get the object header */
- if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
-
- /* Create/Update the modification time message */
- if(H5O_touch_oh(loc->file, dxpl_id, oh, force) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to update object modificaton time")
-
- /* Mark object header as changed */
- oh_flags |= H5AC__DIRTIED_FLAG;
-
-done:
- if(oh && H5O_unprotect(loc, dxpl_id, oh, oh_flags) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_touch() */
-
-#ifdef H5O_ENABLE_BOGUS
-
-/*-------------------------------------------------------------------------
- * Function: H5O_bogus_oh
- *
- * Purpose: Create a "bogus" message unless one already exists.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * <koziol@ncsa.uiuc.edu>
- * Tuesday, January 21, 2003
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags)
-{
- size_t idx; /* Local index variable */
- H5O_msg_class_t *type; /* Message class type */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- HDassert(f);
- HDassert(oh);
-
- /* Look for existing message */
- for(idx = 0; idx < oh->nmesgs; idx++)
- if(H5O_MSG_BOGUS_VALID == oh->mesg[idx].type ||
- H5O_MSG_BOGUS_INVALID == oh->mesg[idx].type)
- break;
-
- /* Create a new message */
- if(idx == oh->nmesgs) {
- H5O_bogus_t *bogus; /* Pointer to the bogus information */
-
- /* Allocate the native message in memory */
- if(NULL == (bogus = H5MM_malloc(sizeof(H5O_bogus_t))))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message")
-
- /* Update the native value */
- bogus->u = H5O_BOGUS_VALUE;
-
- if(bogus_id == H5O_BOGUS_VALID_ID)
- type = H5O_MSG_BOGUS_VALID;
- else if(bogus_id == H5O_BOGUS_INVALID_ID)
- type = H5O_MSG_BOGUS_INVALID;
- else
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID for 'bogus' message")
-
- /* Allocate space in the object header for bogus message */
- if(H5O_msg_alloc(f, dxpl_id, oh, type, &mesg_flags, bogus, &idx) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message")
-
- /* Point to "bogus" information (take it over) */
- oh->mesg[idx].native = bogus;
-
- /* Set the appropriate flags for the message */
- oh->mesg[idx].flags = mesg_flags;
-
- /* Mark the message and object header as dirty */
- oh->mesg[idx].dirty = TRUE;
- oh->cache_info.is_dirty = TRUE;
- } /* end if */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_bogus_oh() */
-#endif /* H5O_ENABLE_BOGUS */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_delete
- *
- * Purpose: Delete an object header from a file. This frees the file
- * space used for the object header (and it's continuation blocks)
- * and also walks through each header message and asks it to
- * remove all the pieces of the file referenced by the header.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Mar 19 2003
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
-{
- H5O_t *oh = NULL; /* Object header information */
- H5O_loc_t loc; /* Object location for object to delete */
- unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */
- hbool_t corked;
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_TAG(dxpl_id, addr, FAIL)
-
- /* Check args */
- HDassert(f);
- HDassert(H5F_addr_defined(addr));
-
- /* Set up the object location */
- loc.file = f;
- loc.addr = addr;
- loc.holding_file = FALSE;
-
- /* Get the object header information */
- if(NULL == (oh = H5O_protect(&loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
-
- /* Delete object */
- if(H5O_delete_oh(f, dxpl_id, oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file")
-
- /* Uncork cache entries with tag: addr */
- if(H5AC_cork(f, addr, H5AC__GET_CORKED, &corked) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status")
- if(corked)
- if(H5AC_cork(f, addr, H5AC__UNCORK, NULL) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork an object")
-
- /* Mark object header as deleted */
- oh_flags = H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG;
-
-done:
- if(oh && H5O_unprotect(&loc, dxpl_id, oh, oh_flags) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
-} /* end H5O_delete() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_delete_oh
- *
- * Purpose: Internal function to:
- * Delete an object header from a file. This frees the file
- * space used for the object header (and it's continuation blocks)
- * and also walks through each header message and asks it to
- * remove all the pieces of the file referenced by the header.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Mar 19 2003
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
-{
- H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
- unsigned u;
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check args */
- HDassert(f);
- HDassert(oh);
-
- /* Walk through the list of object header messages, asking each one to
- * delete any file space used
- */
- for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
- /* Free any space referred to in the file from this message */
- if(H5O_delete_mesg(f, dxpl_id, oh, curr_msg) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message")
- } /* end for */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_delete_oh() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_obj_type
- *
- * Purpose: Retrieves the type of object pointed to by `loc'.
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * Wednesday, November 4, 1998
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id)
-{
- H5O_t *oh = NULL; /* Object header for location */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL)
-
- /* Load the object header */
- if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
-
- /* Retrieve the type of the object */
- if(H5O_obj_type_real(oh, obj_type) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type")
-
-done:
- if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
-} /* end H5O_obj_type() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_obj_type_real
- *
- * Purpose: Returns the type of object pointed to by `oh'.
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * Monday, November 21, 2005
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type)
-{
- const H5O_obj_class_t *obj_class; /* Class of object for header */
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Sanity check */
- HDassert(oh);
- HDassert(obj_type);
-
- /* Look up class for object header */
- if(NULL == (obj_class = H5O_obj_class_real(oh))) {
- /* Clear error stack from "failed" class lookup */
- H5E_clear_stack(NULL);
-
- /* Set type to "unknown" */
- *obj_type = H5O_TYPE_UNKNOWN;
- } /* end if */
- else {
- /* Set object type */
- *obj_type = obj_class->type;
- } /* end else */
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5O_obj_type_real() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_obj_class
- *
- * Purpose: Returns the class of object pointed to by `loc'.
- *
- * Return: Success: An object class
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * Monday, November 6, 2006
- *
- *-------------------------------------------------------------------------
- */
-const H5O_obj_class_t *
-H5O_obj_class(const H5O_loc_t *loc, hid_t dxpl_id)
-{
- H5O_t *oh = NULL; /* Object header for location */
- const H5O_obj_class_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->addr, NULL)
-
- /* Load the object header */
- if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header")
-
- /* Test whether entry qualifies as a particular type of object */
- if(NULL == (ret_value = H5O_obj_class_real(oh)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to determine object type")
-
-done:
- if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI_TAG(ret_value, NULL)
-} /* end H5O_obj_class() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_obj_class_real
- *
- * Purpose: Returns the class of object pointed to by `oh'.
- *
- * Return: Success: An object class
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * Monday, November 21, 2005
- *
- *-------------------------------------------------------------------------
- */
-static const H5O_obj_class_t *
-H5O_obj_class_real(H5O_t *oh)
-{
- size_t i; /* Local index variable */
- const H5O_obj_class_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
-
- /* Sanity check */
- HDassert(oh);
-
- /* Test whether entry qualifies as a particular type of object */
- /* (Note: loop is in reverse order, to test specific objects first) */
- for(i = NELMTS(H5O_obj_class_g); i > 0; --i) {
- htri_t isa; /* Is entry a particular type? */
-
- if((isa = (H5O_obj_class_g[i - 1]->isa)(oh)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type")
- else if(isa)
- HGOTO_DONE(H5O_obj_class_g[i - 1])
- } /* end for */
-
- if(0 == i)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_obj_class_real() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_get_loc
- *
- * Purpose: Gets the object location for an object given its ID.
- *
- * Return: Success: Pointer to H5O_loc_t
- * Failure: NULL
- *
- * Programmer: James Laird
- * July 25 2006
- *
- *-------------------------------------------------------------------------
- */
-H5O_loc_t *
-H5O_get_loc(hid_t object_id)
-{
- H5O_loc_t *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- switch(H5I_get_type(object_id)) {
- case H5I_GROUP:
- if(NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from group ID")
- break;
-
- case H5I_DATASET:
- if(NULL == (ret_value = H5O_OBJ_DATASET->get_oloc(object_id)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from dataset ID")
- break;
-
- case H5I_DATATYPE:
- if(NULL == (ret_value = H5O_OBJ_DATATYPE->get_oloc(object_id)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from datatype ID")
- break;
-
- case H5I_UNINIT:
- case H5I_BADID:
- case H5I_FILE:
- case H5I_DATASPACE:
- case H5I_ATTR:
- case H5I_REFERENCE:
- case H5I_VFL:
- case H5I_GENPROP_CLS:
- case H5I_GENPROP_LST:
- case H5I_ERROR_CLASS:
- case H5I_ERROR_MSG:
- case H5I_ERROR_STACK:
- case H5I_NTYPES:
- default:
- HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, NULL, "invalid object type")
- } /* end switch */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_get_loc() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_loc_reset
- *
- * Purpose: Reset a object location to an empty state
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * Monday, September 19, 2005
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_loc_reset(H5O_loc_t *loc)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check arguments */
- HDassert(loc);
-
- /* Clear the object location to an empty state */
- HDmemset(loc, 0, sizeof(H5O_loc_t));
- loc->addr = HADDR_UNDEF;
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5O_loc_reset() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_loc_copy
- *
- * Purpose: Copy object location information
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Monday, September 19, 2005
- *
- * Notes: 'depth' parameter determines how much of the group entry
- * structure we want to copy. The values are:
- * H5_COPY_SHALLOW - Copy all the field values from the source
- * to the destination, but not copying objects pointed to.
- * (Destination "takes ownership" of objects pointed to)
- * H5_COPY_DEEP - Copy all the fields from the source to
- * the destination, deep copying objects pointed to.
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check arguments */
- HDassert(src);
- HDassert(dst);
- HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP);
-
- /* Copy the top level information */
- HDmemcpy(dst, src, sizeof(H5O_loc_t));
-
- /* Deep copy the names */
- if(depth == H5_COPY_DEEP) {
- /* If the original entry was holding open the file, this one should
- * hold it open, too.
- */
- if(src->holding_file)
- H5F_INCR_NOPEN_OBJS(dst->file);
- } else if(depth == H5_COPY_SHALLOW) {
- H5O_loc_reset(src);
- } /* end if */
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5O_loc_copy() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_loc_hold_file
- *
- * Purpose: Have this object header hold a file open until it is
- * released.
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: James Laird
- * Wednesday, August 16, 2006
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_loc_hold_file(H5O_loc_t *loc)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check arguments */
- HDassert(loc);
- HDassert(loc->file);
-
- /* If this location is not already holding its file open, do so. */
- if(!loc->holding_file) {
- H5F_INCR_NOPEN_OBJS(loc->file);
- loc->holding_file = TRUE;
- } /* end if */
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5O_loc_hold_file() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_loc_free
- *
- * Purpose: Release resources used by this object header location.
- * Not to be confused with H5O_close; this is used on
- * locations that don't correspond to open objects.
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: James Laird
- * Wednesday, August 16, 2006
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_loc_free(H5O_loc_t *loc)
-{
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check arguments */
- HDassert(loc);
-
- /* If this location is holding its file open try to close the file. */
- if(loc->holding_file) {
- H5F_DECR_NOPEN_OBJS(loc->file);
- loc->holding_file = FALSE;
- if(H5F_NOPEN_OBJS(loc->file) <= 0) {
- if(H5F_try_close(loc->file, NULL) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file")
- } /* end if */
- } /* end if */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_loc_free() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_get_hdr_info
- *
- * Purpose: Retrieve the object header information for an object
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * September 22 2009
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_get_hdr_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_hdr_info_t *hdr)
-{
- H5O_t *oh = NULL; /* Object header */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(loc);
- HDassert(hdr);
-
- /* Reset the object header info structure */
- HDmemset(hdr, 0, sizeof(*hdr));
-
- /* Get the object header */
- if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
-
- /* Get the information for the object header */
- if(H5O_get_hdr_info_real(oh, hdr) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
-
-done:
- if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_get_hdr_info() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_get_hdr_info_real
- *
- * Purpose: Internal routine to retrieve the object header information for an object
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * September 22 2009
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
-{
- const H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
- const H5O_chunk_t *curr_chunk; /* Pointer to current message being operated on */
- unsigned u; /* Local index variable */
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check args */
- HDassert(oh);
- HDassert(hdr);
-
- /* Set the version for the object header */
- hdr->version = oh->version;
-
- /* Set the number of messages & chunks */
- H5_CHECKED_ASSIGN(hdr->nmesgs, unsigned, oh->nmesgs, size_t);
- H5_CHECKED_ASSIGN(hdr->nchunks, unsigned, oh->nchunks, size_t);
-
- /* Set the status flags */
- hdr->flags = oh->flags;
-
- /* Iterate over all the messages, accumulating message size & type information */
- hdr->space.meta = (hsize_t)H5O_SIZEOF_HDR(oh) + (hsize_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1));
- hdr->space.mesg = 0;
- hdr->space.free = 0;
- hdr->mesg.present = 0;
- hdr->mesg.shared = 0;
- for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
- uint64_t type_flag; /* Flag for message type */
-
- /* Accumulate space usage information, based on the type of message */
- if(H5O_NULL_ID == curr_msg->type->id)
- hdr->space.free += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size);
- else if(H5O_CONT_ID == curr_msg->type->id)
- hdr->space.meta += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size);
- else {
- hdr->space.meta += (hsize_t)H5O_SIZEOF_MSGHDR_OH(oh);
- hdr->space.mesg += curr_msg->raw_size;
- } /* end else */
-
- /* Set flag to indicate presence of message type */
- type_flag = ((uint64_t)1) << curr_msg->type->id;
- hdr->mesg.present |= type_flag;
-
- /* Set flag if the message is shared in some way */
- if(curr_msg->flags & H5O_MSG_FLAG_SHARED) \
- hdr->mesg.shared |= type_flag;
- } /* end for */
-
- /* Iterate over all the chunks, adding any gaps to the free space */
- hdr->space.total = 0;
- for(u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) {
- /* Accumulate the size of the header on disk */
- hdr->space.total += curr_chunk->size;
-
- /* If the chunk has a gap, add it to the free space */
- hdr->space.free += curr_chunk->gap;
- } /* end for */
-
- /* Sanity check that all the bytes are accounted for */
- HDassert(hdr->space.total == (hdr->space.free + hdr->space.meta + hdr->space.mesg));
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5O_get_hdr_info_real() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_get_info
- *
- * Purpose: Retrieve the information for an object
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * November 21 2006
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_get_info(const H5O_loc_t *loc, hid_t dxpl_id, hbool_t want_ih_info,
- H5O_info_t *oinfo)
-{
- const H5O_obj_class_t *obj_class; /* Class of object for header */
- H5O_t *oh = NULL; /* Object header */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL)
-
- /* Check args */
- HDassert(loc);
- HDassert(oinfo);
-
- /* Get the object header */
- if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
-
- /* Reset the object info structure */
- HDmemset(oinfo, 0, sizeof(*oinfo));
-
- /* Retrieve the file's fileno */
- H5F_GET_FILENO(loc->file, oinfo->fileno);
-
- /* Set the object's address */
- oinfo->addr = loc->addr;
-
- /* Get class for object */
- if(NULL == (obj_class = H5O_obj_class_real(oh)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class")
-
- /* Retrieve the type of the object */
- oinfo->type = obj_class->type;
-
- /* Set the object's reference count */
- oinfo->rc = oh->nlink;
-
- /* Get modification time for object */
- if(oh->version > H5O_VERSION_1) {
- oinfo->atime = oh->atime;
- oinfo->mtime = oh->mtime;
- oinfo->ctime = oh->ctime;
- oinfo->btime = oh->btime;
- } /* end if */
- else {
- htri_t exists; /* Flag if header message of interest exists */
-
- /* No information for access & modification fields */
- /* (we stopped updating the "modification time" header message for
- * raw data changes, so the "modification time" header message
- * is closest to the 'change time', in POSIX terms - QAK)
- */
- oinfo->atime = 0;
- oinfo->mtime = 0;
- oinfo->btime = 0;
-
- /* Might be information for modification time */
- if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_ID)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME message")
- if(exists > 0) {
- /* Get "old style" modification time info */
- if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_MTIME_ID, &oinfo->ctime))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME message")
- } /* end if */
- else {
- /* Check for "new style" modification time info */
- if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_NEW_ID)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME_NEW message")
- if(exists > 0) {
- /* Get "new style" modification time info */
- if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_MTIME_NEW_ID, &oinfo->ctime))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME_NEW message")
- } /* end if */
- else
- oinfo->ctime = 0;
- } /* end else */
- } /* end else */
-
- /* Get the information for the object header */
- if(H5O_get_hdr_info_real(oh, &oinfo->hdr) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
-
- /* Retrieve # of attributes */
- if(H5O_attr_count_real(loc->file, dxpl_id, oh, &oinfo->num_attrs) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count")
-
- /* Get B-tree & heap metadata storage size, if requested */
- if(want_ih_info) {
- /* Check for 'bh_info' callback for this type of object */
- if(obj_class->bh_info) {
- /* Call the object's class 'bh_info' routine */
- if((obj_class->bh_info)(loc, dxpl_id, oh, &oinfo->meta_size.obj) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info")
- } /* end if */
-
- /* Get B-tree & heap info for any attributes */
- if(oinfo->num_attrs > 0) {
- if(H5O_attr_bh_info(loc->file, dxpl_id, oh, &oinfo->meta_size.attr) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info")
- } /* end if */
- } /* end if */
-
-done:
- if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
-} /* end H5O_get_info() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_get_create_plist
- *
- * Purpose: Retrieve the object creation properties for an object
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * November 28 2006
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_get_create_plist(const H5O_loc_t *loc, hid_t dxpl_id, H5P_genplist_t *oc_plist)
-{
- H5O_t *oh = NULL; /* Object header */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(loc);
- HDassert(oc_plist);
-
- /* Get the object header */
- if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
-
- /* Set property values, if they were used for the object */
- if(oh->version > H5O_VERSION_1) {
- uint8_t ohdr_flags; /* "User-visible" object header status flags */
-
- /* Set attribute storage values */
- if(H5P_set(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set max. # of compact attributes in property list")
- if(H5P_set(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list")
-
- /* Mask off non-"user visible" flags */
- ohdr_flags = oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_STORE_TIMES);
-
- /* Set object header flags */
- if(H5P_set(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags")
- } /* end if */
-
-done:
- if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_get_create_plist() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_get_nlinks
- *
- * Purpose: Retrieve the number of link messages read in from the file
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * March 11 2007
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_get_nlinks(const H5O_loc_t *loc, hid_t dxpl_id, hsize_t *nlinks)
-{
- H5O_t *oh = NULL; /* Object header */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(loc);
- HDassert(nlinks);
-
- /* Get the object header */
- if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
-
- /* Retrieve the # of link messages seen when the object header was loaded */
- *nlinks = oh->link_msgs_seen;
-
-done:
- if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_get_nlinks() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_obj_create
- *
- * Purpose: Creates an object, in an abstract manner.
- *
- * Return: Success: Pointer to object opened
- * Failure: NULL
- *
- * Programmer: Quincey Koziol
- * April 9 2007
- *
- *-------------------------------------------------------------------------
- */
-void *
-H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc,
- hid_t dxpl_id)
-{
- size_t u; /* Local index variable */
- void *ret_value = NULL; /* Return value */
-
- FUNC_ENTER_NOAPI(NULL)
-
- /* Sanity checks */
- HDassert(f);
- HDassert(obj_type >= H5O_TYPE_GROUP && obj_type <= H5O_TYPE_NAMED_DATATYPE);
- HDassert(crt_info);
- HDassert(obj_loc);
-
- /* Iterate through the object classes */
- for(u = 0; u < NELMTS(H5O_obj_class_g); u++) {
- /* Check for correct type of object to create */
- if(H5O_obj_class_g[u]->type == obj_type) {
- /* Call the object class's 'create' routine */
- HDassert(H5O_obj_class_g[u]->create);
- if(NULL == (ret_value = H5O_obj_class_g[u]->create(f, crt_info, obj_loc, dxpl_id)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object")
-
- /* Break out of loop */
- break;
- } /* end if */
- } /* end for */
- HDassert(ret_value);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_obj_create() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_get_oh_addr
- *
- * Purpose: Retrieve the address of the object header
- *
- * Note: This routine participates in the "Inlining C struct access"
- * pattern, don't call it directly, use the appropriate macro
- * defined in H5Oprivate.h.
- *
- * Return: Success: Valid haddr_t
- * Failure: HADDR_UNDEF
- *
- * Programmer: Quincey Koziol
- * March 15 2007
- *
- *-------------------------------------------------------------------------
- */
-haddr_t
-H5O_get_oh_addr(const H5O_t *oh)
-{
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- HDassert(oh);
- HDassert(oh->chunk);
-
- FUNC_LEAVE_NOAPI(oh->chunk[0].addr)
-} /* end H5O_get_oh_addr() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_get_rc_and_type
- *
- * Purpose: Retrieve an object's reference count and type
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * November 4 2007
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_get_rc_and_type(const H5O_loc_t *loc, hid_t dxpl_id, unsigned *rc, H5O_type_t *otype)
-{
- H5O_t *oh = NULL; /* Object header */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Check args */
- HDassert(loc);
-
- /* Get the object header */
- if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
-
- /* Set the object's reference count */
- if(rc)
- *rc = oh->nlink;
-
- /* Retrieve the type of the object */
- if(otype)
- if(H5O_obj_type_real(oh, otype) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type")
-
-done:
- if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_get_rc_and_type() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_free_visit_visited
- *
- * Purpose: Free the key for an object visited during a group traversal
- *
- * Return: Non-negative on success, negative on failure
- *
- * Programmer: Quincey Koziol
- * Nov 25, 2007
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data/*in,out*/)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- item = H5FL_FREE(H5_obj_t, item);
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5O_free_visit_visited() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_visit_cb
- *
- * Purpose: Callback function for recursively visiting objects from a group
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * Nov 25, 2007
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *linfo,
- void *_udata)
-{
- H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */
- H5G_loc_t obj_loc; /* Location of object */
- H5G_name_t obj_path; /* Object's group hier. path */
- H5O_loc_t obj_oloc; /* Object's object location */
- hbool_t obj_found = FALSE; /* Object at 'name' found */
- herr_t ret_value = H5_ITER_CONT; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Sanity check */
- HDassert(name);
- HDassert(linfo);
- HDassert(udata);
-
- /* Check if this is a hard link */
- if(linfo->type == H5L_TYPE_HARD) {
- H5_obj_t obj_pos; /* Object "position" for this object */
-
- /* Set up opened group location to fill in */
- obj_loc.oloc = &obj_oloc;
- obj_loc.path = &obj_path;
- H5G_loc_reset(&obj_loc);
-
- /* Find the object using the LAPL passed in */
- /* (Correctly handles mounted files) */
- if(H5G_loc_find(udata->start_loc, name, &obj_loc/*out*/, udata->lapl_id, udata->dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5_ITER_ERROR, "object not found")
- obj_found = TRUE;
-
- /* Construct unique "position" for this object */
- H5F_GET_FILENO(obj_oloc.file, obj_pos.fileno);
- obj_pos.addr = obj_oloc.addr;
-
- /* Check if we've seen the object the link references before */
- if(NULL == H5SL_search(udata->visited, &obj_pos)) {
- H5O_info_t oinfo; /* Object info */
-
- /* Get the object's info */
- if(H5O_get_info(&obj_oloc, udata->dxpl_id, TRUE, &oinfo) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get object info")
-
- /* Make the application callback */
- ret_value = (udata->op)(udata->obj_id, name, &oinfo, udata->op_data);
-
- /* Check for continuing to visit objects */
- if(ret_value == H5_ITER_CONT) {
- /* If its ref count is > 1, we add it to the list of visited objects */
- /* (because it could come up again during traversal) */
- if(oinfo.rc > 1) {
- H5_obj_t *new_node; /* New object node for visited list */
-
- /* Allocate new object "position" node */
- if((new_node = H5FL_MALLOC(H5_obj_t)) == NULL)
- HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate object node")
-
- /* Set node information */
- *new_node = obj_pos;
-
- /* Add to list of visited objects */
- if(H5SL_insert(udata->visited, new_node, new_node) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert object node into visited list")
- } /* end if */
- } /* end if */
- } /* end if */
- } /* end if */
-
-done:
- /* Release resources */
- if(obj_found && H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_visit_cb() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_visit
- *
- * Purpose: Recursively visit an object and all the objects reachable
- * from it. If the starting object is a group, all the objects
- * linked to from that group will be visited. Links within
- * each group are visited according to the order within the
- * specified index (unless the specified index does not exist for
- * a particular group, then the "name" index is used).
- *
- * NOTE: Soft links and user-defined links are ignored during
- * this operation.
- *
- * NOTE: Each _object_ reachable from the initial group will only
- * be visited once. If multiple hard links point to the same
- * object, the first link to the object's path (according to the
- * iteration index and iteration order given) will be used to in
- * the callback about the object.
- *
- * Return: Success: The return value of the first operator that
- * returns non-zero, or zero if all members were
- * processed with no operator returning non-zero.
- *
- * Failure: Negative if something goes wrong within the
- * library, or the negative value returned by one
- * of the operators.
- *
- * Programmer: Quincey Koziol
- * November 24 2007
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
- H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id,
- hid_t dxpl_id)
-{
- H5O_iter_visit_ud_t udata; /* User data for callback */
- H5G_loc_t loc; /* Location of reference object */
- H5G_loc_t obj_loc; /* Location used to open object */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
- hbool_t loc_found = FALSE; /* Entry at 'name' found */
- H5O_info_t oinfo; /* Object info struct */
- hid_t obj_id = (-1); /* ID of object */
- herr_t ret_value = FAIL; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Portably initialize user data struct to zeros */
- HDmemset(&udata, 0, sizeof(udata));
-
- /* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
-
- /* Set up opened group location to fill in */
- obj_loc.oloc = &obj_oloc;
- obj_loc.path = &obj_path;
- H5G_loc_reset(&obj_loc);
-
- /* Find the object's location */
- if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
- loc_found = TRUE;
-
- /* Get the object's info */
- if(H5O_get_info(&obj_oloc, dxpl_id, TRUE, &oinfo) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info")
-
- /* Open the object */
- /* (Takes ownership of the obj_loc information) */
- if((obj_id = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
-
- /* Make callback for starting object */
- if((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "can't visit objects")
-
- /* Check return value of first callback */
- if(ret_value != H5_ITER_CONT)
- HGOTO_DONE(ret_value);
-
- /* Check for object being a group */
- if(oinfo.type == H5O_TYPE_GROUP) {
- H5G_loc_t start_loc; /* Location of starting group */
-
- /* Get the location of the starting group */
- if(H5G_loc(obj_id, &start_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
-
- /* Set up user data for visiting links */
- udata.obj_id = obj_id;
- udata.start_loc = &start_loc;
- udata.lapl_id = lapl_id;
- udata.dxpl_id = dxpl_id;
- udata.op = op;
- udata.op_data = op_data;
-
- /* Create skip list to store visited object information */
- if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create skip list for visited objects")
-
- /* If its ref count is > 1, we add it to the list of visited objects */
- /* (because it could come up again during traversal) */
- if(oinfo.rc > 1) {
- H5_obj_t *obj_pos; /* New object node for visited list */
-
- /* Allocate new object "position" node */
- if((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL)
- HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "can't allocate object node")
-
- /* Construct unique "position" for this object */
- obj_pos->fileno = oinfo.fileno;
- obj_pos->addr = oinfo.addr;
-
- /* Add to list of visited objects */
- if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object node into visited list")
- } /* end if */
-
- /* Call internal group visitation routine */
- if((ret_value = H5G_visit(obj_id, ".", idx_type, order, H5O_visit_cb, &udata, lapl_id, dxpl_id)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed")
- } /* end if */
-
-done:
- if(obj_id > 0) {
- if(H5I_dec_app_ref(obj_id) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
- } /* end if */
- else if(loc_found && H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location")
- if(udata.visited)
- H5SL_destroy(udata.visited, H5O_free_visit_visited, NULL);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_visit() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_inc_rc
- *
- * Purpose: Increments the reference count on an object header
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Jul 13 2008
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_inc_rc(H5O_t *oh)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check args */
- HDassert(oh);
-
- /* Pin the object header when the reference count goes above 0 */
- if(oh->rc == 0)
- if(H5AC_pin_protected_entry(oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header")
-
- /* Increment reference count */
- oh->rc++;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_inc_rc() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_dec_rc
- *
- * Purpose: Decrements the reference count on an object header
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Jul 13 2008
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_dec_rc(H5O_t *oh)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check args */
- HDassert(oh);
-
- /* Decrement reference count */
- oh->rc--;
-
- /* Unpin the object header when the reference count goes back to 0 */
- if(oh->rc == 0)
- if(H5AC_unpin_entry(oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_dec_rc() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_dec_rc_by_loc
- *
- * Purpose: Decrement the refcount of an object header, using its
- * object location information.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@hdfgroup.org
- * Oct 08 2010
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O_dec_rc_by_loc(const H5O_loc_t *loc, hid_t dxpl_id)
-{
- H5O_t *oh = NULL; /* Object header */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* check args */
- HDassert(loc);
-
- /* Get header */
- if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
- HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header")
-
- /* Decrement the reference count on the object header */
- /* (which will unpin it, if appropriate) */
- if(H5O_dec_rc(oh) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header")
-
-done:
- /* Release the object header from the cache */
- if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
- HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O_dec_rc_by_loc() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O_get_proxy
- *
- * Purpose: Retrieve the proxy for the object header.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * July 24 2016
- *
- *-------------------------------------------------------------------------
- */
-H5AC_proxy_entry_t *
-H5O_get_proxy(const H5O_t *oh)
-{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Check args */
- HDassert(oh);
-
- FUNC_LEAVE_NOAPI(oh->proxy)
-} /* end H5O_get_proxy() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5O__free
- *
- * Purpose: Destroys an object header.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * koziol@ncsa.uiuc.edu
- * Jan 15 2003
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O__free(H5O_t *oh)
-{
- unsigned u; /* Local index variable */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_PACKAGE
-
- /* check args */
- HDassert(oh);
- HDassert(0 == oh->rc);
-
- /* Destroy chunks */
- if(oh->chunk) {
- for(u = 0; u < oh->nchunks; u++)
- oh->chunk[u].image = H5FL_BLK_FREE(chunk_image, oh->chunk[u].image);
-
- oh->chunk = (H5O_chunk_t *)H5FL_SEQ_FREE(H5O_chunk_t, oh->chunk);
- } /* end if */
-
- /* Destroy messages */
- if(oh->mesg) {
- for(u = 0; u < oh->nmesgs; u++) {
-#ifndef NDEBUG
- /* Verify that message is clean, unless it could have been marked
- * dirty by decoding */
- if(oh->ndecode_dirtied && oh->mesg[u].dirty)
- oh->ndecode_dirtied--;
- else
- HDassert(oh->mesg[u].dirty == 0);
-#endif /* NDEBUG */
-
- H5O_msg_free_mesg(&oh->mesg[u]);
- } /* end for */
-
- /* Make sure we accounted for all the messages dirtied by decoding */
- HDassert(!oh->ndecode_dirtied);
-
- oh->mesg = (H5O_mesg_t *)H5FL_SEQ_FREE(H5O_mesg_t, oh->mesg);
- } /* end if */
-
- /* Destroy the proxy */
- if(oh->proxy)
- if(H5AC_proxy_entry_dest(oh->proxy) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy virtual entry used for proxy")
-
- /* destroy object header */
- oh = H5FL_FREE(H5O_t, oh);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O__free() */
-
diff --git a/src/H5Oint.c b/src/H5Oint.c
new file mode 100644
index 0000000..6ab5393
--- /dev/null
+++ b/src/H5Oint.c
@@ -0,0 +1,2713 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*-------------------------------------------------------------------------
+ *
+ * Created: H5O.c
+ *
+ * Purpose: Internal object header routines
+ *
+ *-------------------------------------------------------------------------
+ */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#include "H5Omodule.h" /* This source code file is part of the H5O module */
+
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5FLprivate.h" /* Free lists */
+#include "H5FOprivate.h" /* File objects */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Lprivate.h" /* Links */
+#include "H5MFprivate.h" /* File memory management */
+#ifdef H5O_ENABLE_BOGUS
+#include "H5MMprivate.h" /* Memory management */
+#endif /* H5O_ENABLE_BOGUS */
+#include "H5Opkg.h" /* Object headers */
+#include "H5SMprivate.h" /* Shared object header messages */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+/* User data for recursive traversal over objects from a group */
+typedef struct {
+ hid_t obj_id; /* The ID for the starting group */
+ H5G_loc_t *start_loc; /* Location of starting group */
+ hid_t lapl_id; /* LAPL for walking across links */
+ hid_t dxpl_id; /* DXPL for operations */
+ H5SL_t *visited; /* Skip list for tracking visited nodes */
+ H5O_iterate_t op; /* Application callback */
+ void *op_data; /* Application's op data */
+} H5O_iter_visit_ud_t;
+
+
+/********************/
+/* Package Typedefs */
+/********************/
+
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh);
+static herr_t H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type);
+static herr_t H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr);
+static const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh);
+
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+/* Package initialization variable */
+hbool_t H5_PKG_INIT_VAR = FALSE;
+
+/* Header message ID to class mapping
+ *
+ * Remember to increment H5O_MSG_TYPES in H5Opkg.h when adding a new
+ * message.
+ */
+const H5O_msg_class_t *const H5O_msg_class_g[] = {
+ H5O_MSG_NULL, /*0x0000 Null */
+ H5O_MSG_SDSPACE, /*0x0001 Dataspace */
+ H5O_MSG_LINFO, /*0x0002 Link information */
+ H5O_MSG_DTYPE, /*0x0003 Datatype */
+ H5O_MSG_FILL, /*0x0004 Old data storage -- fill value */
+ H5O_MSG_FILL_NEW, /*0x0005 New data storage -- fill value */
+ H5O_MSG_LINK, /*0x0006 Link */
+ H5O_MSG_EFL, /*0x0007 Data storage -- external data files */
+ H5O_MSG_LAYOUT, /*0x0008 Data Layout */
+#ifdef H5O_ENABLE_BOGUS
+ H5O_MSG_BOGUS_VALID, /*0x0009 "Bogus valid" (for testing) */
+#else /* H5O_ENABLE_BOGUS */
+ NULL, /*0x0009 "Bogus valid" (for testing) */
+#endif /* H5O_ENABLE_BOGUS */
+ H5O_MSG_GINFO, /*0x000A Group information */
+ H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */
+ H5O_MSG_ATTR, /*0x000C Attribute */
+ H5O_MSG_NAME, /*0x000D Object name */
+ H5O_MSG_MTIME, /*0x000E Object modification date and time */
+ H5O_MSG_SHMESG, /*0x000F File-wide shared message table */
+ H5O_MSG_CONT, /*0x0010 Object header continuation */
+ H5O_MSG_STAB, /*0x0011 Symbol table */
+ H5O_MSG_MTIME_NEW, /*0x0012 New Object modification date and time */
+ H5O_MSG_BTREEK, /*0x0013 Non-default v1 B-tree 'K' values */
+ H5O_MSG_DRVINFO, /*0x0014 Driver info settings */
+ H5O_MSG_AINFO, /*0x0015 Attribute information */
+ H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */
+ H5O_MSG_FSINFO, /*0x0017 Free-space manager info */
+ H5O_MSG_MDCI, /*0x0018 Metadata cache image */
+ H5O_MSG_UNKNOWN, /*0x0019 Placeholder for unknown message */
+#ifdef H5O_ENABLE_BOGUS
+ H5O_MSG_BOGUS_INVALID, /*0x001A "Bogus invalid" (for testing) */
+#else /* H5O_ENABLE_BOGUS */
+ NULL, /*0x001A "Bogus invalid" (for testing) */
+#endif /* H5O_ENABLE_BOGUS */
+};
+
+/* Declare a free list to manage the H5O_t struct */
+H5FL_DEFINE(H5O_t);
+
+/* Declare a free list to manage the H5O_mesg_t sequence information */
+H5FL_SEQ_DEFINE(H5O_mesg_t);
+
+/* Declare a free list to manage the H5O_chunk_t sequence information */
+H5FL_SEQ_DEFINE(H5O_chunk_t);
+
+/* Declare a free list to manage the chunk image information */
+H5FL_BLK_DEFINE(chunk_image);
+
+/* Declare external the free list for H5O_cont_t sequences */
+H5FL_SEQ_EXTERN(H5O_cont_t);
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+/* Declare external the free list for time_t's */
+H5FL_EXTERN(time_t);
+
+/* Declare external the free list for H5_obj_t's */
+H5FL_EXTERN(H5_obj_t);
+
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+/* Header object ID to class mapping */
+/*
+ * Initialize the object class info table. Begin with the most general types
+ * and end with the most specific. For instance, any object that has a
+ * datatype message is a datatype but only some of them are datasets.
+ */
+static const H5O_obj_class_t *const H5O_obj_class_g[] = {
+ H5O_OBJ_DATATYPE, /* Datatype object (H5O_TYPE_NAMED_DATATYPE - 2) */
+ H5O_OBJ_DATASET, /* Dataset object (H5O_TYPE_DATASET - 1) */
+ H5O_OBJ_GROUP, /* Group object (H5O_TYPE_GROUP - 0) */
+};
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O__init_package
+ *
+ * Purpose: Initialize information specific to H5O interface.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, January 18, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O__init_package(void)
+{
+ FUNC_ENTER_PACKAGE_NOERR
+
+ /* H5O interface sanity checks */
+ HDcompile_assert(H5O_MSG_TYPES == NELMTS(H5O_msg_class_g));
+ HDcompile_assert(sizeof(H5O_fheap_id_t) == H5O_FHEAP_ID_LEN);
+
+ HDcompile_assert(H5O_UNKNOWN_ID < H5O_MSG_TYPES);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O__init_package() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_create
+ *
+ * Purpose: Creates a new object header. Allocates space for it and
+ * then calls an initialization function. The object header
+ * is opened for write access and should eventually be
+ * closed by calling H5O_close().
+ *
+ * Return: Success: Non-negative, the ENT argument contains
+ * information about the object header,
+ * including its address.
+ *
+ * Failure: Negative
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 5 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc,
+ hid_t ocpl_id, H5O_loc_t *loc/*out*/)
+{
+ H5P_genplist_t *oc_plist; /* Object creation property list */
+ H5O_t *oh = NULL; /* Object header created */
+ haddr_t oh_addr; /* Address of initial object header */
+ size_t oh_size; /* Size of initial object header */
+ uint8_t oh_flags; /* Object header's initial status flags */
+ unsigned insert_flags = H5AC__NO_FLAGS_SET; /* Flags for inserting object header into cache */
+ hbool_t store_msg_crt_idx; /* Whether to always store message creation indices for this file */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* check args */
+ HDassert(f);
+ HDassert(loc);
+ HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE));
+
+ /* Check for invalid access request */
+ if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR))
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "no write intent on file")
+
+ /* Make certain we allocate at least a reasonable size for the object header */
+ size_hint = H5O_ALIGN_F(f, MAX(H5O_MIN_SIZE, size_hint));
+
+ /* Get the property list */
+ if(NULL == (oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id)))
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list")
+
+ /* Get any object header status flags set by properties */
+ if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags")
+
+ /* Allocate the object header and zero out header fields */
+ if(NULL == (oh = H5FL_CALLOC(H5O_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /* Initialize file-specific information for object header */
+ store_msg_crt_idx = H5F_STORE_MSG_CRT_IDX(f);
+ if(H5F_USE_LATEST_FLAGS(f, H5F_LATEST_OBJ_HEADER) || store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED))
+ oh->version = H5O_VERSION_LATEST;
+ else
+ oh->version = H5O_VERSION_1;
+ oh->sizeof_size = H5F_SIZEOF_SIZE(f);
+ oh->sizeof_addr = H5F_SIZEOF_ADDR(f);
+ oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE);
+#ifdef H5O_ENABLE_BAD_MESG_COUNT
+ /* Check whether the "bad message count" property is set */
+ if(H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME) > 0) {
+ /* Retrieve bad message count flag */
+ if(H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get bad message count flag")
+ }
+#endif /* H5O_ENABLE_BAD_MESG_COUNT */
+
+ /* Create object header proxy if doing SWMR writes */
+ if(oh->swmr_write) {
+ /* Create virtual entry, for use as proxy */
+ if(NULL == (oh->proxy = H5AC_proxy_entry_create()))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy")
+ }
+ else
+ oh->proxy = NULL;
+
+ /* Set initial status flags */
+ oh->flags = oh_flags;
+
+ /* Initialize version-specific fields */
+ if(oh->version > H5O_VERSION_1) {
+ /* Initialize all time fields with current time, if we are storing them */
+ if(oh->flags & H5O_HDR_STORE_TIMES)
+ oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now();
+ else
+ oh->atime = oh->mtime = oh->ctime = oh->btime = 0;
+
+ /* Make certain attribute creation order tracking is enabled if
+ * attributes can be shared in this file.
+ */
+ if(store_msg_crt_idx)
+ oh->flags |= H5O_HDR_ATTR_CRT_ORDER_TRACKED;
+
+ /* Retrieve attribute storage phase change values from property list */
+ if(H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes")
+ if(H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes")
+
+ /* Check for non-default attribute storage phase change values */
+ if(oh->max_compact != H5O_CRT_ATTR_MAX_COMPACT_DEF || oh->min_dense != H5O_CRT_ATTR_MIN_DENSE_DEF)
+ oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE;
+
+ /* Determine correct value for chunk #0 size bits */
+/* Avoid compiler warning on 32-bit machines */
+#if H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T
+ if(size_hint > 4294967295UL)
+ oh->flags |= H5O_HDR_CHUNK0_8;
+ else
+#endif /* H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T */
+ if(size_hint > 65535)
+ oh->flags |= H5O_HDR_CHUNK0_4;
+ else if(size_hint > 255)
+ oh->flags |= H5O_HDR_CHUNK0_2;
+ } /* end if */
+ else {
+ /* Reset unused time fields */
+ oh->atime = oh->mtime = oh->ctime = oh->btime = 0;
+ } /* end else */
+
+ /* Compute total size of initial object header */
+ /* (i.e. object header prefix and first chunk) */
+ oh_size = (size_t)H5O_SIZEOF_HDR(oh) + size_hint;
+
+ /* Allocate disk space for header and first chunk */
+ if(HADDR_UNDEF == (oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)oh_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header")
+
+ /* Create the chunk list */
+ oh->nchunks = oh->alloc_nchunks = 1;
+ if(NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /* Initialize the first chunk */
+ oh->chunk[0].addr = oh_addr;
+ oh->chunk[0].size = oh_size;
+ oh->chunk[0].gap = 0;
+
+ /* Allocate enough space for the first chunk */
+ /* (including space for serializing the object header prefix */
+ if(NULL == (oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ oh->chunk[0].chunk_proxy = NULL;
+
+ /* Put magic # for object header in first chunk */
+ if(oh->version > H5O_VERSION_1)
+ HDmemcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC);
+
+ /* Create the message list */
+ oh->nmesgs = 1;
+ oh->alloc_nmesgs = H5O_NMESGS;
+ if(NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /* Initialize the initial "null" message, covering the entire first chunk */
+ oh->mesg[0].type = H5O_MSG_NULL;
+ oh->mesg[0].dirty = TRUE;
+ oh->mesg[0].native = NULL;
+ oh->mesg[0].raw = oh->chunk[0].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)) + H5O_SIZEOF_MSGHDR_OH(oh);
+ oh->mesg[0].raw_size = size_hint - (size_t)H5O_SIZEOF_MSGHDR_OH(oh);
+ oh->mesg[0].chunkno = 0;
+
+ /* Check for non-zero initial refcount on the object header */
+ if(initial_rc > 0) {
+ /* Set the initial refcount & pin the header when its inserted */
+ oh->rc = initial_rc;
+ insert_flags |= H5AC__PIN_ENTRY_FLAG;
+ }
+
+ /* Set metadata tag in dxpl_id */
+ H5_BEGIN_TAG(dxpl_id, oh_addr, FAIL);
+
+ /* Cache object header */
+ if(H5AC_insert_entry(f, dxpl_id, H5AC_OHDR, oh_addr, oh, insert_flags) < 0)
+ HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header")
+
+ /* Reset object header pointer, now that it's been inserted into the cache */
+ oh = NULL;
+
+ /* Reset metadata tag in dxpl_id */
+ H5_END_TAG(FAIL);
+
+ /* Set up object location */
+ loc->file = f;
+ loc->addr = oh_addr;
+
+ /* Open it */
+ if(H5O_open(loc) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header")
+
+done:
+ if(ret_value < 0 && oh)
+ if(H5O__free(oh) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_create() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_open
+ *
+ * Purpose: Opens an object header which is described by the symbol table
+ * entry OBJ_ENT.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * Monday, January 5, 1998
+ *
+ * Modification:
+ * Raymond Lu
+ * 5 November 2007
+ * Turn off the holding file variable if it's on. When it's
+ * needed, the caller will turn it on again.
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_open(H5O_loc_t *loc)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Check args */
+ HDassert(loc);
+ HDassert(loc->file);
+
+#ifdef H5O_DEBUG
+ if(H5DEBUG(O))
+ HDfprintf(H5DEBUG(O), "> %a\n", loc->addr);
+#endif
+
+ /* Turn off the variable for holding file or increment open-lock counters */
+ if(loc->holding_file)
+ loc->holding_file = FALSE;
+ else
+ H5F_INCR_NOPEN_OBJS(loc->file);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_open() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_open_name
+ *
+ * Purpose: Opens an object within an HDF5 file.
+ *
+ * Return: Success: An open object identifier
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * March 5 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref)
+{
+ H5G_loc_t obj_loc; /* Location used to open group */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
+ hbool_t loc_found = FALSE; /* Entry at 'name' found */
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Check args */
+ HDassert(loc);
+ HDassert(name && *name);
+
+ /* Set up opened group location to fill in */
+ obj_loc.oloc = &obj_oloc;
+ obj_loc.path = &obj_path;
+ H5G_loc_reset(&obj_loc);
+
+ /* Find the object's location */
+ if(H5G_loc_find(loc, name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
+ loc_found = TRUE;
+
+ /* Open the object */
+ if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, app_ref)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
+
+done:
+ if(ret_value < 0 && loc_found)
+ if(H5G_loc_free(&obj_loc) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_open_name() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_open_by_loc
+ *
+ * Purpose: Opens an object and returns an ID given its group loction.
+ *
+ * Return: Success: Open object identifier
+ * Failure: Negative
+ *
+ * Programmer: James Laird
+ * July 25 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref)
+{
+ const H5O_obj_class_t *obj_class; /* Class of object for location */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ HDassert(obj_loc);
+
+ /* Get the object class for this location */
+ if(NULL == (obj_class = H5O_obj_class(obj_loc->oloc, dxpl_id)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class")
+
+ /* Call the object class's 'open' routine */
+ HDassert(obj_class->open);
+ if((ret_value = obj_class->open(obj_loc, lapl_id, dxpl_id, app_ref)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_open_by_loc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_close
+ *
+ * Purpose: Closes an object header that was previously open.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * Monday, January 5, 1998
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Check args */
+ HDassert(loc);
+ HDassert(loc->file);
+ HDassert(H5F_NOPEN_OBJS(loc->file) > 0);
+
+ /* Set the file_closed flag to the default value.
+ * This flag lets downstream code know if the file struct is
+ * still accessible and/or likely to contain useful data.
+ * It's needed by the evict-on-close code. Clients can ignore
+ * this value by passing in NULL.
+ */
+ if(file_closed)
+ *file_closed = FALSE;
+
+ /* Decrement open-lock counters */
+ H5F_DECR_NOPEN_OBJS(loc->file);
+
+#ifdef H5O_DEBUG
+ if(H5DEBUG(O)) {
+ if(H5F_FILE_ID(loc->file)< 0 && 1 == H5F_NREFS(loc->file))
+ HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n",
+ loc->addr, (unsigned long)H5F_NOPEN_OBJS(loc->file));
+ else
+ HDfprintf(H5DEBUG(O), "< %a\n", loc->addr);
+ }
+#endif
+
+ /*
+ * If the file open object count has reached the number of open mount points
+ * (each of which has a group open in the file) attempt to close the file.
+ */
+ if(H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file))
+ /* Attempt to close down the file hierarchy */
+ if(H5F_try_close(loc->file, file_closed) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close")
+
+ /* Release location information */
+ if(H5O_loc_free(loc) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "problem attempting to free location")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_close() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_link_oh
+ *
+ * Purpose: Adjust the link count for an open object header by adding
+ * ADJUST to the link count.
+ *
+ * Return: Success: New link count
+ *
+ * Failure: Negative
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 5 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t *deleted)
+{
+ haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */
+ int ret_value = -1; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* check args */
+ HDassert(f);
+ HDassert(oh);
+ HDassert(deleted);
+
+ /* Check for adjusting link count */
+ if(adjust) {
+ if(adjust < 0) {
+ /* Check for too large of an adjustment */
+ if((unsigned)(-adjust) > oh->nlink)
+ HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative")
+
+ /* Adjust the link count for the object header */
+ oh->nlink = (unsigned)((int)oh->nlink + adjust);
+
+ /* Mark object header as dirty in cache */
+ if(H5AC_mark_entry_dirty(oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty")
+
+ /* Check if the object should be deleted */
+ if(oh->nlink == 0) {
+ /* Check if the object is still open by the user */
+ if(H5FO_opened(f, addr) != NULL) {
+ /* Flag the object to be deleted when it's closed */
+ if(H5FO_mark(f, addr, TRUE) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion")
+ } /* end if */
+ else {
+ /* Mark the object header for deletion */
+ *deleted = TRUE;
+ } /* end else */
+ } /* end if */
+ } /* end if */
+ else {
+ /* A new object, or one that will be deleted */
+ if(0 == oh->nlink) {
+ /* Check if the object is currently open, but marked for deletion */
+ if(H5FO_marked(f, addr)) {
+ /* Remove "delete me" flag on the object */
+ if(H5FO_mark(f, addr, FALSE) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion")
+ } /* end if */
+ } /* end if */
+
+ /* Adjust the link count for the object header */
+ oh->nlink = (unsigned)((int)oh->nlink + adjust);
+
+ /* Mark object header as dirty in cache */
+ if(H5AC_mark_entry_dirty(oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty")
+ } /* end if */
+
+ /* Check for operations on refcount message */
+ if(oh->version > H5O_VERSION_1) {
+ /* Check if the object has a refcount message already */
+ if(oh->has_refcount_msg) {
+ /* Check for removing refcount message */
+ if(oh->nlink <= 1) {
+ if(H5O_msg_remove_real(f, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete refcount message")
+ oh->has_refcount_msg = FALSE;
+ } /* end if */
+ /* Update refcount message with new link count */
+ else {
+ H5O_refcount_t refcount = oh->nlink;
+
+ if(H5O_msg_write_real(f, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update refcount message")
+ } /* end else */
+ } /* end if */
+ else {
+ /* Check for adding refcount message to object */
+ if(oh->nlink > 1) {
+ H5O_refcount_t refcount = oh->nlink;
+
+ if(H5O_msg_append_real(f, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to create new refcount message")
+ oh->has_refcount_msg = TRUE;
+ } /* end if */
+ } /* end else */
+ } /* end if */
+ } /* end if */
+
+ /* Set return value */
+ ret_value = (int)oh->nlink;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_link_oh() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_link
+ *
+ * Purpose: Adjust the link count for an object header by adding
+ * ADJUST to the link count.
+ *
+ * Return: Success: New link count
+ *
+ * Failure: Negative
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 5 1997
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id)
+{
+ H5O_t *oh = NULL;
+ hbool_t deleted = FALSE; /* Whether the object was deleted */
+ int ret_value = -1; /* Return value */
+
+ FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL)
+
+ /* check args */
+ HDassert(loc);
+ HDassert(loc->file);
+ HDassert(H5F_addr_defined(loc->addr));
+
+ /* Pin the object header */
+ if(NULL == (oh = H5O_pin(loc, dxpl_id)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header")
+
+ /* Call the "real" link routine */
+ if((ret_value = H5O_link_oh(loc->file, adjust, dxpl_id, oh, &deleted)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust object link count")
+
+done:
+ if(oh && H5O_unpin(oh) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header")
+ if(ret_value >= 0 && deleted && H5O_delete(loc->file, dxpl_id, loc->addr) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file")
+
+ FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+} /* end H5O_link() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_protect
+ *
+ * Purpose: Wrapper around H5AC_protect for use during a H5O_protect->
+ * H5O_msg_append->...->H5O_msg_append->H5O_unprotect sequence of calls
+ * during an object's creation.
+ *
+ * Return: Success: Pointer to the object header structure for the
+ * object.
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Dec 31 2002
+ *
+ *-------------------------------------------------------------------------
+ */
+H5O_t *
+H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, unsigned prot_flags,
+ hbool_t pin_all_chunks)
+{
+ H5O_t *oh = NULL; /* Object header protected */
+ H5O_cache_ud_t udata; /* User data for protecting object header */
+ H5O_cont_msgs_t cont_msg_info; /* Continuation message info */
+ unsigned file_intent; /* R/W intent on file */
+ H5O_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, NULL)
+
+ /* check args */
+ HDassert(loc);
+ HDassert(loc->file);
+
+ /* prot_flags may only contain the H5AC__READ_ONLY_FLAG */
+ HDassert((prot_flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0);
+
+ /* Check for valid address */
+ if(!H5F_addr_defined(loc->addr))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "address undefined")
+
+ /* Check for write access on the file */
+ file_intent = H5F_INTENT(loc->file);
+ if((0 == (prot_flags & H5AC__READ_ONLY_FLAG)) && (0 == (file_intent & H5F_ACC_RDWR)))
+ HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "no write intent on file")
+
+ /* Construct the user data for protect callback */
+ udata.made_attempt = FALSE;
+ udata.v1_pfx_nmesgs = 0;
+ udata.chunk0_size = 0;
+ udata.oh = NULL;
+ udata.common.f = loc->file;
+ udata.common.dxpl_id = dxpl_id;
+ udata.common.file_intent = file_intent;
+ udata.common.merged_null_msgs = 0;
+ HDmemset(&cont_msg_info, 0, sizeof(cont_msg_info));
+ udata.common.cont_msg_info = &cont_msg_info;
+ udata.common.addr = loc->addr;
+
+ /* Lock the object header into the cache */
+ if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, &udata, prot_flags)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header")
+
+ /* Check if there are any continuation messages to process */
+ if(cont_msg_info.nmsgs > 0) {
+ size_t curr_msg; /* Current continuation message to process */
+ H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */
+
+ /* Sanity check - we should only have continuation messages to process
+ * when the object header is actually loaded from the file.
+ */
+ HDassert(udata.made_attempt == TRUE);
+ HDassert(cont_msg_info.msgs);
+
+ /* Construct the user data for protecting chunks */
+ chk_udata.decoding = TRUE;
+ chk_udata.oh = oh;
+ chk_udata.chunkno = UINT_MAX; /* Set to invalid value, for better error detection */
+ chk_udata.common.f = loc->file;
+ chk_udata.common.dxpl_id = dxpl_id;
+ chk_udata.common.file_intent = file_intent;
+ chk_udata.common.merged_null_msgs = udata.common.merged_null_msgs;
+ chk_udata.common.cont_msg_info = &cont_msg_info;
+
+ /* Read in continuation messages, until there are no more */
+ /* (Note that loading chunks could increase the # of continuation
+ * messages if new ones are found - QAK, 19/11/2016)
+ */
+ curr_msg = 0;
+ while(curr_msg < cont_msg_info.nmsgs) {
+ H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to bring it into memory */
+#ifndef NDEBUG
+ size_t chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */
+#endif /* NDEBUG */
+
+ /* Bring the chunk into the cache */
+ /* (which adds to the object header) */
+ chk_udata.common.addr = cont_msg_info.msgs[curr_msg].addr;
+ chk_udata.size = cont_msg_info.msgs[curr_msg].size;
+ if(NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, &chk_udata, prot_flags)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header chunk")
+
+ /* Sanity check */
+ HDassert(chk_proxy->oh == oh);
+ HDassert(chk_proxy->chunkno == chkcnt);
+ HDassert(oh->nchunks == (chkcnt + 1));
+
+ /* Release the chunk from the cache */
+ if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header chunk")
+
+ /* Advance to next continuation message */
+ curr_msg++;
+ } /* end while */
+
+ /* Release any continuation messages built up */
+ cont_msg_info.msgs = (H5O_cont_t *)H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs);
+
+ /* Pass back out some of the chunk's user data */
+ udata.common.merged_null_msgs = chk_udata.common.merged_null_msgs;
+ } /* end if */
+
+ /* Check for incorrect # of object header messages, if we've just loaded
+ * this object header from the file
+ */
+ if(udata.made_attempt) {
+/* Don't enforce the error on an incorrect # of object header messages bug
+ * unless strict format checking is enabled. This allows for older
+ * files, created with a version of the library that had a bug in tracking
+ * the correct # of header messages to be read in without the library
+ * erroring out here. -QAK
+ */
+#ifdef H5_STRICT_FORMAT_CHECKS
+ /* Check for incorrect # of messages in v1 object header */
+ if(oh->version == H5O_VERSION_1 &&
+ (oh->nmesgs + udata.common.merged_null_msgs) != udata.v1_pfx_nmesgs)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - incorrect # of messages")
+#endif /* H5_STRICT_FORMAT_CHECKS */
+ } /* end if */
+
+#ifdef H5O_DEBUG
+H5O_assert(oh);
+#endif /* H5O_DEBUG */
+
+ /* Pin the other chunks also when requested, so that the object header
+ * proxy can be set up.
+ */
+ if(pin_all_chunks && oh->nchunks > 1) {
+ unsigned u; /* Local index variable */
+
+ /* Sanity check */
+ HDassert(oh->swmr_write);
+
+ /* Iterate over chunks > 0 */
+ for(u = 1; u < oh->nchunks; u++) {
+ H5O_chunk_proxy_t *chk_proxy; /* Chunk proxy */
+
+ /* Protect chunk */
+ if(NULL == (chk_proxy = H5O_chunk_protect(loc->file, dxpl_id, oh, u)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header chunk")
+
+ /* Pin chunk proxy*/
+ if(H5AC_pin_protected_entry(chk_proxy) < 0 )
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, NULL, "unable to pin object header chunk")
+
+ /* Unprotect chunk */
+ if(H5O_chunk_unprotect(loc->file, dxpl_id, chk_proxy, FALSE) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect object header chunk")
+
+ /* Preserve chunk proxy pointer for later */
+ oh->chunk[u].chunk_proxy = chk_proxy;
+ } /* end for */
+
+ /* Set the flag for the unprotect */
+ oh->chunks_pinned = TRUE;
+ } /* end if */
+
+ /* Set return value */
+ ret_value = oh;
+
+done:
+ if(ret_value == NULL && oh)
+ if(H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI_TAG(ret_value, NULL)
+} /* end H5O_protect() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_pin
+ *
+ * Purpose: Pin an object header down for use during a sequence of message
+ * operations, which prevents the object header from being
+ * evicted from the cache.
+ *
+ * Return: Success: Pointer to the object header structure for the
+ * object.
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Jul 13 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+H5O_t *
+H5O_pin(const H5O_loc_t *loc, hid_t dxpl_id)
+{
+ H5O_t *oh = NULL; /* Object header */
+ H5O_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI(NULL)
+
+ /* check args */
+ HDassert(loc);
+
+ /* Get header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header")
+
+ /* Increment the reference count on the object header */
+ /* (which will pin it, if appropriate) */
+ if(H5O_inc_rc(oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "unable to increment reference count on object header")
+
+ /* Set the return value */
+ ret_value = oh;
+
+done:
+ /* Release the object header from the cache */
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_pin() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_unpin
+ *
+ * Purpose: Unpin an object header, allowing it to be evicted from the
+ * metadata cache.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Jul 13 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_unpin(H5O_t *oh)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* check args */
+ HDassert(oh);
+
+ /* Decrement the reference count on the object header */
+ /* (which will unpin it, if appropriate) */
+ if(H5O_dec_rc(oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_unpin() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_unprotect
+ *
+ * Purpose: Wrapper around H5AC_unprotect for use during a H5O_protect->
+ * H5O_msg_append->...->H5O_msg_append->H5O_unprotect sequence of calls
+ * during an object's creation.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Dec 31 2002
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_unprotect(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, unsigned oh_flags)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* check args */
+ HDassert(loc);
+ HDassert(oh);
+
+ /* Unpin the other chunks */
+ if(oh->chunks_pinned && oh->nchunks > 1) {
+ unsigned u; /* Local index variable */
+
+ /* Sanity check */
+ HDassert(oh->swmr_write);
+
+ /* Iterate over chunks > 0 */
+ for(u = 1; u < oh->nchunks; u++) {
+ if(NULL != oh->chunk[u].chunk_proxy) {
+ /* Release chunk proxy */
+ if(H5AC_unpin_entry(oh->chunk[u].chunk_proxy) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header chunk")
+ oh->chunk[u].chunk_proxy = NULL;
+ } /* end if */
+ } /* end for */
+
+ /* Reet the flag from the unprotect */
+ oh->chunks_pinned = FALSE;
+ } /* end if */
+
+ /* Unprotect the object header */
+ if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, oh->chunk[0].addr, oh, oh_flags) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_unprotect() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_touch_oh
+ *
+ * Purpose: If FORCE is non-zero then create a modification time message
+ * unless one already exists. Then update any existing
+ * modification time message with the current time.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * Monday, July 27, 1998
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force)
+{
+ H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */
+ hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */
+ time_t now; /* Current time */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(f);
+ HDassert(oh);
+
+ /* Check if this object header is tracking times */
+ if(oh->flags & H5O_HDR_STORE_TIMES) {
+ /* Get current time */
+ now = H5_now();
+
+ /* Check version, to determine how to store time information */
+ if(oh->version == H5O_VERSION_1) {
+ size_t idx; /* Index of modification time message to update */
+
+ /* Look for existing message */
+ for(idx = 0; idx < oh->nmesgs; idx++)
+ if(H5O_MSG_MTIME == oh->mesg[idx].type || H5O_MSG_MTIME_NEW == oh->mesg[idx].type)
+ break;
+
+ /* Create a new message, if necessary */
+ if(idx == oh->nmesgs) {
+ unsigned mesg_flags = 0; /* Flags for message in object header */
+
+ /* If we would have to create a new message, but we aren't 'forcing' it, get out now */
+ if(!force)
+ HGOTO_DONE(SUCCEED); /*nothing to do*/
+
+ /* Allocate space for the modification time message */
+ if(H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now, &idx) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message")
+
+ /* Set the message's flags if appropriate */
+ oh->mesg[idx].flags = (uint8_t)mesg_flags;
+ } /* end if */
+
+ /* Protect chunk */
+ if(NULL == (chk_proxy = H5O_chunk_protect(f, dxpl_id, oh, oh->mesg[idx].chunkno)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk")
+
+ /* Allocate 'native' space, if necessary */
+ if(NULL == oh->mesg[idx].native) {
+ if(NULL == (oh->mesg[idx].native = H5FL_MALLOC(time_t)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for modification time message")
+ } /* end if */
+
+ /* Update the message */
+ *((time_t *)(oh->mesg[idx].native)) = now;
+
+ /* Mark the message as dirty */
+ oh->mesg[idx].dirty = TRUE;
+ chk_dirtied = TRUE;
+ } /* end if */
+ else {
+ /* XXX: For now, update access time & change fields in the object header */
+ /* (will need to add some code to update modification time appropriately) */
+ oh->atime = oh->ctime = now;
+
+ /* Mark object header as dirty in cache */
+ if(H5AC_mark_entry_dirty(oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty")
+ } /* end else */
+ } /* end if */
+
+done:
+ /* Release chunk */
+ if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, chk_proxy, chk_dirtied) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_touch_oh() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_touch
+ *
+ * Purpose: Touch an object by setting the modification time to the
+ * current time and marking the object as dirty. Unless FORCE
+ * is non-zero, nothing happens if there is no MTIME message in
+ * the object header.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * Monday, July 27, 1998
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_touch(const H5O_loc_t *loc, hbool_t force, hid_t dxpl_id)
+{
+ H5O_t *oh = NULL; /* Object header to modify */
+ unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* check args */
+ HDassert(loc);
+
+ /* Get the object header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
+
+ /* Create/Update the modification time message */
+ if(H5O_touch_oh(loc->file, dxpl_id, oh, force) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to update object modificaton time")
+
+ /* Mark object header as changed */
+ oh_flags |= H5AC__DIRTIED_FLAG;
+
+done:
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, oh_flags) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_touch() */
+
+#ifdef H5O_ENABLE_BOGUS
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_bogus_oh
+ *
+ * Purpose: Create a "bogus" message unless one already exists.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * <koziol@ncsa.uiuc.edu>
+ * Tuesday, January 21, 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags)
+{
+ size_t idx; /* Local index variable */
+ H5O_msg_class_t *type; /* Message class type */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ HDassert(f);
+ HDassert(oh);
+
+ /* Look for existing message */
+ for(idx = 0; idx < oh->nmesgs; idx++)
+ if(H5O_MSG_BOGUS_VALID == oh->mesg[idx].type || H5O_MSG_BOGUS_INVALID == oh->mesg[idx].type)
+ break;
+
+ /* Create a new message */
+ if(idx == oh->nmesgs) {
+ H5O_bogus_t *bogus; /* Pointer to the bogus information */
+
+ /* Allocate the native message in memory */
+ if(NULL == (bogus = H5MM_malloc(sizeof(H5O_bogus_t))))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message")
+
+ /* Update the native value */
+ bogus->u = H5O_BOGUS_VALUE;
+
+ if(bogus_id == H5O_BOGUS_VALID_ID)
+ type = H5O_MSG_BOGUS_VALID;
+ else if(bogus_id == H5O_BOGUS_INVALID_ID)
+ type = H5O_MSG_BOGUS_INVALID;
+ else
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID for 'bogus' message")
+
+ /* Allocate space in the object header for bogus message */
+ if(H5O_msg_alloc(f, dxpl_id, oh, type, &mesg_flags, bogus, &idx) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message")
+
+ /* Point to "bogus" information (take it over) */
+ oh->mesg[idx].native = bogus;
+
+ /* Set the appropriate flags for the message */
+ oh->mesg[idx].flags = mesg_flags;
+
+ /* Mark the message and object header as dirty */
+ oh->mesg[idx].dirty = TRUE;
+ oh->cache_info.is_dirty = TRUE;
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_bogus_oh() */
+#endif /* H5O_ENABLE_BOGUS */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_delete
+ *
+ * Purpose: Delete an object header from a file. This frees the file
+ * space used for the object header (and it's continuation blocks)
+ * and also walks through each header message and asks it to
+ * remove all the pieces of the file referenced by the header.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Mar 19 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr)
+{
+ H5O_t *oh = NULL; /* Object header information */
+ H5O_loc_t loc; /* Object location for object to delete */
+ unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */
+ hbool_t corked;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_TAG(dxpl_id, addr, FAIL)
+
+ /* Check args */
+ HDassert(f);
+ HDassert(H5F_addr_defined(addr));
+
+ /* Set up the object location */
+ loc.file = f;
+ loc.addr = addr;
+ loc.holding_file = FALSE;
+
+ /* Get the object header information */
+ if(NULL == (oh = H5O_protect(&loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
+
+ /* Delete object */
+ if(H5O_delete_oh(f, dxpl_id, oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file")
+
+ /* Uncork cache entries with tag: addr */
+ if(H5AC_cork(f, addr, H5AC__GET_CORKED, &corked) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status")
+ if(corked)
+ if(H5AC_cork(f, addr, H5AC__UNCORK, NULL) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork an object")
+
+ /* Mark object header as deleted */
+ oh_flags = H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG;
+
+done:
+ if(oh && H5O_unprotect(&loc, dxpl_id, oh, oh_flags) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+} /* end H5O_delete() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_delete_oh
+ *
+ * Purpose: Internal function to:
+ * Delete an object header from a file. This frees the file
+ * space used for the object header (and it's continuation blocks)
+ * and also walks through each header message and asks it to
+ * remove all the pieces of the file referenced by the header.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Mar 19 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh)
+{
+ H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
+ unsigned u;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Check args */
+ HDassert(f);
+ HDassert(oh);
+
+ /* Walk through the list of object header messages, asking each one to
+ * delete any file space used
+ */
+ for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
+ /* Free any space referred to in the file from this message */
+ if(H5O_delete_mesg(f, dxpl_id, oh, curr_msg) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message")
+ } /* end for */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_delete_oh() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_obj_type
+ *
+ * Purpose: Retrieves the type of object pointed to by `loc'.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Robb Matzke
+ * Wednesday, November 4, 1998
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id)
+{
+ H5O_t *oh = NULL; /* Object header for location */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL)
+
+ /* Load the object header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
+
+ /* Retrieve the type of the object */
+ if(H5O_obj_type_real(oh, obj_type) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type")
+
+done:
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+} /* end H5O_obj_type() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_obj_type_real
+ *
+ * Purpose: Returns the type of object pointed to by `oh'.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Monday, November 21, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type)
+{
+ const H5O_obj_class_t *obj_class; /* Class of object for header */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Sanity check */
+ HDassert(oh);
+ HDassert(obj_type);
+
+ /* Look up class for object header */
+ if(NULL == (obj_class = H5O_obj_class_real(oh))) {
+ /* Clear error stack from "failed" class lookup */
+ H5E_clear_stack(NULL);
+
+ /* Set type to "unknown" */
+ *obj_type = H5O_TYPE_UNKNOWN;
+ }
+ else {
+ /* Set object type */
+ *obj_type = obj_class->type;
+ }
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_obj_type_real() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_obj_class
+ *
+ * Purpose: Returns the class of object pointed to by `loc'.
+ *
+ * Return: Success: An object class
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Monday, November 6, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+const H5O_obj_class_t *
+H5O_obj_class(const H5O_loc_t *loc, hid_t dxpl_id)
+{
+ H5O_t *oh = NULL; /* Object header for location */
+ const H5O_obj_class_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->addr, NULL)
+
+ /* Load the object header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header")
+
+ /* Test whether entry qualifies as a particular type of object */
+ if(NULL == (ret_value = H5O_obj_class_real(oh)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to determine object type")
+
+done:
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI_TAG(ret_value, NULL)
+} /* end H5O_obj_class() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_obj_class_real
+ *
+ * Purpose: Returns the class of object pointed to by `oh'.
+ *
+ * Return: Success: An object class
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * Monday, November 21, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+static const H5O_obj_class_t *
+H5O_obj_class_real(H5O_t *oh)
+{
+ size_t i; /* Local index variable */
+ const H5O_obj_class_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI(NULL)
+
+ /* Sanity check */
+ HDassert(oh);
+
+ /* Test whether entry qualifies as a particular type of object */
+ /* (Note: loop is in reverse order, to test specific objects first) */
+ for(i = NELMTS(H5O_obj_class_g); i > 0; --i) {
+ htri_t isa; /* Is entry a particular type? */
+
+ if((isa = (H5O_obj_class_g[i - 1]->isa)(oh)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type")
+ else if(isa)
+ HGOTO_DONE(H5O_obj_class_g[i - 1])
+ }
+
+ if(0 == i)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_obj_class_real() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_loc
+ *
+ * Purpose: Gets the object location for an object given its ID.
+ *
+ * Return: Success: Pointer to H5O_loc_t
+ * Failure: NULL
+ *
+ * Programmer: James Laird
+ * July 25 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+H5O_loc_t *
+H5O_get_loc(hid_t object_id)
+{
+ H5O_loc_t *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ switch(H5I_get_type(object_id)) {
+ case H5I_GROUP:
+ if(NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from group ID")
+ break;
+
+ case H5I_DATASET:
+ if(NULL == (ret_value = H5O_OBJ_DATASET->get_oloc(object_id)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from dataset ID")
+ break;
+
+ case H5I_DATATYPE:
+ if(NULL == (ret_value = H5O_OBJ_DATATYPE->get_oloc(object_id)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from datatype ID")
+ break;
+
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_FILE:
+ case H5I_DATASPACE:
+ case H5I_ATTR:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, NULL, "invalid object type")
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_get_loc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_loc_reset
+ *
+ * Purpose: Reset a object location to an empty state
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Monday, September 19, 2005
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_loc_reset(H5O_loc_t *loc)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Check arguments */
+ HDassert(loc);
+
+ /* Clear the object location to an empty state */
+ HDmemset(loc, 0, sizeof(H5O_loc_t));
+ loc->addr = HADDR_UNDEF;
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_loc_reset() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_loc_copy
+ *
+ * Purpose: Copy object location information
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Monday, September 19, 2005
+ *
+ * Notes: 'depth' parameter determines how much of the group entry
+ * structure we want to copy. The values are:
+ * H5_COPY_SHALLOW - Copy all the field values from the source
+ * to the destination, but not copying objects pointed to.
+ * (Destination "takes ownership" of objects pointed to)
+ * H5_COPY_DEEP - Copy all the fields from the source to
+ * the destination, deep copying objects pointed to.
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Check arguments */
+ HDassert(src);
+ HDassert(dst);
+ HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP);
+
+ /* Copy the top level information */
+ HDmemcpy(dst, src, sizeof(H5O_loc_t));
+
+ /* Deep copy the names */
+ if(depth == H5_COPY_DEEP) {
+ /* If the original entry was holding open the file, this one should
+ * hold it open, too.
+ */
+ if(src->holding_file)
+ H5F_INCR_NOPEN_OBJS(dst->file);
+ }
+ else if(depth == H5_COPY_SHALLOW) {
+ H5O_loc_reset(src);
+ }
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_loc_copy() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_loc_hold_file
+ *
+ * Purpose: Have this object header hold a file open until it is
+ * released.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: James Laird
+ * Wednesday, August 16, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_loc_hold_file(H5O_loc_t *loc)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Check arguments */
+ HDassert(loc);
+ HDassert(loc->file);
+
+ /* If this location is not already holding its file open, do so. */
+ if(!loc->holding_file) {
+ H5F_INCR_NOPEN_OBJS(loc->file);
+ loc->holding_file = TRUE;
+ }
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_loc_hold_file() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_loc_free
+ *
+ * Purpose: Release resources used by this object header location.
+ * Not to be confused with H5O_close; this is used on
+ * locations that don't correspond to open objects.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: James Laird
+ * Wednesday, August 16, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_loc_free(H5O_loc_t *loc)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Check arguments */
+ HDassert(loc);
+
+ /* If this location is holding its file open try to close the file. */
+ if(loc->holding_file) {
+ H5F_DECR_NOPEN_OBJS(loc->file);
+ loc->holding_file = FALSE;
+ if(H5F_NOPEN_OBJS(loc->file) <= 0) {
+ if(H5F_try_close(loc->file, NULL) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file")
+ }
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_loc_free() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_hdr_info
+ *
+ * Purpose: Retrieve the object header information for an object
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * September 22 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_get_hdr_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_hdr_info_t *hdr)
+{
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Check args */
+ HDassert(loc);
+ HDassert(hdr);
+
+ /* Reset the object header info structure */
+ HDmemset(hdr, 0, sizeof(*hdr));
+
+ /* Get the object header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header")
+
+ /* Get the information for the object header */
+ if(H5O_get_hdr_info_real(oh, hdr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
+
+done:
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_get_hdr_info() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_hdr_info_real
+ *
+ * Purpose: Internal routine to retrieve the object header information for an object
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * September 22 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
+{
+ const H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */
+ const H5O_chunk_t *curr_chunk; /* Pointer to current message being operated on */
+ unsigned u; /* Local index variable */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Check args */
+ HDassert(oh);
+ HDassert(hdr);
+
+ /* Set the version for the object header */
+ hdr->version = oh->version;
+
+ /* Set the number of messages & chunks */
+ H5_CHECKED_ASSIGN(hdr->nmesgs, unsigned, oh->nmesgs, size_t);
+ H5_CHECKED_ASSIGN(hdr->nchunks, unsigned, oh->nchunks, size_t);
+
+ /* Set the status flags */
+ hdr->flags = oh->flags;
+
+ /* Iterate over all the messages, accumulating message size & type information */
+ hdr->space.meta = (hsize_t)H5O_SIZEOF_HDR(oh) + (hsize_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1));
+ hdr->space.mesg = 0;
+ hdr->space.free = 0;
+ hdr->mesg.present = 0;
+ hdr->mesg.shared = 0;
+ for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) {
+ uint64_t type_flag; /* Flag for message type */
+
+ /* Accumulate space usage information, based on the type of message */
+ if(H5O_NULL_ID == curr_msg->type->id)
+ hdr->space.free += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size);
+ else if(H5O_CONT_ID == curr_msg->type->id)
+ hdr->space.meta += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size);
+ else {
+ hdr->space.meta += (hsize_t)H5O_SIZEOF_MSGHDR_OH(oh);
+ hdr->space.mesg += curr_msg->raw_size;
+ } /* end else */
+
+ /* Set flag to indicate presence of message type */
+ type_flag = ((uint64_t)1) << curr_msg->type->id;
+ hdr->mesg.present |= type_flag;
+
+ /* Set flag if the message is shared in some way */
+ if(curr_msg->flags & H5O_MSG_FLAG_SHARED) \
+ hdr->mesg.shared |= type_flag;
+ } /* end for */
+
+ /* Iterate over all the chunks, adding any gaps to the free space */
+ hdr->space.total = 0;
+ for(u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) {
+ /* Accumulate the size of the header on disk */
+ hdr->space.total += curr_chunk->size;
+
+ /* If the chunk has a gap, add it to the free space */
+ hdr->space.free += curr_chunk->gap;
+ } /* end for */
+
+ /* Sanity check that all the bytes are accounted for */
+ HDassert(hdr->space.total == (hdr->space.free + hdr->space.meta + hdr->space.mesg));
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_get_hdr_info_real() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_info
+ *
+ * Purpose: Retrieve the information for an object
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * November 21 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_get_info(const H5O_loc_t *loc, hid_t dxpl_id, hbool_t want_ih_info,
+ H5O_info_t *oinfo)
+{
+ const H5O_obj_class_t *obj_class; /* Class of object for header */
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL)
+
+ /* Check args */
+ HDassert(loc);
+ HDassert(oinfo);
+
+ /* Get the object header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
+
+ /* Reset the object info structure */
+ HDmemset(oinfo, 0, sizeof(*oinfo));
+
+ /* Retrieve the file's fileno */
+ H5F_GET_FILENO(loc->file, oinfo->fileno);
+
+ /* Set the object's address */
+ oinfo->addr = loc->addr;
+
+ /* Get class for object */
+ if(NULL == (obj_class = H5O_obj_class_real(oh)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class")
+
+ /* Retrieve the type of the object */
+ oinfo->type = obj_class->type;
+
+ /* Set the object's reference count */
+ oinfo->rc = oh->nlink;
+
+ /* Get modification time for object */
+ if(oh->version > H5O_VERSION_1) {
+ oinfo->atime = oh->atime;
+ oinfo->mtime = oh->mtime;
+ oinfo->ctime = oh->ctime;
+ oinfo->btime = oh->btime;
+ } /* end if */
+ else {
+ htri_t exists; /* Flag if header message of interest exists */
+
+ /* No information for access & modification fields */
+ /* (we stopped updating the "modification time" header message for
+ * raw data changes, so the "modification time" header message
+ * is closest to the 'change time', in POSIX terms - QAK)
+ */
+ oinfo->atime = 0;
+ oinfo->mtime = 0;
+ oinfo->btime = 0;
+
+ /* Might be information for modification time */
+ if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_ID)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME message")
+ if(exists > 0) {
+ /* Get "old style" modification time info */
+ if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_MTIME_ID, &oinfo->ctime))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME message")
+ } /* end if */
+ else {
+ /* Check for "new style" modification time info */
+ if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_NEW_ID)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME_NEW message")
+ if(exists > 0) {
+ /* Get "new style" modification time info */
+ if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_MTIME_NEW_ID, &oinfo->ctime))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME_NEW message")
+ } /* end if */
+ else
+ oinfo->ctime = 0;
+ } /* end else */
+ } /* end else */
+
+ /* Get the information for the object header */
+ if(H5O_get_hdr_info_real(oh, &oinfo->hdr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
+
+ /* Retrieve # of attributes */
+ if(H5O_attr_count_real(loc->file, dxpl_id, oh, &oinfo->num_attrs) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count")
+
+ /* Get B-tree & heap metadata storage size, if requested */
+ if(want_ih_info) {
+ /* Check for 'bh_info' callback for this type of object */
+ if(obj_class->bh_info) {
+ /* Call the object's class 'bh_info' routine */
+ if((obj_class->bh_info)(loc, dxpl_id, oh, &oinfo->meta_size.obj) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info")
+ } /* end if */
+
+ /* Get B-tree & heap info for any attributes */
+ if(oinfo->num_attrs > 0) {
+ if(H5O_attr_bh_info(loc->file, dxpl_id, oh, &oinfo->meta_size.attr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info")
+ } /* end if */
+ } /* end if */
+
+done:
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+} /* end H5O_get_info() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_create_plist
+ *
+ * Purpose: Retrieve the object creation properties for an object
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * November 28 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_get_create_plist(const H5O_loc_t *loc, hid_t dxpl_id, H5P_genplist_t *oc_plist)
+{
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Check args */
+ HDassert(loc);
+ HDassert(oc_plist);
+
+ /* Get the object header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
+
+ /* Set property values, if they were used for the object */
+ if(oh->version > H5O_VERSION_1) {
+ uint8_t ohdr_flags; /* "User-visible" object header status flags */
+
+ /* Set attribute storage values */
+ if(H5P_set(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set max. # of compact attributes in property list")
+ if(H5P_set(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list")
+
+ /* Mask off non-"user visible" flags */
+ ohdr_flags = oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_STORE_TIMES);
+
+ /* Set object header flags */
+ if(H5P_set(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags")
+ } /* end if */
+
+done:
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_get_create_plist() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_nlinks
+ *
+ * Purpose: Retrieve the number of link messages read in from the file
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * March 11 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_get_nlinks(const H5O_loc_t *loc, hid_t dxpl_id, hsize_t *nlinks)
+{
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Check args */
+ HDassert(loc);
+ HDassert(nlinks);
+
+ /* Get the object header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
+
+ /* Retrieve the # of link messages seen when the object header was loaded */
+ *nlinks = oh->link_msgs_seen;
+
+done:
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_get_nlinks() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_obj_create
+ *
+ * Purpose: Creates an object, in an abstract manner.
+ *
+ * Return: Success: Pointer to object opened
+ * Failure: NULL
+ *
+ * Programmer: Quincey Koziol
+ * April 9 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc,
+ hid_t dxpl_id)
+{
+ size_t u; /* Local index variable */
+ void *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI(NULL)
+
+ /* Sanity checks */
+ HDassert(f);
+ HDassert(obj_type >= H5O_TYPE_GROUP && obj_type <= H5O_TYPE_NAMED_DATATYPE);
+ HDassert(crt_info);
+ HDassert(obj_loc);
+
+ /* Iterate through the object classes */
+ for(u = 0; u < NELMTS(H5O_obj_class_g); u++) {
+ /* Check for correct type of object to create */
+ if(H5O_obj_class_g[u]->type == obj_type) {
+ /* Call the object class's 'create' routine */
+ HDassert(H5O_obj_class_g[u]->create);
+ if(NULL == (ret_value = H5O_obj_class_g[u]->create(f, crt_info, obj_loc, dxpl_id)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object")
+
+ /* Break out of loop */
+ break;
+ } /* end if */
+ } /* end for */
+ HDassert(ret_value);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_obj_create() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_oh_addr
+ *
+ * Purpose: Retrieve the address of the object header
+ *
+ * Note: This routine participates in the "Inlining C struct access"
+ * pattern, don't call it directly, use the appropriate macro
+ * defined in H5Oprivate.h.
+ *
+ * Return: Success: Valid haddr_t
+ * Failure: HADDR_UNDEF
+ *
+ * Programmer: Quincey Koziol
+ * March 15 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+haddr_t
+H5O_get_oh_addr(const H5O_t *oh)
+{
+ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ HDassert(oh);
+ HDassert(oh->chunk);
+
+ FUNC_LEAVE_NOAPI(oh->chunk[0].addr)
+} /* end H5O_get_oh_addr() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_rc_and_type
+ *
+ * Purpose: Retrieve an object's reference count and type
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * November 4 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_get_rc_and_type(const H5O_loc_t *loc, hid_t dxpl_id, unsigned *rc, H5O_type_t *otype)
+{
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Check args */
+ HDassert(loc);
+
+ /* Get the object header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
+
+ /* Set the object's reference count */
+ if(rc)
+ *rc = oh->nlink;
+
+ /* Retrieve the type of the object */
+ if(otype)
+ if(H5O_obj_type_real(oh, otype) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type")
+
+done:
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_get_rc_and_type() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_free_visit_visited
+ *
+ * Purpose: Free the key for an object visited during a group traversal
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Nov 25, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data/*in,out*/)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ item = H5FL_FREE(H5_obj_t, item);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5O_free_visit_visited() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_visit_cb
+ *
+ * Purpose: Callback function for recursively visiting objects from a group
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Nov 25, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *linfo,
+ void *_udata)
+{
+ H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */
+ H5G_loc_t obj_loc; /* Location of object */
+ H5G_name_t obj_path; /* Object's group hier. path */
+ H5O_loc_t obj_oloc; /* Object's object location */
+ hbool_t obj_found = FALSE; /* Object at 'name' found */
+ herr_t ret_value = H5_ITER_CONT; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Sanity check */
+ HDassert(name);
+ HDassert(linfo);
+ HDassert(udata);
+
+ /* Check if this is a hard link */
+ if(linfo->type == H5L_TYPE_HARD) {
+ H5_obj_t obj_pos; /* Object "position" for this object */
+
+ /* Set up opened group location to fill in */
+ obj_loc.oloc = &obj_oloc;
+ obj_loc.path = &obj_path;
+ H5G_loc_reset(&obj_loc);
+
+ /* Find the object using the LAPL passed in */
+ /* (Correctly handles mounted files) */
+ if(H5G_loc_find(udata->start_loc, name, &obj_loc/*out*/, udata->lapl_id, udata->dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5_ITER_ERROR, "object not found")
+ obj_found = TRUE;
+
+ /* Construct unique "position" for this object */
+ H5F_GET_FILENO(obj_oloc.file, obj_pos.fileno);
+ obj_pos.addr = obj_oloc.addr;
+
+ /* Check if we've seen the object the link references before */
+ if(NULL == H5SL_search(udata->visited, &obj_pos)) {
+ H5O_info_t oinfo; /* Object info */
+
+ /* Get the object's info */
+ if(H5O_get_info(&obj_oloc, udata->dxpl_id, TRUE, &oinfo) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get object info")
+
+ /* Make the application callback */
+ ret_value = (udata->op)(udata->obj_id, name, &oinfo, udata->op_data);
+
+ /* Check for continuing to visit objects */
+ if(ret_value == H5_ITER_CONT) {
+ /* If its ref count is > 1, we add it to the list of visited objects */
+ /* (because it could come up again during traversal) */
+ if(oinfo.rc > 1) {
+ H5_obj_t *new_node; /* New object node for visited list */
+
+ /* Allocate new object "position" node */
+ if((new_node = H5FL_MALLOC(H5_obj_t)) == NULL)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate object node")
+
+ /* Set node information */
+ *new_node = obj_pos;
+
+ /* Add to list of visited objects */
+ if(H5SL_insert(udata->visited, new_node, new_node) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert object node into visited list")
+ } /* end if */
+ } /* end if */
+ } /* end if */
+ } /* end if */
+
+done:
+ /* Release resources */
+ if(obj_found && H5G_loc_free(&obj_loc) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_visit_cb() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_visit
+ *
+ * Purpose: Recursively visit an object and all the objects reachable
+ * from it. If the starting object is a group, all the objects
+ * linked to from that group will be visited. Links within
+ * each group are visited according to the order within the
+ * specified index (unless the specified index does not exist for
+ * a particular group, then the "name" index is used).
+ *
+ * NOTE: Soft links and user-defined links are ignored during
+ * this operation.
+ *
+ * NOTE: Each _object_ reachable from the initial group will only
+ * be visited once. If multiple hard links point to the same
+ * object, the first link to the object's path (according to the
+ * iteration index and iteration order given) will be used to in
+ * the callback about the object.
+ *
+ * Return: Success: The return value of the first operator that
+ * returns non-zero, or zero if all members were
+ * processed with no operator returning non-zero.
+ *
+ * Failure: Negative if something goes wrong within the
+ * library, or the negative value returned by one
+ * of the operators.
+ *
+ * Programmer: Quincey Koziol
+ * November 24 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
+ H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id,
+ hid_t dxpl_id)
+{
+ H5O_iter_visit_ud_t udata; /* User data for callback */
+ H5G_loc_t loc; /* Location of reference object */
+ H5G_loc_t obj_loc; /* Location used to open object */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
+ hbool_t loc_found = FALSE; /* Entry at 'name' found */
+ H5O_info_t oinfo; /* Object info struct */
+ hid_t obj_id = (-1); /* ID of object */
+ herr_t ret_value = FAIL; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Portably initialize user data struct to zeros */
+ HDmemset(&udata, 0, sizeof(udata));
+
+ /* Check args */
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+
+ /* Set up opened group location to fill in */
+ obj_loc.oloc = &obj_oloc;
+ obj_loc.path = &obj_path;
+ H5G_loc_reset(&obj_loc);
+
+ /* Find the object's location */
+ if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
+ loc_found = TRUE;
+
+ /* Get the object's info */
+ if(H5O_get_info(&obj_oloc, dxpl_id, TRUE, &oinfo) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info")
+
+ /* Open the object */
+ /* (Takes ownership of the obj_loc information) */
+ if((obj_id = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
+
+ /* Make callback for starting object */
+ if((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "can't visit objects")
+
+ /* Check return value of first callback */
+ if(ret_value != H5_ITER_CONT)
+ HGOTO_DONE(ret_value);
+
+ /* Check for object being a group */
+ if(oinfo.type == H5O_TYPE_GROUP) {
+ H5G_loc_t start_loc; /* Location of starting group */
+
+ /* Get the location of the starting group */
+ if(H5G_loc(obj_id, &start_loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+
+ /* Set up user data for visiting links */
+ udata.obj_id = obj_id;
+ udata.start_loc = &start_loc;
+ udata.lapl_id = lapl_id;
+ udata.dxpl_id = dxpl_id;
+ udata.op = op;
+ udata.op_data = op_data;
+
+ /* Create skip list to store visited object information */
+ if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create skip list for visited objects")
+
+ /* If its ref count is > 1, we add it to the list of visited objects */
+ /* (because it could come up again during traversal) */
+ if(oinfo.rc > 1) {
+ H5_obj_t *obj_pos; /* New object node for visited list */
+
+ /* Allocate new object "position" node */
+ if((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "can't allocate object node")
+
+ /* Construct unique "position" for this object */
+ obj_pos->fileno = oinfo.fileno;
+ obj_pos->addr = oinfo.addr;
+
+ /* Add to list of visited objects */
+ if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object node into visited list")
+ } /* end if */
+
+ /* Call internal group visitation routine */
+ if((ret_value = H5G_visit(obj_id, ".", idx_type, order, H5O_visit_cb, &udata, lapl_id, dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed")
+ } /* end if */
+
+done:
+ if(obj_id > 0) {
+ if(H5I_dec_app_ref(obj_id) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
+ } /* end if */
+ else if(loc_found && H5G_loc_free(&obj_loc) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location")
+ if(udata.visited)
+ H5SL_destroy(udata.visited, H5O_free_visit_visited, NULL);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_visit() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_inc_rc
+ *
+ * Purpose: Increments the reference count on an object header
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Jul 13 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_inc_rc(H5O_t *oh)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* check args */
+ HDassert(oh);
+
+ /* Pin the object header when the reference count goes above 0 */
+ if(oh->rc == 0)
+ if(H5AC_pin_protected_entry(oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header")
+
+ /* Increment reference count */
+ oh->rc++;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_inc_rc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_dec_rc
+ *
+ * Purpose: Decrements the reference count on an object header
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Jul 13 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_dec_rc(H5O_t *oh)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* check args */
+ HDassert(oh);
+
+ /* Decrement reference count */
+ oh->rc--;
+
+ /* Unpin the object header when the reference count goes back to 0 */
+ if(oh->rc == 0)
+ if(H5AC_unpin_entry(oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dec_rc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_dec_rc_by_loc
+ *
+ * Purpose: Decrement the refcount of an object header, using its
+ * object location information.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Oct 08 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_dec_rc_by_loc(const H5O_loc_t *loc, hid_t dxpl_id)
+{
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* check args */
+ HDassert(loc);
+
+ /* Get header */
+ if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header")
+
+ /* Decrement the reference count on the object header */
+ /* (which will unpin it, if appropriate) */
+ if(H5O_dec_rc(oh) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header")
+
+done:
+ /* Release the object header from the cache */
+ if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dec_rc_by_loc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_proxy
+ *
+ * Purpose: Retrieve the proxy for the object header.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * July 24 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+H5AC_proxy_entry_t *
+H5O_get_proxy(const H5O_t *oh)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* Check args */
+ HDassert(oh);
+
+ FUNC_LEAVE_NOAPI(oh->proxy)
+} /* end H5O_get_proxy() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O__free
+ *
+ * Purpose: Destroys an object header.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@ncsa.uiuc.edu
+ * Jan 15 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O__free(H5O_t *oh)
+{
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_PACKAGE
+
+ /* check args */
+ HDassert(oh);
+ HDassert(0 == oh->rc);
+
+ /* Destroy chunks */
+ if(oh->chunk) {
+ for(u = 0; u < oh->nchunks; u++)
+ oh->chunk[u].image = H5FL_BLK_FREE(chunk_image, oh->chunk[u].image);
+
+ oh->chunk = (H5O_chunk_t *)H5FL_SEQ_FREE(H5O_chunk_t, oh->chunk);
+ } /* end if */
+
+ /* Destroy messages */
+ if(oh->mesg) {
+ for(u = 0; u < oh->nmesgs; u++) {
+#ifndef NDEBUG
+ /* Verify that message is clean, unless it could have been marked
+ * dirty by decoding */
+ if(oh->ndecode_dirtied && oh->mesg[u].dirty)
+ oh->ndecode_dirtied--;
+ else
+ HDassert(oh->mesg[u].dirty == 0);
+#endif /* NDEBUG */
+
+ H5O_msg_free_mesg(&oh->mesg[u]);
+ } /* end for */
+
+ /* Make sure we accounted for all the messages dirtied by decoding */
+ HDassert(!oh->ndecode_dirtied);
+
+ oh->mesg = (H5O_mesg_t *)H5FL_SEQ_FREE(H5O_mesg_t, oh->mesg);
+ } /* end if */
+
+ /* Destroy the proxy */
+ if(oh->proxy)
+ if(H5AC_proxy_entry_dest(oh->proxy) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy virtual entry used for proxy")
+
+ /* destroy object header */
+ oh = H5FL_FREE(H5O_t, oh);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O__free() */
+
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 563f8fa..e87c148 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -24,6 +24,9 @@
#ifndef _H5Oprivate_H
#define _H5Oprivate_H
+/* Early typedefs to avoid circular dependencies */
+typedef struct H5O_t H5O_t;
+
/* Include the public header file for this API */
#include "H5Opublic.h" /* Object header functions */
@@ -44,7 +47,6 @@
/* Forward references of package typedefs */
typedef struct H5O_msg_class_t H5O_msg_class_t;
typedef struct H5O_mesg_t H5O_mesg_t;
-typedef struct H5O_t H5O_t;
/* Values used to create the shared message & attribute heaps */
/* (Note that these parameters have been tuned so that the resulting heap ID
@@ -881,6 +883,9 @@ H5_DLL void *H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_l
H5_DLL haddr_t H5O_get_oh_addr(const H5O_t *oh);
H5_DLL herr_t H5O_get_rc_and_type(const H5O_loc_t *oloc, hid_t dxpl_id, unsigned *rc, H5O_type_t *otype);
H5_DLL H5AC_proxy_entry_t *H5O_get_proxy(const H5O_t *oh);
+H5_DLL herr_t H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
+ H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id,
+ hid_t dxpl_id);
/* Object header message routines */
H5_DLL herr_t H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags,
diff --git a/src/H5PLint.c b/src/H5PLint.c
index c887f86..b190746 100644
--- a/src/H5PLint.c
+++ b/src/H5PLint.c
@@ -235,11 +235,11 @@ done:
*-------------------------------------------------------------------------
*/
const void *
-H5PL_load(H5PL_type_t type, int id)
+H5PL_load(H5PL_type_t type, H5PL_key_t key)
{
- H5PL_search_params_t search_params;
+ H5PL_search_params_t search_params; /* Plugin search parameters */
hbool_t found = FALSE; /* Whether the plugin was found */
- const void *plugin_info = NULL;
+ const void *plugin_info = NULL; /* Information from the plugin */
const void *ret_value = NULL;
FUNC_ENTER_NOAPI(NULL)
@@ -248,18 +248,17 @@ H5PL_load(H5PL_type_t type, int id)
switch (type) {
case H5PL_TYPE_FILTER:
if ((H5PL_plugin_control_mask_g & H5PL_FILTER_PLUGIN) == 0)
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "required dynamically loaded plugin filter '%d' is not available", id)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "filter plugins disabled")
break;
-
case H5PL_TYPE_ERROR:
case H5PL_TYPE_NONE:
default:
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "required dynamically loaded plugin '%d' is not valid", id)
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "Invalid plugin type specified")
}
/* Set up the search parameters */
search_params.type = type;
- search_params.id = id;
+ search_params.key.id = key.id;
/* Search in the table of already loaded plugin libraries */
if(H5PL__find_plugin_in_cache(&search_params, &found, &plugin_info) < 0)
@@ -304,11 +303,11 @@ done:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
herr_t
-H5PL__open(const char *path, H5PL_type_t type, int id, hbool_t *success, const void **plugin_info)
+H5PL__open(const char *path, H5PL_type_t type, H5PL_key_t key, hbool_t *success, const void **plugin_info)
{
H5PL_HANDLE handle = NULL;
H5PL_get_plugin_info_t get_plugin_info = NULL;
- htri_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE
@@ -326,35 +325,46 @@ H5PL__open(const char *path, H5PL_type_t type, int id, hbool_t *success, const v
*/
if (NULL == (handle = H5PL_OPEN_DLIB(path))) {
H5PL_CLR_ERROR; /* clear error */
- HGOTO_DONE(SUCCEED);
+ HGOTO_DONE(SUCCEED)
}
/* Return a handle for the function H5PLget_plugin_info in the dynamic library.
* The plugin library is suppose to define this function.
*/
- if (NULL != (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_info"))) {
-
- const H5Z_class2_t *info;
+ if (NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_info")))
+ HGOTO_DONE(SUCCEED)
- /* Get the plugin info */
- if (NULL == (info = (const H5Z_class2_t *)(*get_plugin_info)()))
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info")
+ /* Get the plugin information */
+ switch (type) {
+ case H5PL_TYPE_FILTER:
+ {
+ const H5Z_class2_t *filter_info;
- /* Check if the filter IDs match */
- if (info->id == id) {
+ /* Get the plugin info */
+ if (NULL == (filter_info = (const H5Z_class2_t *)(*get_plugin_info)()))
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get filter info from plugin")
- /* Store the plugin in the cache */
- if (H5PL__add_plugin(type, id, handle))
- HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINSERT, FAIL, "unable to add new plugin to plugin cache")
+ /* If the filter IDs match, we're done. Set the output parameters. */
+ if (filter_info->id == key.id) {
+ *plugin_info = (const void *)filter_info;
+ *success = TRUE;
+ }
- /* Set output parameters */
- *success = TRUE;
- *plugin_info = (const void *)info;
+ break;
}
- }
+ case H5PL_TYPE_ERROR:
+ case H5PL_TYPE_NONE:
+ default:
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "Invalid plugin type specified")
+ } /* end switch */
+
+ /* If we found the correct plugin, store it in the cache */
+ if (*success)
+ if (H5PL__add_plugin(type, key, handle))
+ HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINSERT, FAIL, "unable to add new plugin to plugin cache")
done:
- if (!success && handle)
+ if (!(*success) && handle)
if (H5PL__close(handle) < 0)
HDONE_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library")
diff --git a/src/H5PLpath.c b/src/H5PLpath.c
index 435802a..972f1d0 100644
--- a/src/H5PLpath.c
+++ b/src/H5PLpath.c
@@ -689,7 +689,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo
continue;
/* attempt to open the dynamic library as a filter library */
- if (H5PL__open(path, search_params->type, search_params->id, found, plugin_info) < 0)
+ if (H5PL__open(path, search_params->type, search_params->key, found, plugin_info) < 0)
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed")
if (*found)
HGOTO_DONE(SUCCEED)
@@ -755,7 +755,7 @@ H5PL__find_plugin_in_path(const H5PL_search_params_t *search_params, hbool_t *fo
continue;
/* attempt to open the dynamic library as a filter library */
- if (H5PL__open(path, search_params->type, search_params->id, found, plugin_info) < 0)
+ if (H5PL__open(path, search_params->type, search_params->key, found, plugin_info) < 0)
HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed")
if (*found)
HGOTO_DONE(SUCCEED)
diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h
index 0d1c271..dfaa4af 100644
--- a/src/H5PLpkg.h
+++ b/src/H5PLpkg.h
@@ -115,8 +115,8 @@
/* Data used to search for plugins */
typedef struct H5PL_search_params_t {
- H5PL_type_t type;
- int id;
+ H5PL_type_t type;
+ H5PL_key_t key;
} H5PL_search_params_t;
@@ -134,13 +134,13 @@ H5_DLL herr_t H5PL__get_plugin_control_mask(unsigned int *mask /*out*/);
H5_DLL herr_t H5PL__set_plugin_control_mask(unsigned int mask);
/* Plugin search and manipulation */
-H5_DLL herr_t H5PL__open(const char *libname, H5PL_type_t type, int id, hbool_t *success /*out*/, const void **plugin_info /*out*/);
+H5_DLL herr_t H5PL__open(const char *libname, H5PL_type_t type, H5PL_key_t key, hbool_t *success /*out*/, const void **plugin_info /*out*/);
H5_DLL herr_t H5PL__close(H5PL_HANDLE handle);
/* Plugin cache calls */
H5_DLL herr_t H5PL__create_plugin_cache(void);
H5_DLL herr_t H5PL__close_plugin_cache(hbool_t *already_closed /*out*/);
-H5_DLL herr_t H5PL__add_plugin(H5PL_type_t type, int id, H5PL_HANDLE handle);
+H5_DLL herr_t H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle);
H5_DLL herr_t H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found /*out*/, const void **plugin_info /*out*/);
/* Plugin search path calls */
diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c
index e483e01..e905ac2 100644
--- a/src/H5PLplugin_cache.c
+++ b/src/H5PLplugin_cache.c
@@ -56,9 +56,9 @@
/* Type for the list of info for opened plugin libraries */
typedef struct H5PL_plugin_t {
- H5PL_type_t type; /* Plugin type */
- int id; /* ID for the plugin */
- H5PL_HANDLE handle; /* Plugin handle */
+ H5PL_type_t type; /* Plugin type */
+ H5PL_key_t key; /* Unique key to identify the plugin */
+ H5PL_HANDLE handle; /* Plugin handle */
} H5PL_plugin_t;
@@ -209,14 +209,14 @@ done:
/*-------------------------------------------------------------------------
* Function: H5PL__add_plugin
*
- * Purpose: Add a plugin to the plugin cached.
+ * Purpose: Add a plugin to the plugin cache.
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
-H5PL__add_plugin(H5PL_type_t type, int id, H5PL_HANDLE handle)
+H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle)
{
herr_t ret_value = SUCCEED;
@@ -229,7 +229,7 @@ H5PL__add_plugin(H5PL_type_t type, int id, H5PL_HANDLE handle)
/* Store the plugin info and bump the # of plugins */
H5PL_cache_g[H5PL_num_plugins_g].type = type;
- H5PL_cache_g[H5PL_num_plugins_g].id = id;
+ H5PL_cache_g[H5PL_num_plugins_g].key = key;
H5PL_cache_g[H5PL_num_plugins_g].handle = handle;
H5PL_num_plugins_g++;
@@ -276,7 +276,7 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f
for (u = 0; u < H5PL_num_plugins_g; u++) {
/* If the plugin type (filter, etc.) and ID match, query the plugin for its info */
- if ((search_params->type == (H5PL_cache_g[u]).type) && (search_params->id == (H5PL_cache_g[u]).id)) {
+ if ((search_params->type == (H5PL_cache_g[u]).type) && (search_params->key.id == (H5PL_cache_g[u]).key.id)) {
H5PL_get_plugin_info_t get_plugin_info_function;
const H5Z_class2_t *filter_info;
diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h
index bc12e64..cc2e258 100644
--- a/src/H5PLprivate.h
+++ b/src/H5PLprivate.h
@@ -33,6 +33,11 @@
/* Library Private Typedefs */
/****************************/
+/* The key that will be used to find the plugin */
+typedef union H5PL_key_t {
+ int id; /* filters */
+} H5PL_key_t;
+
/*****************************/
/* Library-private Variables */
@@ -44,7 +49,7 @@
/***************************************/
/* Internal API routines */
-H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, int type_id);
+H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, H5PL_key_t key);
#endif /* _H5PLprivate_H */
diff --git a/src/H5PLpublic.h b/src/H5PLpublic.h
index 3b36ccd..fe5bdfb 100644
--- a/src/H5PLpublic.h
+++ b/src/H5PLpublic.h
@@ -30,9 +30,9 @@
/* Plugin type used by the plugin library */
typedef enum H5PL_type_t {
- H5PL_TYPE_ERROR = -1, /* Error */
- H5PL_TYPE_FILTER = 0, /* Filter */
- H5PL_TYPE_NONE = 1 /* This must be last! */
+ H5PL_TYPE_ERROR = -1, /* Error */
+ H5PL_TYPE_FILTER = 0, /* Filter */
+ H5PL_TYPE_NONE = 1 /* This must be last! */
} H5PL_type_t;
/* Common dynamic plugin type flags used by the set/get_loading_state functions */
diff --git a/src/H5R.c b/src/H5R.c
index b965632..0409f33 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -21,16 +21,13 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5Dprivate.h" /* Datasets */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Gprivate.h" /* Groups */
-#include "H5HGprivate.h" /* Global Heaps */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Rpkg.h" /* References */
-#include "H5Sprivate.h" /* Dataspaces */
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Gprivate.h" /* Groups */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Rpkg.h" /* References */
+#include "H5Sprivate.h" /* Dataspaces */
/****************/
@@ -47,20 +44,11 @@
/* Local Prototypes */
/********************/
-static herr_t H5R_create(void *ref, H5G_loc_t *loc, const char *name,
- H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id);
-static H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref);
-static ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id,
- H5R_type_t ref_type, const void *_ref, char *name, size_t size);
-
/*********************/
/* Package Variables */
/*********************/
-/* Package initialization variable */
-hbool_t H5_PKG_INIT_VAR = FALSE;
-
/*****************************/
/* Library Private Variables */
@@ -71,275 +59,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE;
/* Local Variables */
/*******************/
-/* Reference ID class */
-static const H5I_class_t H5I_REFERENCE_CLS[1] = {{
- H5I_REFERENCE, /* ID class value */
- 0, /* Class flags */
- 0, /* # of reserved IDs for class */
- NULL /* Callback routine for closing objects of this class */
-}};
-
-/* Flag indicating "top" of interface has been initialized */
-static hbool_t H5R_top_package_initialize_s = FALSE;
-
-
-
-/*--------------------------------------------------------------------------
-NAME
- H5R__init_package -- Initialize interface-specific information
-USAGE
- herr_t H5R__init_package()
-
-RETURNS
- Non-negative on success/Negative on failure
-DESCRIPTION
- Initializes any interface-specific data or routines.
-
---------------------------------------------------------------------------*/
-herr_t
-H5R__init_package(void)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Initialize the atom group for the file IDs */
- if(H5I_register_type(H5I_REFERENCE_CLS) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface")
-
- /* Mark "top" of interface as initialized, too */
- H5R_top_package_initialize_s = TRUE;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5R__init_package() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5R_top_term_package
- PURPOSE
- Terminate various H5R objects
- USAGE
- void H5R_top_term_package()
- RETURNS
- void
- DESCRIPTION
- Release IDs for the atom group, deferring full interface shutdown
- until later (in H5R_term_package).
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Can't report errors...
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-int
-H5R_top_term_package(void)
-{
- int n = 0;
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- if(H5R_top_package_initialize_s) {
- if(H5I_nmembers(H5I_REFERENCE) > 0) {
- (void)H5I_clear_type(H5I_REFERENCE, FALSE, FALSE);
- n++; /*H5I*/
- } /* end if */
-
- /* Mark closed */
- if(0 == n)
- H5R_top_package_initialize_s = FALSE;
- } /* end if */
-
- FUNC_LEAVE_NOAPI(n)
-} /* end H5R_top_term_package() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5R_term_package
- PURPOSE
- Terminate various H5R objects
- USAGE
- void H5R_term_package()
- RETURNS
- void
- DESCRIPTION
- Release the atom group and any other resources allocated.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Can't report errors...
-
- Finishes shutting down the interface, after H5R_top_term_package()
- is called
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-int
-H5R_term_package(void)
-{
- int n = 0;
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- if(H5_PKG_INIT_VAR) {
- /* Sanity checks */
- HDassert(0 == H5I_nmembers(H5I_REFERENCE));
- HDassert(FALSE == H5R_top_package_initialize_s);
-
- /* Destroy the reference id group */
- n += (H5I_dec_type_ref(H5I_REFERENCE) > 0);
-
- /* Mark closed */
- if(0 == n)
- H5_PKG_INIT_VAR = FALSE;
- } /* end if */
-
- FUNC_LEAVE_NOAPI(n)
-} /* end H5R_term_package() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5R_create
- PURPOSE
- Creates a particular kind of reference for the user
- USAGE
- herr_t H5R_create(ref, loc, name, ref_type, space)
- void *ref; OUT: Reference created
- H5G_loc_t *loc; IN: File location used to locate object pointed to
- const char *name; IN: Name of object at location LOC_ID of object
- pointed to
- H5R_type_t ref_type; IN: Type of reference to create
- H5S_t *space; IN: Dataspace ID with selection, used for Dataset
- Region references.
-
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Creates a particular type of reference specified with REF_TYPE, in the
- space pointed to by REF. The LOC_ID and NAME are used to locate the object
- pointed to and the SPACE_ID is used to choose the region pointed to (for
- Dataset Region references).
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id)
-{
- H5G_loc_t obj_loc; /* Group hier. location of object */
- H5G_name_t path; /* Object group hier. path */
- H5O_loc_t oloc; /* Object object location */
- hbool_t obj_found = FALSE; /* Object location found */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- HDassert(_ref);
- HDassert(loc);
- HDassert(name);
- HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE);
-
- /* Set up object location to fill in */
- obj_loc.oloc = &oloc;
- obj_loc.path = &path;
- H5G_loc_reset(&obj_loc);
-
- /* Find the object */
- if(H5G_loc_find(loc, name, &obj_loc, H5P_DEFAULT, dxpl_id) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "object not found")
- obj_found = TRUE;
-
- switch(ref_type) {
- case H5R_OBJECT:
- {
- hobj_ref_t *ref = (hobj_ref_t *)_ref; /* Get pointer to correct type of reference struct */
-
- *ref = obj_loc.oloc->addr;
- break;
- }
-
- case H5R_DATASET_REGION:
- {
- H5HG_t hobjid; /* Heap object ID */
- hdset_reg_ref_t *ref = (hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */
- hssize_t buf_size; /* Size of buffer needed to serialize selection */
- uint8_t *p; /* Pointer to OID to store */
- uint8_t *buf; /* Buffer to store serialized selection in */
- unsigned heapid_found; /* Flag for non-zero heap ID found */
- unsigned u; /* local index */
-
- /* Set up information for dataset region */
-
- /* Return any previous heap block to the free list if we are garbage collecting */
- if(H5F_GC_REF(loc->oloc->file)) {
- /* Check for an existing heap ID in the reference */
- for(u = 0, heapid_found = 0, p = (uint8_t *)ref; u < H5R_DSET_REG_REF_BUF_SIZE; u++)
- if(p[u] != 0) {
- heapid_found = 1;
- break;
- } /* end if */
-
- if(heapid_found != 0) {
-/* Return heap block to free list */
- } /* end if */
- } /* end if */
-
- /* Zero the heap ID out, may leak heap space if user is re-using reference and doesn't have garbage collection on */
- HDmemset(ref, 0, H5R_DSET_REG_REF_BUF_SIZE);
-
- /* Get the amount of space required to serialize the selection */
- if((buf_size = H5S_SELECT_SERIAL_SIZE(space, loc->oloc->file)) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "Invalid amount of space for serializing selection")
-
- /* Increase buffer size to allow for the dataset OID */
- buf_size += (hssize_t)sizeof(haddr_t);
-
- /* Allocate the space to store the serialized information */
- H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t);
- if(NULL == (buf = (uint8_t *)H5MM_malloc((size_t)buf_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-
- /* Serialize information for dataset OID into heap buffer */
- p = (uint8_t *)buf;
- H5F_addr_encode(loc->oloc->file, &p, obj_loc.oloc->addr);
-
- /* Serialize the selection into heap buffer */
- if(H5S_SELECT_SERIALIZE(space, &p, loc->oloc->file) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection")
-
- /* Save the serialized buffer for later */
- H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t);
- if(H5HG_insert(loc->oloc->file, dxpl_id, (size_t)buf_size, buf, &hobjid) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to serialize selection")
-
- /* Serialize the heap ID and index for storage in the file */
- p = (uint8_t *)ref;
- H5F_addr_encode(loc->oloc->file, &p, hobjid.addr);
- UINT32ENCODE(p, hobjid.idx);
-
- /* Free the buffer we serialized data in */
- H5MM_xfree(buf);
- break;
- }
-
- case H5R_BADTYPE:
- case H5R_MAXTYPE:
- default:
- HDassert("unknown reference type" && 0);
- HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
- } /* end switch */
-
-done:
- if(obj_found)
- H5G_loc_free(&obj_loc);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5R_create() */
-
-
/*--------------------------------------------------------------------------
NAME
H5Rcreate
@@ -378,23 +97,23 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t
H5TRACE5("e", "*xi*sRti", ref, loc_id, name, ref_type, space_id);
/* Check args */
- if(ref == NULL)
+ if (ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
- if(H5G_loc(loc_id, &loc) < 0)
+ if (H5G_loc(loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(!name || !*name)
+ if (!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given")
- if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
+ if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
- if(ref_type != H5R_OBJECT && ref_type != H5R_DATASET_REGION)
+ if (ref_type != H5R_OBJECT && ref_type != H5R_DATASET_REGION)
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported")
- if(space_id == (-1) && ref_type == H5R_DATASET_REGION)
+ if (space_id == (-1) && ref_type == H5R_DATASET_REGION)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid")
- if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))))
+ if (space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
/* Create reference */
- if((ret_value = H5R_create(ref, &loc, name, ref_type, space, H5AC_ind_read_dxpl_id)) < 0)
+ if ((ret_value = H5R_create(ref, &loc, name, ref_type, space, H5AC_ind_read_dxpl_id)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to create reference")
done:
@@ -404,166 +123,6 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5R_dereference
- PURPOSE
- Opens the HDF5 object referenced.
- USAGE
- hid_t H5R_dereference(ref)
- H5F_t *file; IN: File the object being dereferenced is within
- H5R_type_t ref_type; IN: Type of reference
- void *ref; IN: Reference to open.
-
- RETURNS
- Valid ID on success, Negative on failure
- DESCRIPTION
- Given a reference to some object, open that object and return an ID for
- that object.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- Currently only set up to work with references to datasets
- EXAMPLES
- REVISION LOG
- Raymond Lu
- 13 July 2011
- I added the OAPL_ID parameter for the object being referenced. It only
- supports dataset access property list currently.
-
- M. Scot Breitenfeld
- 3 March 2015
- Added a check for undefined reference pointer.
---------------------------------------------------------------------------*/
-hid_t
-H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, hbool_t app_ref)
-{
- H5O_loc_t oloc; /* Object location */
- H5G_name_t path; /* Path of object */
- H5G_loc_t loc; /* Group location */
- unsigned rc; /* Reference count of object */
- H5O_type_t obj_type; /* Type of object */
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- HDassert(_ref);
- HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE);
- HDassert(file);
-
- /* Initialize the object location */
- H5O_loc_reset(&oloc);
- oloc.file = file;
-
- switch(ref_type) {
- case H5R_OBJECT:
- oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */
- if(!H5F_addr_defined(oloc.addr) || oloc.addr == 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer")
- break;
-
- case H5R_DATASET_REGION:
- {
- H5HG_t hobjid; /* Heap object ID */
- uint8_t *buf; /* Buffer to store serialized selection in */
- const uint8_t *p; /* Pointer to OID to store */
-
- /* Get the heap ID for the dataset region */
- p = (const uint8_t *)_ref;
- H5F_addr_decode(oloc.file, &p, &(hobjid.addr));
- UINT32DECODE(p, hobjid.idx);
-
- if(!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer")
-
- /* Get the dataset region from the heap (allocate inside routine) */
- if(NULL == (buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)))
- HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information")
-
- /* Get the object oid for the dataset */
- p = buf;
- H5F_addr_decode(oloc.file, &p, &(oloc.addr));
-
- /* Free the buffer allocated in H5HG_read() */
- H5MM_xfree(buf);
- } /* end case */
- break;
-
- case H5R_BADTYPE:
- case H5R_MAXTYPE:
- default:
- HDassert("unknown reference type" && 0);
- HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
- } /* end switch */
-
- /* Get the # of links for object, and its type */
- /* (To check to make certain that this object hasn't been deleted since the reference was created) */
- if(H5O_get_rc_and_type(&oloc, dxpl_id, &rc, &obj_type) < 0 || 0 == rc)
- HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object")
-
- /* Construct a group location for opening the object */
- H5G_name_reset(&path);
- loc.oloc = &oloc;
- loc.path = &path;
-
- /* Open the object */
- switch(obj_type) {
- case H5O_TYPE_GROUP:
- {
- H5G_t *group; /* Pointer to group to open */
-
- if(NULL == (group = H5G_open(&loc, dxpl_id)))
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found")
-
- /* Create an atom for the group */
- if((ret_value = H5I_register(H5I_GROUP, group, app_ref)) < 0) {
- H5G_close(group);
- HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "can't register group")
- } /* end if */
- } /* end case */
- break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- {
- H5T_t *type; /* Pointer to datatype to open */
-
- if(NULL == (type = H5T_open(&loc, dxpl_id)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found")
-
- /* Create an atom for the datatype */
- if((ret_value = H5I_register(H5I_DATATYPE, type, app_ref)) < 0) {
- H5T_close(type);
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "can't register datatype")
- } /* end if */
- } /* end case */
- break;
-
- case H5O_TYPE_DATASET:
- {
- H5D_t *dset; /* Pointer to dataset to open */
-
- /* Open the dataset */
- if(NULL == (dset = H5D_open(&loc, oapl_id, dxpl_id)))
- HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found")
-
- /* Create an atom for the dataset */
- if((ret_value = H5I_register(H5I_DATASET, dset, app_ref)) < 0) {
- H5D_close(dset);
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset")
- } /* end if */
- } /* end case */
- break;
-
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, FAIL, "can't identify type of object referenced")
- } /* end switch */
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5R_dereference() */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5Rdereference2
PURPOSE
Opens the HDF5 object referenced.
@@ -601,24 +160,24 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r
H5TRACE4("i", "iiRt*x", obj_id, oapl_id, ref_type, _ref);
/* Check args */
- if(H5G_loc(obj_id, &loc) < 0)
+ if (H5G_loc(obj_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(oapl_id < 0)
+ if (oapl_id < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
- if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
+ if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
- if(_ref == NULL)
+ if (_ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
/* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&oapl_id, H5P_CLS_DACC, &dxpl_id, obj_id, FALSE) < 0)
+ if (H5P_verify_apl_and_dxpl(&oapl_id, H5P_CLS_DACC, &dxpl_id, obj_id, FALSE) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
/* Get the file pointer from the entry */
file = loc.oloc->file;
/* Create reference */
- if((ret_value = H5R_dereference(file, oapl_id, dxpl_id, ref_type, _ref, TRUE)) < 0)
+ if ((ret_value = H5R_dereference(file, oapl_id, dxpl_id, ref_type, _ref, TRUE)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object")
done:
@@ -628,75 +187,6 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5R_get_region
- PURPOSE
- Retrieves a dataspace with the region pointed to selected.
- USAGE
- H5S_t *H5R_get_region(file, ref_type, ref)
- H5F_t *file; IN: File the object being dereferenced is within
- void *ref; IN: Reference to open.
-
- RETURNS
- Pointer to the dataspace on success, NULL on failure
- DESCRIPTION
- Given a reference to some object, creates a copy of the dataset pointed
- to's dataspace and defines a selection in the copy which is the region
- pointed to.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static H5S_t *
-H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref)
-{
- H5O_loc_t oloc; /* Object location */
- const uint8_t *p; /* Pointer to OID to store */
- H5HG_t hobjid; /* Heap object ID */
- uint8_t *buf = NULL; /* Buffer to store serialized selection in */
- H5S_t *ret_value;
-
- FUNC_ENTER_NOAPI_NOINIT
-
- HDassert(_ref);
- HDassert(file);
-
- /* Initialize the object location */
- H5O_loc_reset(&oloc);
- oloc.file = file;
-
- /* Get the heap ID for the dataset region */
- p = (const uint8_t *)_ref;
- H5F_addr_decode(oloc.file, &p, &(hobjid.addr));
- UINT32DECODE(p, hobjid.idx);
-
- /* Get the dataset region from the heap (allocate inside routine) */
- if((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL)
- HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, NULL, "Unable to read dataset region information")
-
- /* Get the object oid for the dataset */
- p = buf;
- H5F_addr_decode(oloc.file, &p, &(oloc.addr));
-
- /* Open and copy the dataset's dataspace */
- if((ret_value = H5S_read(&oloc, dxpl_id)) == NULL)
- HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, NULL, "not found")
-
- /* Unserialize the selection */
- if(H5S_SELECT_DESERIALIZE(&ret_value, &p) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't deserialize selection")
-
-done:
- /* Free the buffer allocated in H5HG_read() */
- if(buf)
- H5MM_xfree(buf);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5R_get_region() */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5Rget_region
PURPOSE
Retrieves a dataspace with the region pointed to selected.
@@ -729,19 +219,19 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref)
H5TRACE3("i", "iRt*x", id, ref_type, ref);
/* Check args */
- if(H5G_loc(id, &loc) < 0)
+ if (H5G_loc(id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(ref_type != H5R_DATASET_REGION)
+ if (ref_type != H5R_DATASET_REGION)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
- if(ref == NULL)
+ if (ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
/* Get the dataspace with the correct region selected */
- if((space = H5R_get_region(loc.oloc->file, H5AC_ind_read_dxpl_id, ref)) == NULL)
+ if ((space = H5R_get_region(loc.oloc->file, H5AC_ind_read_dxpl_id, ref)) == NULL)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create dataspace")
/* Atomize */
- if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0)
+ if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom")
done:
@@ -751,92 +241,6 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5R_get_obj_type
- PURPOSE
- Retrieves the type of object that an object reference points to
- USAGE
- H5O_type_t H5R_get_obj_type(file, ref_type, ref)
- H5F_t *file; IN: File the object being dereferenced is within
- H5R_type_t ref_type; IN: Type of reference to query
- void *ref; IN: Reference to query.
-
- RETURNS
- Success: An object type defined in H5Gpublic.h
- Failure: H5G_UNKNOWN
- DESCRIPTION
- Given a reference to some object, this function returns the type of object
- pointed to.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type,
- const void *_ref, H5O_type_t *obj_type)
-{
- H5O_loc_t oloc; /* Object location */
- unsigned rc; /* Reference count of object */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- HDassert(file);
- HDassert(_ref);
-
- /* Initialize the symbol table entry */
- H5O_loc_reset(&oloc);
- oloc.file = file;
-
- switch(ref_type) {
- case H5R_OBJECT:
- /* Get the object oid */
- oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */
- break;
-
- case H5R_DATASET_REGION:
- {
- H5HG_t hobjid; /* Heap object ID */
- const uint8_t *p; /* Pointer to reference to decode */
- uint8_t *buf; /* Buffer to store serialized selection in */
-
- /* Get the heap ID for the dataset region */
- p = (const uint8_t *)_ref;
- H5F_addr_decode(oloc.file, &p, &(hobjid.addr));
- UINT32DECODE(p, hobjid.idx);
-
- /* Get the dataset region from the heap (allocate inside routine) */
- if((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL)
- HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information")
-
- /* Get the object oid for the dataset */
- p = buf;
- H5F_addr_decode(oloc.file, &p, &(oloc.addr));
-
- /* Free the buffer allocated in H5HG_read() */
- H5MM_xfree(buf);
- } /* end case */
- break;
-
- case H5R_BADTYPE:
- case H5R_MAXTYPE:
- default:
- HDassert("unknown reference type" && 0);
- HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
- } /* end switch */
-
- /* Get the # of links for object, and its type */
- /* (To check to make certain that this object hasn't been deleted since the reference was created) */
- if(H5O_get_rc_and_type(&oloc, dxpl_id, &rc, obj_type) < 0 || 0 == rc)
- HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5R_get_obj_type() */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5Rget_obj_type2
PURPOSE
Retrieves the type of object that an object reference points to
@@ -869,16 +273,16 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref,
H5TRACE4("e", "iRt*x*Ot", id, ref_type, ref, obj_type);
/* Check args */
- if(H5G_loc(id, &loc) < 0)
+ if (H5G_loc(id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
+ if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
- if(ref == NULL)
+ if (ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
/* Get the object information */
- if(H5R_get_obj_type(loc.oloc->file, H5AC_ind_read_dxpl_id, ref_type, ref, obj_type) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object type")
+ if (H5R_get_obj_type(loc.oloc->file, H5AC_ind_read_dxpl_id, ref_type, ref, obj_type) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object type")
done:
FUNC_LEAVE_API(ret_value)
@@ -887,106 +291,6 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5R_get_name
- PURPOSE
- Internal routine to determine a name for the object referenced
- USAGE
- ssize_t H5R_get_name(f, dxpl_id, ref_type, ref, name, size)
- H5F_t *f; IN: Pointer to the file that the reference is pointing
- into
- hid_t lapl_id; IN: LAPL to use for operation
- hid_t dxpl_id; IN: DXPL to use for operation
- hid_t id; IN: Location ID given for reference
- H5R_type_t ref_type; IN: Type of reference
- void *ref; IN: Reference to query.
- char *name; OUT: Buffer to place name of object referenced
- size_t size; IN: Size of name buffer
-
- RETURNS
- Non-negative length of the path on success, Negative on failure
- DESCRIPTION
- Given a reference to some object, determine a path to the object
- referenced in the file.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- This may not be the only path to that object.
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static ssize_t
-H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type,
- const void *_ref, char *name, size_t size)
-{
- hid_t file_id = H5I_INVALID_HID; /* ID for file that the reference is in */
- H5O_loc_t oloc; /* Object location describing object for reference */
- ssize_t ret_value = -1; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check args */
- HDassert(f);
- HDassert(_ref);
-
- /* Initialize the object location */
- H5O_loc_reset(&oloc);
- oloc.file = f;
-
- /* Get address for reference */
- switch(ref_type) {
- case H5R_OBJECT:
- oloc.addr = *(const hobj_ref_t *)_ref;
- break;
-
- case H5R_DATASET_REGION:
- {
- H5HG_t hobjid; /* Heap object ID */
- uint8_t *buf; /* Buffer to store serialized selection in */
- const uint8_t *p; /* Pointer to OID to store */
-
- /* Get the heap ID for the dataset region */
- p = (const uint8_t *)_ref;
- H5F_addr_decode(oloc.file, &p, &(hobjid.addr));
- UINT32DECODE(p, hobjid.idx);
-
- /* Get the dataset region from the heap (allocate inside routine) */
- if((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL)
- HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information")
-
- /* Get the object oid for the dataset */
- p = buf;
- H5F_addr_decode(oloc.file, &p, &(oloc.addr));
-
- /* Free the buffer allocated in H5HG_read() */
- H5MM_xfree(buf);
- } /* end case */
- break;
-
- case H5R_BADTYPE:
- case H5R_MAXTYPE:
- default:
- HDassert("unknown reference type" && 0);
- HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
- } /* end switch */
-
- /* Retrieve file ID for name search */
- if((file_id = H5I_get_file_id(id, FALSE)) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID")
-
- /* Get name, length, etc. */
- if((ret_value = H5G_get_name_by_addr(file_id, lapl_id, dxpl_id, &oloc, name, size)) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't determine name")
-
-done:
- /* Close file ID used for search */
- if(file_id > 0 && H5I_dec_ref(file_id) < 0)
- HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5R_get_name() */
-
-
-/*--------------------------------------------------------------------------
- NAME
H5Rget_name
PURPOSE
Determines a name for the object referenced
@@ -1030,18 +334,18 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name,
H5TRACE5("Zs", "iRt*x*sz", id, ref_type, _ref, name, size);
/* Check args */
- if(H5G_loc(id, &loc) < 0)
+ if (H5G_loc(id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
+ if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
- if(_ref == NULL)
+ if (_ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
/* Get the file pointer from the entry */
file = loc.oloc->file;
/* Get name */
- if((ret_value = H5R_get_name(file, H5P_DEFAULT, H5AC_ind_read_dxpl_id, id, ref_type, _ref, name, size)) < 0)
+ if ((ret_value = H5R_get_name(file, H5P_DEFAULT, H5AC_ind_read_dxpl_id, id, ref_type, _ref, name, size)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object path")
done:
diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c
index 109bbb4..699f8df 100644
--- a/src/H5Rdeprec.c
+++ b/src/H5Rdeprec.c
@@ -13,11 +13,9 @@
/*-------------------------------------------------------------------------
*
- * Created: H5Rdeprec.c
- * September 13 2007
- * Quincey Koziol <koziol@hdfgroup.org>
+ * Created: H5Rdeprec.c
*
- * Purpose: Deprecated functions from the H5R interface. These
+ * Purpose: Deprecated functions from the H5R interface. These
* functions are here for compatibility purposes and may be
* removed in the future. Applications should switch to the
* newer APIs.
@@ -35,13 +33,16 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5ACprivate.h" /* Metadata cache */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Gprivate.h" /* Groups */
-#include "H5Oprivate.h" /* Object headers */
-#include "H5Rpkg.h" /* References */
-#include "H5Ppublic.h" /* for using H5P_DATASET_ACCESS_DEFAULT */
+/* Public headers needed by this file */
+#include "H5Ppublic.h" /* Property lists */
+
+/* Private headers needed by this file */
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Gprivate.h" /* Groups */
+#include "H5Oprivate.h" /* Object headers */
+#include "H5Rpkg.h" /* References */
/****************/
@@ -81,29 +82,22 @@
#ifndef H5_NO_DEPRECATED_SYMBOLS
-/*--------------------------------------------------------------------------
- NAME
- H5Rget_obj_type1
- PURPOSE
- Retrieves the type of object that an object reference points to
- USAGE
- H5G_obj_t H5Rget_obj_type1(id, ref_type, ref)
- hid_t id; IN: Dataset reference object is in or location ID of
- object that the dataset is located within.
- H5R_type_t ref_type; IN: Type of reference to query
- void *ref; IN: Reference to query.
-
- RETURNS
- Success: An object type defined in H5Gpublic.h
- Failure: H5G_UNKNOWN
- DESCRIPTION
- Given a reference to some object, this function returns the type of object
- pointed to.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------
+ * Function: H5Rget_obj_type1
+ *
+ * Purpose: Retrieves the type of the object that an object points to.
+ *
+ * Parameters:
+ * id IN: Dataset reference object is in or location ID of
+ * object that the dataset is located within
+ * ref_type IN: Type of reference to query
+ * ref IN: Reference to query
+ *
+ * Return: Success: An object type (as defined in H5Gpublic.h)
+ * Failure: H5G_UNKNOWN
+ *
+ *-------------------------------------------------------------------------
+ */
H5G_obj_t
H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref)
{
@@ -115,16 +109,16 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref)
H5TRACE3("Go", "iRt*x", id, ref_type, ref);
/* Check args */
- if(H5G_loc(id, &loc) < 0)
+ if (H5G_loc(id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location")
- if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
+ if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference type")
- if(ref == NULL)
+ if (ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer")
/* Get the object information */
- if(H5R_get_obj_type(loc.oloc->file, H5AC_ind_read_dxpl_id, ref_type, ref, &obj_type) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type")
+ if (H5R_get_obj_type(loc.oloc->file, H5AC_ind_read_dxpl_id, ref_type, ref, &obj_type) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type")
/* Set return value */
ret_value = H5G_map_obj_type(obj_type);
@@ -134,28 +128,22 @@ done:
} /* end H5Rget_obj_type1() */
-/*--------------------------------------------------------------------------
- NAME
- H5Rdereference1
- PURPOSE
- Opens the HDF5 object referenced.
- USAGE
- hid_t H5Rdereference1(ref)
- hid_t id; IN: Dataset reference object is in or location ID of
- object that the dataset is located within.
- H5R_type_t ref_type; IN: Type of reference to create
- void *ref; IN: Reference to open.
-
- RETURNS
- Valid ID on success, Negative on failure
- DESCRIPTION
- Given a reference to some object, open that object and return an ID for
- that object.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------
+ * Function: H5Rdereference1
+ *
+ * Purpose: Opens the HDF5 object referenced.
+ *
+ * Parameters:
+ * id IN: Dataset reference object is in or location ID of
+ * object that the dataset is located within
+ * ref_type IN: Type of reference to create
+ * ref IN: Reference to open
+ *
+ * Return: Success: Valid HDF5 ID
+ * Failure: Negative
+ *
+ *-------------------------------------------------------------------------
+ */
hid_t
H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref)
{
@@ -167,18 +155,18 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref)
H5TRACE3("i", "iRt*x", obj_id, ref_type, _ref);
/* Check args */
- if(H5G_loc(obj_id, &loc) < 0)
+ if (H5G_loc(obj_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
+ if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type")
- if(_ref == NULL)
+ if (_ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
/* Get the file pointer from the entry */
file = loc.oloc->file;
/* Create reference */
- if((ret_value = H5R_dereference(file, H5P_DATASET_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id, ref_type, _ref, TRUE)) < 0)
+ if ((ret_value = H5R_dereference(file, H5P_DATASET_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id, ref_type, _ref, TRUE)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object")
done:
diff --git a/src/H5Rint.c b/src/H5Rint.c
new file mode 100644
index 0000000..716a573
--- /dev/null
+++ b/src/H5Rint.c
@@ -0,0 +1,767 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/****************/
+/* Module Setup */
+/****************/
+
+#include "H5Rmodule.h" /* This source code file is part of the H5R module */
+
+
+/***********/
+/* Headers */
+/***********/
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Dprivate.h" /* Datasets */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Gprivate.h" /* Groups */
+#include "H5HGprivate.h" /* Global Heaps */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Oprivate.h" /* Object headers */
+#include "H5Rpkg.h" /* References */
+#include "H5Sprivate.h" /* Dataspaces */
+#include "H5Tprivate.h" /* Datatypes */
+
+
+/****************/
+/* Local Macros */
+/****************/
+
+/******************/
+/* Local Typedefs */
+/******************/
+
+/********************/
+/* Local Prototypes */
+/********************/
+
+/*********************/
+/* Package Variables */
+/*********************/
+
+/* Package initialization variable */
+hbool_t H5_PKG_INIT_VAR = FALSE;
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+/*******************/
+/* Local Variables */
+/*******************/
+
+/* Reference ID class
+ *
+ * NOTE: H5I_REFERENCE is not used by the library and has been deprecated
+ * with a tentative removal version of 1.12.0. (DER, July 2017)
+ */
+static const H5I_class_t H5I_REFERENCE_CLS[1] = {{
+ H5I_REFERENCE, /* ID class value */
+ 0, /* Class flags */
+ 0, /* # of reserved IDs for class */
+ NULL /* Callback routine for closing objects of this class */
+}};
+
+/* Flag indicating "top" of interface has been initialized */
+static hbool_t H5R_top_package_initialize_s = FALSE;
+
+
+/*--------------------------------------------------------------------------
+NAME
+ H5R__init_package -- Initialize interface-specific information
+USAGE
+ herr_t H5R__init_package()
+
+RETURNS
+ Non-negative on success/Negative on failure
+DESCRIPTION
+ Initializes any interface-specific data or routines.
+
+--------------------------------------------------------------------------*/
+herr_t
+H5R__init_package(void)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Initialize the atom group for the file IDs */
+ if (H5I_register_type(H5I_REFERENCE_CLS) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface")
+
+ /* Mark "top" of interface as initialized, too */
+ H5R_top_package_initialize_s = TRUE;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5R__init_package() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5R_top_term_package
+ PURPOSE
+ Terminate various H5R objects
+ USAGE
+ void H5R_top_term_package()
+ RETURNS
+ void
+ DESCRIPTION
+ Release IDs for the atom group, deferring full interface shutdown
+ until later (in H5R_term_package).
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ Can't report errors...
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+int
+H5R_top_term_package(void)
+{
+ int n = 0;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ if (H5R_top_package_initialize_s) {
+ if (H5I_nmembers(H5I_REFERENCE) > 0) {
+ (void)H5I_clear_type(H5I_REFERENCE, FALSE, FALSE);
+ n++;
+ }
+
+ /* Mark closed */
+ if (0 == n)
+ H5R_top_package_initialize_s = FALSE;
+ }
+
+ FUNC_LEAVE_NOAPI(n)
+} /* end H5R_top_term_package() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5R_term_package
+ PURPOSE
+ Terminate various H5R objects
+ USAGE
+ void H5R_term_package()
+ RETURNS
+ void
+ DESCRIPTION
+ Release the atom group and any other resources allocated.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ Can't report errors...
+
+ Finishes shutting down the interface, after H5R_top_term_package()
+ is called
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+int
+H5R_term_package(void)
+{
+ int n = 0;
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ if (H5_PKG_INIT_VAR) {
+ /* Sanity checks */
+ HDassert(0 == H5I_nmembers(H5I_REFERENCE));
+ HDassert(FALSE == H5R_top_package_initialize_s);
+
+ /* Destroy the reference id group */
+ n += (H5I_dec_type_ref(H5I_REFERENCE) > 0);
+
+ /* Mark closed */
+ if (0 == n)
+ H5_PKG_INIT_VAR = FALSE;
+ }
+
+ FUNC_LEAVE_NOAPI(n)
+} /* end H5R_term_package() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5R_create
+ PURPOSE
+ Creates a particular kind of reference for the user
+ USAGE
+ herr_t H5R_create(ref, loc, name, ref_type, space)
+ void *ref; OUT: Reference created
+ H5G_loc_t *loc; IN: File location used to locate object pointed to
+ const char *name; IN: Name of object at location LOC_ID of object
+ pointed to
+ H5R_type_t ref_type; IN: Type of reference to create
+ H5S_t *space; IN: Dataspace ID with selection, used for Dataset
+ Region references.
+
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ Creates a particular type of reference specified with REF_TYPE, in the
+ space pointed to by REF. The LOC_ID and NAME are used to locate the object
+ pointed to and the SPACE_ID is used to choose the region pointed to (for
+ Dataset Region references).
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id)
+{
+ H5G_loc_t obj_loc; /* Group hier. location of object */
+ H5G_name_t path; /* Object group hier. path */
+ H5O_loc_t oloc; /* Object object location */
+ hbool_t obj_found = FALSE; /* Object location found */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(_ref);
+ HDassert(loc);
+ HDassert(name);
+ HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE);
+
+ /* Set up object location to fill in */
+ obj_loc.oloc = &oloc;
+ obj_loc.path = &path;
+ H5G_loc_reset(&obj_loc);
+
+ /* Find the object */
+ if (H5G_loc_find(loc, name, &obj_loc, H5P_DEFAULT, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "object not found")
+ obj_found = TRUE;
+
+ switch (ref_type) {
+ case H5R_OBJECT:
+ {
+ hobj_ref_t *ref = (hobj_ref_t *)_ref; /* Get pointer to correct type of reference struct */
+
+ *ref = obj_loc.oloc->addr;
+ break;
+ }
+
+ case H5R_DATASET_REGION:
+ {
+ H5HG_t hobjid; /* Heap object ID */
+ hdset_reg_ref_t *ref = (hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */
+ hssize_t buf_size; /* Size of buffer needed to serialize selection */
+ uint8_t *p; /* Pointer to OID to store */
+ uint8_t *buf; /* Buffer to store serialized selection in */
+ unsigned heapid_found; /* Flag for non-zero heap ID found */
+ unsigned u; /* local index */
+
+ /* Set up information for dataset region */
+
+ /* Return any previous heap block to the free list if we are
+ * garbage collecting
+ */
+ if (H5F_GC_REF(loc->oloc->file)) {
+ /* Check for an existing heap ID in the reference */
+ for (u = 0, heapid_found = 0, p = (uint8_t *)ref; u < H5R_DSET_REG_REF_BUF_SIZE; u++)
+ if (p[u] != 0) {
+ heapid_found = 1;
+ break;
+ }
+
+ if (heapid_found != 0) {
+ /* Return heap block to free list */
+ }
+ }
+
+ /* Zero the heap ID out, may leak heap space if user is re-using
+ * reference and doesn't have garbage collection turned on
+ */
+ HDmemset(ref, 0, H5R_DSET_REG_REF_BUF_SIZE);
+
+ /* Get the amount of space required to serialize the selection */
+ if ((buf_size = H5S_SELECT_SERIAL_SIZE(space)) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "Invalid amount of space for serializing selection")
+
+ /* Increase buffer size to allow for the dataset OID */
+ buf_size += (hssize_t)sizeof(haddr_t);
+
+ /* Allocate the space to store the serialized information */
+ H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t);
+ if (NULL == (buf = (uint8_t *)H5MM_malloc((size_t)buf_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ /* Serialize information for dataset OID into heap buffer */
+ p = (uint8_t *)buf;
+ H5F_addr_encode(loc->oloc->file, &p, obj_loc.oloc->addr);
+
+ /* Serialize the selection into heap buffer */
+ if (H5S_SELECT_SERIALIZE(space, &p) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection")
+
+ /* Save the serialized buffer for later */
+ H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t);
+ if (H5HG_insert(loc->oloc->file, dxpl_id, (size_t)buf_size, buf, &hobjid) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to serialize selection")
+
+ /* Serialize the heap ID and index for storage in the file */
+ p = (uint8_t *)ref;
+ H5F_addr_encode(loc->oloc->file, &p, hobjid.addr);
+ UINT32ENCODE(p, hobjid.idx);
+
+ /* Free the buffer we serialized data in */
+ H5MM_xfree(buf);
+ break;
+ } /* end case H5R_DATASET_REGION */
+
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ HDassert("unknown reference type" && 0);
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
+ } /* end switch */
+
+done:
+ if (obj_found)
+ H5G_loc_free(&obj_loc);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5R_create() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5R_dereference
+ PURPOSE
+ Opens the HDF5 object referenced.
+ USAGE
+ hid_t H5R_dereference(ref)
+ H5F_t *file; IN: File the object being dereferenced is within
+ H5R_type_t ref_type; IN: Type of reference
+ void *ref; IN: Reference to open.
+
+ RETURNS
+ Valid ID on success, Negative on failure
+ DESCRIPTION
+ Given a reference to some object, open that object and return an ID for
+ that object.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ Currently only set up to work with references to datasets
+ EXAMPLES
+ REVISION LOG
+ Raymond Lu
+ 13 July 2011
+ I added the OAPL_ID parameter for the object being referenced. It only
+ supports dataset access property list currently.
+
+ M. Scot Breitenfeld
+ 3 March 2015
+ Added a check for undefined reference pointer.
+--------------------------------------------------------------------------*/
+hid_t
+H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, hbool_t app_ref)
+{
+ H5O_loc_t oloc; /* Object location */
+ H5G_name_t path; /* Path of object */
+ H5G_loc_t loc; /* Group location */
+ unsigned rc; /* Reference count of object */
+ H5O_type_t obj_type; /* Type of object */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(_ref);
+ HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE);
+ HDassert(file);
+
+ /* Initialize the object location */
+ H5O_loc_reset(&oloc);
+ oloc.file = file;
+
+ switch (ref_type) {
+ case H5R_OBJECT:
+ {
+ oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */
+ if (!H5F_addr_defined(oloc.addr) || oloc.addr == 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer")
+ break;
+ }
+
+ case H5R_DATASET_REGION:
+ {
+ H5HG_t hobjid; /* Heap object ID */
+ uint8_t *buf; /* Buffer to store serialized selection in */
+ const uint8_t *p; /* Pointer to OID to store */
+
+ /* Get the heap ID for the dataset region */
+ p = (const uint8_t *)_ref;
+ H5F_addr_decode(oloc.file, &p, &(hobjid.addr));
+ UINT32DECODE(p, hobjid.idx);
+
+ if (!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer")
+
+ /* Get the dataset region from the heap (allocate inside routine) */
+ if (NULL == (buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)))
+ HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information")
+
+ /* Get the object oid for the dataset */
+ p = buf;
+ H5F_addr_decode(oloc.file, &p, &(oloc.addr));
+
+ /* Free the buffer allocated in H5HG_read() */
+ H5MM_xfree(buf);
+ break;
+ } /* end case H5R_DATASET_REGION */
+
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ HDassert("unknown reference type" && 0);
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
+ } /* end switch */
+
+ /* Get the # of links for object, and its type
+ * (To check to make certain that this object hasn't been deleted
+ * since the reference was created)
+ */
+ if (H5O_get_rc_and_type(&oloc, dxpl_id, &rc, &obj_type) < 0 || 0 == rc)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object")
+
+ /* Construct a group location for opening the object */
+ H5G_name_reset(&path);
+ loc.oloc = &oloc;
+ loc.path = &path;
+
+ /* Open the object */
+ switch (obj_type) {
+ case H5O_TYPE_GROUP:
+ {
+ H5G_t *group; /* Pointer to group to open */
+
+ if (NULL == (group = H5G_open(&loc, dxpl_id)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found")
+
+ /* Create an atom for the group */
+ if ((ret_value = H5I_register(H5I_GROUP, group, app_ref)) < 0) {
+ H5G_close(group);
+ HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "can't register group")
+ }
+
+ break;
+ }
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ {
+ H5T_t *type; /* Pointer to datatype to open */
+
+ if (NULL == (type = H5T_open(&loc, dxpl_id)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found")
+
+ /* Create an atom for the datatype */
+ if ((ret_value = H5I_register(H5I_DATATYPE, type, app_ref)) < 0) {
+ H5T_close(type);
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "can't register datatype")
+ }
+
+ break;
+ }
+
+ case H5O_TYPE_DATASET:
+ {
+ H5D_t *dset; /* Pointer to dataset to open */
+
+ /* Open the dataset */
+ if (NULL == (dset = H5D_open(&loc, oapl_id, dxpl_id)))
+ HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found")
+
+ /* Create an atom for the dataset */
+ if ((ret_value = H5I_register(H5I_DATASET, dset, app_ref)) < 0) {
+ H5D_close(dset);
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset")
+ }
+
+ break;
+ }
+
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, FAIL, "can't identify type of object referenced")
+ } /* end switch */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5R_dereference() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5R_get_region
+ PURPOSE
+ Retrieves a dataspace with the region pointed to selected.
+ USAGE
+ H5S_t *H5R_get_region(file, ref_type, ref)
+ H5F_t *file; IN: File the object being dereferenced is within
+ void *ref; IN: Reference to open.
+
+ RETURNS
+ Pointer to the dataspace on success, NULL on failure
+ DESCRIPTION
+ Given a reference to some object, creates a copy of the dataset pointed
+ to's dataspace and defines a selection in the copy which is the region
+ pointed to.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+H5S_t *
+H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref)
+{
+ H5O_loc_t oloc; /* Object location */
+ const uint8_t *p; /* Pointer to OID to store */
+ H5HG_t hobjid; /* Heap object ID */
+ uint8_t *buf = NULL; /* Buffer to store serialized selection in */
+ H5S_t *ret_value;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(_ref);
+ HDassert(file);
+
+ /* Initialize the object location */
+ H5O_loc_reset(&oloc);
+ oloc.file = file;
+
+ /* Get the heap ID for the dataset region */
+ p = (const uint8_t *)_ref;
+ H5F_addr_decode(oloc.file, &p, &(hobjid.addr));
+ UINT32DECODE(p, hobjid.idx);
+
+ /* Get the dataset region from the heap (allocate inside routine) */
+ if ((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, NULL, "Unable to read dataset region information")
+
+ /* Get the object oid for the dataset */
+ p = buf;
+ H5F_addr_decode(oloc.file, &p, &(oloc.addr));
+
+ /* Open and copy the dataset's dataspace */
+ if ((ret_value = H5S_read(&oloc, dxpl_id)) == NULL)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, NULL, "not found")
+
+ /* Unserialize the selection */
+ if (H5S_SELECT_DESERIALIZE(&ret_value, &p) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't deserialize selection")
+
+done:
+ /* Free the buffer allocated in H5HG_read() */
+ if (buf)
+ H5MM_xfree(buf);
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5R_get_region() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5R_get_obj_type
+ PURPOSE
+ Retrieves the type of object that an object reference points to
+ USAGE
+ H5O_type_t H5R_get_obj_type(file, ref_type, ref)
+ H5F_t *file; IN: File the object being dereferenced is within
+ H5R_type_t ref_type; IN: Type of reference to query
+ void *ref; IN: Reference to query.
+
+ RETURNS
+ Success: An object type defined in H5Gpublic.h
+ Failure: H5G_UNKNOWN
+ DESCRIPTION
+ Given a reference to some object, this function returns the type of object
+ pointed to.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type,
+ const void *_ref, H5O_type_t *obj_type)
+{
+ H5O_loc_t oloc; /* Object location */
+ unsigned rc; /* Reference count of object */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(file);
+ HDassert(_ref);
+
+ /* Initialize the symbol table entry */
+ H5O_loc_reset(&oloc);
+ oloc.file = file;
+
+ switch (ref_type) {
+ case H5R_OBJECT:
+ {
+ /* Get the object oid */
+ oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */
+ break;
+ }
+
+ case H5R_DATASET_REGION:
+ {
+ H5HG_t hobjid; /* Heap object ID */
+ const uint8_t *p; /* Pointer to reference to decode */
+ uint8_t *buf; /* Buffer to store serialized selection in */
+
+ /* Get the heap ID for the dataset region */
+ p = (const uint8_t *)_ref;
+ H5F_addr_decode(oloc.file, &p, &(hobjid.addr));
+ UINT32DECODE(p, hobjid.idx);
+
+ /* Get the dataset region from the heap (allocate inside routine) */
+ if ((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information")
+
+ /* Get the object oid for the dataset */
+ p = buf;
+ H5F_addr_decode(oloc.file, &p, &(oloc.addr));
+
+ /* Free the buffer allocated in H5HG_read() */
+ H5MM_xfree(buf);
+
+ break;
+ }
+
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ HDassert("unknown reference type" && 0);
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
+ } /* end switch */
+
+ /* Get the # of links for object, and its type */
+ /* (To check to make certain that this object hasn't been deleted since the reference was created) */
+ if (H5O_get_rc_and_type(&oloc, dxpl_id, &rc, obj_type) < 0 || 0 == rc)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5R_get_obj_type() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5R_get_name
+ PURPOSE
+ Internal routine to determine a name for the object referenced
+ USAGE
+ ssize_t H5R_get_name(f, dxpl_id, ref_type, ref, name, size)
+ H5F_t *f; IN: Pointer to the file that the reference is pointing
+ into
+ hid_t lapl_id; IN: LAPL to use for operation
+ hid_t dxpl_id; IN: DXPL to use for operation
+ hid_t id; IN: Location ID given for reference
+ H5R_type_t ref_type; IN: Type of reference
+ void *ref; IN: Reference to query.
+ char *name; OUT: Buffer to place name of object referenced
+ size_t size; IN: Size of name buffer
+
+ RETURNS
+ Non-negative length of the path on success, Negative on failure
+ DESCRIPTION
+ Given a reference to some object, determine a path to the object
+ referenced in the file.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ This may not be the only path to that object.
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+ssize_t
+H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type,
+ const void *_ref, char *name, size_t size)
+{
+ hid_t file_id = H5I_INVALID_HID; /* ID for file that the reference is in */
+ H5O_loc_t oloc; /* Object location describing object for reference */
+ ssize_t ret_value = -1; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Check args */
+ HDassert(f);
+ HDassert(_ref);
+
+ /* Initialize the object location */
+ H5O_loc_reset(&oloc);
+ oloc.file = f;
+
+ /* Get address for reference */
+ switch (ref_type) {
+ case H5R_OBJECT:
+ {
+ oloc.addr = *(const hobj_ref_t *)_ref;
+ break;
+ }
+
+ case H5R_DATASET_REGION:
+ {
+ H5HG_t hobjid; /* Heap object ID */
+ uint8_t *buf; /* Buffer to store serialized selection in */
+ const uint8_t *p; /* Pointer to OID to store */
+
+ /* Get the heap ID for the dataset region */
+ p = (const uint8_t *)_ref;
+ H5F_addr_decode(oloc.file, &p, &(hobjid.addr));
+ UINT32DECODE(p, hobjid.idx);
+
+ /* Get the dataset region from the heap (allocate inside routine) */
+ if ((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information")
+
+ /* Get the object oid for the dataset */
+ p = buf;
+ H5F_addr_decode(oloc.file, &p, &(oloc.addr));
+
+ /* Free the buffer allocated in H5HG_read() */
+ H5MM_xfree(buf);
+
+ break;
+ }
+
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ HDassert("unknown reference type" && 0);
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
+ } /* end switch */
+
+ /* Retrieve file ID for name search */
+ if ((file_id = H5I_get_file_id(id, FALSE)) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID")
+
+ /* Get name, length, etc. */
+ if ((ret_value = H5G_get_name_by_addr(file_id, lapl_id, dxpl_id, &oloc, name, size)) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't determine name")
+
+done:
+ /* Close file ID used for search */
+ if (file_id > 0 && H5I_dec_ref(file_id) < 0)
+ HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID")
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5R_get_name() */
+
diff --git a/src/H5Rmodule.h b/src/H5Rmodule.h
index 2eaf050..678a668 100644
--- a/src/H5Rmodule.h
+++ b/src/H5Rmodule.h
@@ -10,13 +10,9 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * Programmer: Quincey Koziol <koziol@hdfgroup.org>
- * Saturday, September 12, 2015
- *
- * Purpose: This file contains declarations which define macros for the
- * H5R package. Including this header means that the source file
- * is part of the H5R package.
+/* Purpose: This file contains declarations which define macros for the
+ * H5R package. Including this header means that the source file
+ * is part of the H5R package.
*/
#ifndef _H5Rmodule_H
#define _H5Rmodule_H
@@ -31,4 +27,3 @@
#endif /* _H5Rmodule_H */
-
diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h
index 6d5036b..129f944 100644
--- a/src/H5Rpkg.h
+++ b/src/H5Rpkg.h
@@ -11,11 +11,7 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/*
- * Programmer: Quincey Koziol <koziol@hdfgroup.org>
- * Thursday, September 13, 2007
- *
- * Purpose: This file contains declarations which are visible
+/* Purpose: This file contains declarations which are visible
* only within the H5R package. Source files outside the
* H5R package should include H5Rprivate.h instead.
*/
@@ -30,7 +26,6 @@
#include "H5Rprivate.h"
/* Other private headers needed by this file */
-#include "H5Fprivate.h" /* File access */
/**************************/
/* Package Private Macros */
@@ -51,12 +46,5 @@
/* Package Private Prototypes */
/******************************/
-/* General functions */
-H5_DLL herr_t H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type,
- const void *_ref, H5O_type_t *obj_type);
-H5_DLL hid_t H5R_dereference(H5F_t *file, hid_t dapl_id, hid_t dxpl_id, H5R_type_t ref_type,
- const void *_ref, hbool_t app_ref);
-
-
#endif /* _H5Rpkg_H */
diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h
index 7efa225..35e63d2 100644
--- a/src/H5Rprivate.h
+++ b/src/H5Rprivate.h
@@ -20,10 +20,40 @@
#include "H5Rpublic.h"
/* Private headers needed by this file */
+#include "H5Fprivate.h" /* Files */
+#include "H5Gprivate.h" /* Groups */
+#include "H5Oprivate.h" /* Object headers */
+#include "H5Sprivate.h" /* Dataspaces */
-/* Internal data structures */
-/* Private functions */
+/**************************/
+/* Library Private Macros */
+/**************************/
+
+
+/****************************/
+/* Library Private Typedefs */
+/****************************/
+
+
+/*****************************/
+/* Library Private Variables */
+/*****************************/
+
+
+/******************************/
+/* Library Private Prototypes */
+/******************************/
+
+H5_DLL herr_t H5R_create(void *ref, H5G_loc_t *loc, const char *name,
+ H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id);
+H5_DLL H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref);
+H5_DLL ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id,
+ H5R_type_t ref_type, const void *_ref, char *name, size_t size);
+H5_DLL herr_t H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type,
+ const void *_ref, H5O_type_t *obj_type);
+H5_DLL hid_t H5R_dereference(H5F_t *file, hid_t dapl_id, hid_t dxpl_id, H5R_type_t ref_type,
+ const void *_ref, hbool_t app_ref);
#endif /* _H5Rprivate_H */
diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h
index 446b7cd..598bafd 100644
--- a/src/H5Rpublic.h
+++ b/src/H5Rpublic.h
@@ -22,40 +22,59 @@
#include "H5Gpublic.h"
#include "H5Ipublic.h"
-/*
- * Reference types allowed.
- */
-typedef enum {
- H5R_BADTYPE = (-1), /*invalid Reference Type */
- H5R_OBJECT, /*Object reference */
- H5R_DATASET_REGION, /*Dataset Region Reference */
- H5R_MAXTYPE /*highest type (Invalid as true type) */
-} H5R_type_t;
+/*****************/
+/* Public Macros */
+/*****************/
/* Note! Be careful with the sizes of the references because they should really
* depend on the run-time values in the file. Unfortunately, the arrays need
- * to be defined at compile-time, so we have to go with the worst case sizes for
- * them. -QAK
+ * to be defined at compile-time, so we have to go with the worst case sizes
+ * for them. -QAK
+ */
+#define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t)
+
+/* 4 is used instead of sizeof(int) to permit portability between the Crays
+ * and other machines (the heap ID is always encoded as an int32 anyway).
+ */
+#define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t) + 4)
+
+/*******************/
+/* Public Typedefs */
+/*******************/
+
+/* Reference types */
+typedef enum H5R_type_t {
+ H5R_BADTYPE = (-1), /* Invalid Reference Type */
+ H5R_OBJECT, /* Object reference */
+ H5R_DATASET_REGION, /* Dataset Region Reference */
+ H5R_MAXTYPE /* Highest type (Invalid as true type) */
+} H5R_type_t;
+
+/* Object reference structure for user's code
+ * This needs to be large enough to store largest haddr_t on a worst case
+ * machine (8 bytes currently).
+ */
+typedef haddr_t hobj_ref_t;
+
+/* Dataset Region reference structure for user's code
+ * (Buffer to store heap ID and index)
+ * This needs to be large enough to store largest haddr_t in a worst case
+ * machine (8 bytes currently) plus an int
*/
-#define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t)
-/* Object reference structure for user's code */
-typedef haddr_t hobj_ref_t; /* Needs to be large enough to store largest haddr_t in a worst case machine (ie. 8 bytes currently) */
+typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE];
-#define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t)+4)
-/* 4 is used instead of sizeof(int) to permit portability between
- the Crays and other machines (the heap ID is always encoded as an int32 anyway)
-*/
-/* Dataset Region reference structure for user's code */
-typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE];/* Buffer to store heap ID and index */
-/* Needs to be large enough to store largest haddr_t in a worst case machine (ie. 8 bytes currently) plus an int */
+/********************/
+/* Public Variables */
+/********************/
-/* Publicly visible data structures */
+/*********************/
+/* Public Prototypes */
+/*********************/
#ifdef __cplusplus
extern "C" {
#endif
-/* Functions in H5R.c */
H5_DLL herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name,
H5R_type_t ref_type, hid_t space_id);
H5_DLL hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref);
@@ -63,7 +82,7 @@ H5_DLL hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, const void *ref);
H5_DLL herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *_ref,
H5O_type_t *obj_type);
H5_DLL ssize_t H5Rget_name(hid_t loc_id, H5R_type_t ref_type, const void *ref,
- char *name/*out*/, size_t size);
+ char *name /*out*/, size_t size);
/* Symbols defined for compatibility with previous versions of the HDF5 API.
*
@@ -71,12 +90,6 @@ H5_DLL ssize_t H5Rget_name(hid_t loc_id, H5R_type_t ref_type, const void *ref,
*/
#ifndef H5_NO_DEPRECATED_SYMBOLS
-/* Macros */
-
-
-/* Typedefs */
-
-
/* Function prototypes */
H5_DLL H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *_ref);
H5_DLL hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref);
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index 11fb7fe..068283a 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -17,6 +17,9 @@
#ifndef _H5Sprivate_H
#define _H5Sprivate_H
+/* Early typedefs to avoid circular dependencies */
+typedef struct H5S_t H5S_t;
+
/* Include package's public header */
#include "H5Spublic.h"
@@ -44,7 +47,6 @@
#define H5S_GET_SEQ_LIST_SORTED 0x0001
/* Forward references of package typedefs */
-typedef struct H5S_t H5S_t;
typedef struct H5S_extent_t H5S_extent_t;
typedef struct H5S_pnt_node_t H5S_pnt_node_t;
typedef struct H5S_hyper_span_t H5S_hyper_span_t;
diff --git a/src/H5Tdbg.c b/src/H5Tdbg.c
index f434543..eb648f3 100644
--- a/src/H5Tdbg.c
+++ b/src/H5Tdbg.c
@@ -32,9 +32,9 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Tpkg.h" /* Datatypes */
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Tpkg.h" /* Datatypes */
/****************/
@@ -74,28 +74,21 @@
/*-------------------------------------------------------------------------
- * Function: H5T__print_stats
+ * Function: H5T__print_stats
*
- * Purpose: Print statistics about a conversion path. Statistics are
- * printed only if all the following conditions are true:
+ * Purpose: Print statistics about a conversion path. Statistics are
+ * printed only if all the following conditions are true:
*
- * 1. The library was compiled with H5T_DEBUG defined.
- * 2. Data type debugging is turned on at run time.
- * 3. The path was called at least one time.
+ * 1. The library was compiled with H5T_DEBUG defined.
+ * 2. Data type debugging is turned on at run time.
+ * 3. The path was called at least one time.
*
- * The optional NPRINT argument keeps track of the number of
- * conversions paths for which statistics have been shown. If
- * its value is zero then table headers are printed before the
- * first line of output.
+ * The optional NPRINT argument keeps track of the number of
+ * conversions paths for which statistics have been shown. If
+ * its value is zero then table headers are printed before the
+ * first line of output.
*
- * Return: Success: non-negative
- *
- * Failure: negative
- *
- * Programmer: Robb Matzke
- * Monday, December 14, 1998
- *
- * Modifications:
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -110,34 +103,34 @@ H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/*
FUNC_ENTER_PACKAGE_NOERR
#ifdef H5T_DEBUG
- if(H5DEBUG(T) && path->stats.ncalls > 0) {
- if(nprint && 0 == (*nprint)++) {
- HDfprintf(H5DEBUG(T), "H5T: type conversion statistics:\n");
- HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n",
- "Conversion", "Elmts", "Calls", "User",
- "System", "Elapsed", "Bandwidth");
- HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n",
- "----------", "-----", "-----", "----",
- "------", "-------", "---------");
- }
- if(path->src && path->dst)
+ if (H5DEBUG(T) && path->stats.ncalls > 0) {
+ if (nprint && 0 == (*nprint)++) {
+ HDfprintf(H5DEBUG(T), "H5T: type conversion statistics:\n");
+ HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "Conversion", "Elmts", "Calls", "User",
+ "System", "Elapsed", "Bandwidth");
+ HDfprintf(H5DEBUG(T), " %-16s %10s %10s %8s %8s %8s %10s\n",
+ "----------", "-----", "-----", "----",
+ "------", "-------", "---------");
+ }
+ if (path->src && path->dst)
nbytes = MAX(H5T_get_size(path->src), H5T_get_size(path->dst));
- else if(path->src)
+ else if (path->src)
nbytes = H5T_get_size(path->src);
- else if(path->dst)
+ else if (path->dst)
nbytes = H5T_get_size(path->dst);
else
nbytes = 0;
- nbytes *= path->stats.nelmts;
- H5_bandwidth(bandwidth, (double)nbytes, path->stats.timer.etime);
- HDfprintf(H5DEBUG(T), " %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
- path->name,
- path->stats.nelmts,
- path->stats.ncalls,
- path->stats.timer.utime,
- path->stats.timer.stime,
- path->stats.timer.etime,
- bandwidth);
+ nbytes *= path->stats.nelmts;
+ H5_bandwidth(bandwidth, (double)nbytes, path->stats.timer.etime);
+ HDfprintf(H5DEBUG(T), " %-16s %10Hd %10d %8.2f %8.2f %8.2f %10s\n",
+ path->name,
+ path->stats.nelmts,
+ path->stats.ncalls,
+ path->stats.timer.utime,
+ path->stats.timer.stime,
+ path->stats.timer.etime,
+ bandwidth);
}
#endif
FUNC_LEAVE_NOAPI(SUCCEED)
@@ -145,24 +138,20 @@ H5T__print_stats(H5T_path_t H5_ATTR_UNUSED * path, int H5_ATTR_UNUSED * nprint/*
/*-------------------------------------------------------------------------
- * Function: H5T_debug
- *
- * Purpose: Prints information about a data type.
+ * Function: H5T_debug
*
- * Return: Non-negative on success/Negative on failure
+ * Purpose: Prints information about a data type.
*
- * Programmer: Robb Matzke
- * Wednesday, January 7, 1998
- *
- * Modifications:
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5T_debug(const H5T_t *dt, FILE *stream)
{
- const char *s1 = "", *s2 = "";
- unsigned i;
+ const char *s1 = "";
+ const char *s2 = "";
+ unsigned i;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -171,7 +160,7 @@ H5T_debug(const H5T_t *dt, FILE *stream)
HDassert(dt);
HDassert(stream);
- switch(dt->shared->type) {
+ switch (dt->shared->type) {
case H5T_NO_CLASS:
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "no class");
break;
@@ -221,9 +210,9 @@ H5T_debug(const H5T_t *dt, FILE *stream)
default:
s1 = "";
break;
- } /* end switch */
+ } /* end switch */
- switch(dt->shared->state) {
+ switch (dt->shared->state) {
case H5T_STATE_TRANSIENT:
s2 = "[transient]";
break;
@@ -245,14 +234,14 @@ H5T_debug(const H5T_t *dt, FILE *stream)
break;
default:
HDassert(0 && "This Should never be executed!");
- } /* end switch */
+ } /* end switch */
- fprintf(stream, "%s%s {nbytes=%lu", s1, s2, (unsigned long)(dt->shared->size));
+ HDfprintf(stream, "%s%s {nbytes=%lu", s1, s2, (unsigned long)(dt->shared->size));
- if(H5T_IS_ATOMIC(dt->shared)) {
- uint64_t tmp;
+ if (H5T_IS_ATOMIC(dt->shared)) {
+ uint64_t tmp;
- switch(dt->shared->u.atomic.order) {
+ switch (dt->shared->u.atomic.order) {
case H5T_ORDER_ERROR:
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "order error");
break;
@@ -277,17 +266,16 @@ H5T_debug(const H5T_t *dt, FILE *stream)
default:
s1 = "order?";
break;
- } /* end switch */
+ } /* end switch */
+
+ HDfprintf(stream, ", %s", s1);
- fprintf(stream, ", %s", s1);
+ if (dt->shared->u.atomic.offset)
+ HDfprintf(stream, ", offset=%lu", (unsigned long) (dt->shared->u.atomic.offset));
+ if (dt->shared->u.atomic.prec != 8 * dt->shared->size)
+ HDfprintf(stream, ", prec=%lu", (unsigned long) (dt->shared->u.atomic.prec));
- if(dt->shared->u.atomic.offset)
- fprintf(stream, ", offset=%lu",
- (unsigned long) (dt->shared->u.atomic.offset));
- if(dt->shared->u.atomic.prec != 8 * dt->shared->size)
- fprintf(stream, ", prec=%lu",
- (unsigned long) (dt->shared->u.atomic.prec));
- switch(dt->shared->type) {
+ switch (dt->shared->type) {
case H5T_NO_CLASS:
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "no class");
break;
@@ -313,7 +301,7 @@ H5T_debug(const H5T_t *dt, FILE *stream)
} /* end switch */
if(s1)
- fprintf(stream, ", %s", s1);
+ HDfprintf(stream, ", %s", s1);
break;
case H5T_FLOAT:
@@ -339,23 +327,24 @@ H5T_debug(const H5T_t *dt, FILE *stream)
break;
} /* end switch */
- fprintf(stream, ", sign=%lu+1",
+ HDfprintf(stream, ", sign=%lu+1",
(unsigned long)(dt->shared->u.atomic.u.f.sign));
- fprintf(stream, ", mant=%lu+%lu (%s)",
+ HDfprintf(stream, ", mant=%lu+%lu (%s)",
(unsigned long)(dt->shared->u.atomic.u.f.mpos),
(unsigned long)(dt->shared->u.atomic.u.f.msize), s1);
- fprintf(stream, ", exp=%lu+%lu",
+ HDfprintf(stream, ", exp=%lu+%lu",
(unsigned long)(dt->shared->u.atomic.u.f.epos),
(unsigned long)(dt->shared->u.atomic.u.f.esize));
tmp = dt->shared->u.atomic.u.f.ebias >> 32;
- if(tmp) {
+ if (tmp) {
size_t hi = (size_t)tmp;
size_t lo = (size_t)(dt->shared->u.atomic.u.f.ebias & 0xffffffff);
- fprintf(stream, " bias=0x%08lx%08lx",
+ HDfprintf(stream, " bias=0x%08lx%08lx",
(unsigned long)hi, (unsigned long)lo);
- } else {
+ }
+ else {
size_t lo = (size_t)(dt->shared->u.atomic.u.f.ebias & 0xffffffff);
- fprintf(stream, " bias=0x%08lx", (unsigned long)lo);
+ HDfprintf(stream, " bias=0x%08lx", (unsigned long)lo);
}
break;
@@ -372,69 +361,73 @@ H5T_debug(const H5T_t *dt, FILE *stream)
default:
/* No additional info */
break;
- } /* end switch */
- } else if(H5T_COMPOUND == dt->shared->type) {
- /* Compound data type */
- for(i = 0; i < dt->shared->u.compnd.nmembs; i++) {
- fprintf(stream, "\n\"%s\" @%lu",
- dt->shared->u.compnd.memb[i].name,
- (unsigned long)(dt->shared->u.compnd.memb[i].offset));
- fprintf(stream, " ");
- H5T_debug(dt->shared->u.compnd.memb[i].type, stream);
- } /* end for */
- fprintf(stream, "\n");
- } else if(H5T_VLEN == dt->shared->type) {
- switch(dt->shared->u.vlen.loc) {
+ } /* end switch */
+ }
+ else if (H5T_COMPOUND == dt->shared->type) {
+ /* Compound data type */
+ for (i = 0; i < dt->shared->u.compnd.nmembs; i++) {
+ HDfprintf(stream, "\n\"%s\" @%lu",
+ dt->shared->u.compnd.memb[i].name,
+ (unsigned long)(dt->shared->u.compnd.memb[i].offset));
+ HDfprintf(stream, " ");
+ H5T_debug(dt->shared->u.compnd.memb[i].type, stream);
+ } /* end for */
+ HDfprintf(stream, "\n");
+ }
+ else if (H5T_VLEN == dt->shared->type) {
+ switch (dt->shared->u.vlen.loc) {
case H5T_LOC_BADLOC:
HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid datatype location");
break;
case H5T_LOC_MEMORY:
- fprintf(stream, ", loc=memory");
+ HDfprintf(stream, ", loc=memory");
break;
case H5T_LOC_DISK:
- fprintf(stream, ", loc=disk");
+ HDfprintf(stream, ", loc=disk");
break;
case H5T_LOC_MAXLOC:
default:
- fprintf(stream, ", loc=UNKNOWN");
+ HDfprintf(stream, ", loc=UNKNOWN");
break;
} /* end switch */
- if(H5T_IS_VL_STRING(dt->shared))
+ if (H5T_IS_VL_STRING(dt->shared))
/* Variable length string datatype */
- fprintf(stream, ", variable-length");
+ HDfprintf(stream, ", variable-length");
else {
/* Variable length sequence datatype */
- fprintf(stream, " VLEN ");
+ HDfprintf(stream, " VLEN ");
H5T_debug(dt->shared->parent, stream);
- fprintf(stream, "\n");
+ HDfprintf(stream, "\n");
} /* end else */
- } else if(H5T_ENUM == dt->shared->type) {
+ }
+ else if (H5T_ENUM == dt->shared->type) {
size_t base_size;
- /* Enumeration data type */
- fprintf(stream, " ");
- H5T_debug(dt->shared->parent, stream);
- base_size = dt->shared->parent->shared->size;
- for(i = 0; i < dt->shared->u.enumer.nmembs; i++) {
+ /* Enumeration data type */
+ HDfprintf(stream, " ");
+ H5T_debug(dt->shared->parent, stream);
+ base_size = dt->shared->parent->shared->size;
+ for (i = 0; i < dt->shared->u.enumer.nmembs; i++) {
size_t k;
- fprintf(stream, "\n\"%s\" = 0x", dt->shared->u.enumer.name[i]);
- for(k = 0; k < base_size; k++)
- fprintf(stream, "%02lx",
- (unsigned long)(dt->shared->u.enumer.value + (i * base_size) + k));
- } /* end for */
- fprintf(stream, "\n");
- } else if(H5T_OPAQUE == dt->shared->type) {
- fprintf(stream, ", tag=\"%s\"", dt->shared->u.opaque.tag);
- } else {
- /* Unknown */
- fprintf(stream, "unknown class %d\n", (int)(dt->shared->type));
+ HDfprintf(stream, "\n\"%s\" = 0x", dt->shared->u.enumer.name[i]);
+ for (k = 0; k < base_size; k++)
+ HDfprintf(stream, "%02lx", (unsigned long)(dt->shared->u.enumer.value + (i * base_size) + k));
+ } /* end for */
+ HDfprintf(stream, "\n");
+ }
+ else if (H5T_OPAQUE == dt->shared->type) {
+ HDfprintf(stream, ", tag=\"%s\"", dt->shared->u.opaque.tag);
+ }
+ else {
+ /* Unknown */
+ HDfprintf(stream, "unknown class %d\n", (int)(dt->shared->type));
}
- fprintf(stream, "}");
+ HDfprintf(stream, "}");
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index f2da62e..17cdc49 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -17,6 +17,9 @@
#ifndef _H5Tprivate_H
#define _H5Tprivate_H
+/* Early typedefs to avoid circular dependencies */
+typedef struct H5T_t H5T_t;
+
/* Get package's public header */
#include "H5Tpublic.h"
@@ -45,7 +48,6 @@
#endif /* H5T_MODULE */
/* Forward references of package typedefs (declared in H5Tpkg.h) */
-typedef struct H5T_t H5T_t;
typedef struct H5T_stats_t H5T_stats_t;
typedef struct H5T_path_t H5T_path_t;
diff --git a/src/H5Z.c b/src/H5Z.c
index a9f7336..6f173b2 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -86,24 +86,24 @@ H5Z__init_package(void)
FUNC_ENTER_PACKAGE
/* Internal filters */
- if (H5Z_register (H5Z_SHUFFLE) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register shuffle filter")
- if (H5Z_register (H5Z_FLETCHER32) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register fletcher32 filter")
- if (H5Z_register (H5Z_NBIT) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register nbit filter")
- if (H5Z_register (H5Z_SCALEOFFSET) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register scaleoffset filter")
+ if (H5Z_register(H5Z_SHUFFLE) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register shuffle filter")
+ if (H5Z_register(H5Z_FLETCHER32) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register fletcher32 filter")
+ if (H5Z_register(H5Z_NBIT) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register nbit filter")
+ if (H5Z_register(H5Z_SCALEOFFSET) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register scaleoffset filter")
/* External filters */
#ifdef H5_HAVE_FILTER_DEFLATE
- if (H5Z_register (H5Z_DEFLATE) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register deflate filter")
+ if (H5Z_register(H5Z_DEFLATE) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register deflate filter")
#endif /* H5_HAVE_FILTER_DEFLATE */
#ifdef H5_HAVE_FILTER_SZIP
H5Z_SZIP->encoder_present = SZ_encoder_enabled();
- if (H5Z_register (H5Z_SZIP) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register szip filter")
+ if (H5Z_register(H5Z_SZIP) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register szip filter")
#endif /* H5_HAVE_FILTER_SZIP */
done:
@@ -180,7 +180,7 @@ H5Z_term_package(void)
} /* end if */
#endif /* H5Z_DEBUG */
/* Free the table of filters */
- if(H5Z_table_g) {
+ if (H5Z_table_g) {
H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g);
#ifdef H5Z_DEBUG
H5Z_stat_table_g = (H5Z_stats_t *)H5MM_xfree(H5Z_stat_table_g);
@@ -191,7 +191,7 @@ H5Z_term_package(void)
} /* end if */
/* Mark interface as closed */
- if(0 == n)
+ if (0 == n)
H5_PKG_INIT_VAR = FALSE;
} /* end if */
@@ -219,7 +219,7 @@ H5Zregister(const void *cls)
/* Check args */
if (cls_real==NULL)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter class")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter class")
/* Check H5Z_class_t version number; this is where a function to convert
* from an outdated version should be called.
@@ -251,20 +251,20 @@ H5Zregister(const void *cls)
#else /* H5_NO_DEPRECATED_SYMBOLS */
/* Deprecated symbols not allowed, throw an error */
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number");
#endif /* H5_NO_DEPRECATED_SYMBOLS */
} /* end if */
if (cls_real->id < 0 || cls_real->id > H5Z_FILTER_MAX)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number")
if (cls_real->id < H5Z_FILTER_RESERVED)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters")
if (cls_real->filter == NULL)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no filter function specified")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no filter function specified")
/* Do it */
- if (H5Z_register (cls_real) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
+ if (H5Z_register(cls_real) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
done:
FUNC_LEAVE_API(ret_value)
@@ -275,7 +275,7 @@ done:
* Function: H5Z_register
*
* Purpose: Same as the public version except this one allows filters
- * to be set for predefined method numbers <H5Z_FILTER_RESERVED
+ * to be set for predefined method numbers < H5Z_FILTER_RESERVED
*
* Return: Non-negative on success
* Negative on failure
@@ -289,8 +289,8 @@ H5Z_register (const H5Z_class2_t *cls)
FUNC_ENTER_NOAPI(FAIL)
- HDassert (cls);
- HDassert (cls->id >= 0 && cls->id <= H5Z_FILTER_MAX);
+ HDassert(cls);
+ HDassert(cls->id >= 0 && cls->id <= H5Z_FILTER_MAX);
/* Is the filter already registered? */
for (i = 0; i < H5Z_table_used_g; i++)
@@ -306,11 +306,11 @@ H5Z_register (const H5Z_class2_t *cls)
H5Z_stats_t *stat_table = (H5Z_stats_t *)H5MM_realloc(H5Z_stat_table_g, n * sizeof(H5Z_stats_t));
#endif /* H5Z_DEBUG */
if (!table)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter table")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter table")
H5Z_table_g = table;
#ifdef H5Z_DEBUG
if (!stat_table)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter statistics table")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter statistics table")
H5Z_stat_table_g = stat_table;
#endif /* H5Z_DEBUG */
H5Z_table_alloc_g = n;
@@ -318,15 +318,15 @@ H5Z_register (const H5Z_class2_t *cls)
/* Initialize */
i = H5Z_table_used_g++;
- HDmemcpy (H5Z_table_g+i, cls, sizeof(H5Z_class2_t));
+ HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t));
#ifdef H5Z_DEBUG
- HDmemset (H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t));
+ HDmemset(H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t));
#endif /* H5Z_DEBUG */
} /* end if */
/* Filter already registered */
else {
/* Replace old contents */
- HDmemcpy (H5Z_table_g+i, cls, sizeof(H5Z_class2_t));
+ HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t));
} /* end else */
done:
@@ -420,9 +420,9 @@ H5Z_unregister(H5Z_filter_t filter_id)
/* Remove filter from table */
/* Don't worry about shrinking table size (for now) */
- HDmemmove (&H5Z_table_g[filter_index], &H5Z_table_g[filter_index+1], sizeof(H5Z_class2_t)*((H5Z_table_used_g-1)-filter_index));
+ HDmemmove(&H5Z_table_g[filter_index], &H5Z_table_g[filter_index+1], sizeof(H5Z_class2_t)*((H5Z_table_used_g-1)-filter_index));
#ifdef H5Z_DEBUG
- HDmemmove (&H5Z_stat_table_g[filter_index], &H5Z_stat_table_g[filter_index+1], sizeof(H5Z_stats_t)*((H5Z_table_used_g-1)-filter_index));
+ HDmemmove(&H5Z_stat_table_g[filter_index], &H5Z_stat_table_g[filter_index+1], sizeof(H5Z_stats_t)*((H5Z_table_used_g-1)-filter_index));
#endif /* H5Z_DEBUG */
H5Z_table_used_g--;
@@ -450,11 +450,11 @@ H5Z__check_unregister(hid_t ocpl_id, H5Z_filter_t filter_id)
/* Get the plist structure of object creation */
if (NULL == (plist = H5P_object_verify(ocpl_id, H5P_OBJECT_CREATE)))
- HGOTO_ERROR (H5E_PLINE, H5E_BADATOM, FAIL, "can't find object for ID")
+ HGOTO_ERROR(H5E_PLINE, H5E_BADATOM, FAIL, "can't find object for ID")
/* Check if the object creation property list uses the filter */
if ((ret_value = H5P_filter_in_pline(plist, filter_id)) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -487,11 +487,11 @@ H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void
/* Get the group creation property */
if ((ocpl_id = H5G_get_create_plist((H5G_t *)obj_ptr)) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "can't get group creation property list")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get group creation property list")
/* Check if the filter is in the group creation property list */
if ((filter_in_pline = H5Z__check_unregister(ocpl_id, object->filter_id)) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline")
/* H5I_iterate expects TRUE to stop the loop over objects. Stop the loop and
* let H5Z_unregister return failure.
@@ -504,7 +504,7 @@ H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void
done:
if (ocpl_id > 0)
if (H5I_dec_app_ref(ocpl_id) < 0)
- HDONE_ERROR (H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist")
+ HDONE_ERROR(H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5Z__check_unregister_group_cb() */
@@ -532,15 +532,15 @@ H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *
FUNC_ENTER_STATIC
- HDassert (obj_ptr);
+ HDassert(obj_ptr);
/* Get the dataset creation property */
if ((ocpl_id = H5D_get_create_plist((H5D_t *)obj_ptr)) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "can't get dataset creation property list")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get dataset creation property list")
/* Check if the filter is in the dataset creation property list */
if ((filter_in_pline = H5Z__check_unregister(ocpl_id, object->filter_id)) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline")
/* H5I_iterate expects TRUE to stop the loop over objects. Stop the loop and
* let H5Z_unregister return failure.
@@ -553,7 +553,7 @@ H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *
done:
if (ocpl_id > 0)
if (H5I_dec_app_ref(ocpl_id) < 0)
- HDONE_ERROR (H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist")
+ HDONE_ERROR(H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5Z__check_unregister_dset_cb() */
@@ -576,13 +576,13 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void H5_ATTR_UNUS
FUNC_ENTER_STATIC
- HDassert (obj_ptr);
+ HDassert(obj_ptr);
/* Call the flush routine for mounted file hierarchies. Do a global flush
* if the file is opened for write */
if (H5F_ACC_RDWR & H5F_INTENT((H5F_t *)obj_ptr)) {
if (H5F_flush_mounts((H5F_t *)obj_ptr, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy")
} /* end if */
done:
@@ -608,10 +608,10 @@ H5Zfilter_avail(H5Z_filter_t id)
/* Check args */
if (id < 0 || id > H5Z_FILTER_MAX)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number")
if ((ret_value = H5Z_filter_avail(id)) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, FAIL, "unable to check the availability of the filter")
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "unable to check the availability of the filter")
done:
FUNC_LEAVE_API(ret_value)
@@ -629,22 +629,25 @@ done:
htri_t
H5Z_filter_avail(H5Z_filter_t id)
{
- size_t i; /* Local index variable */
- H5Z_class2_t *filter_info;
- htri_t ret_value = FALSE; /* Return value */
+ H5PL_key_t key; /* Key for finding a plugin */
+ const H5Z_class2_t *filter_info; /* Filter information */
+ size_t i; /* Local index variable */
+ htri_t ret_value = FALSE; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Is the filter already registered? */
for (i = 0; i < H5Z_table_used_g; i++)
if (H5Z_table_g[i].id == id)
- HGOTO_DONE (TRUE)
+ HGOTO_DONE(TRUE)
- if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id))) {
- if (H5Z_register (filter_info) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter")
- HGOTO_DONE (TRUE)
+ key.id = (int)id;
+ if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, key))) {
+ if (H5Z_register(filter_info) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter")
+ HGOTO_DONE(TRUE)
}
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5Z_filter_avail() */
@@ -683,7 +686,7 @@ H5Z_prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id,
if (pline->filter[u].flags & H5Z_FLAG_OPTIONAL)
H5E_clear_stack (NULL);
else
- HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, FAIL, "required filter was not located")
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "required filter was not located")
} /* end if */
else {
/* Make correct callback */
@@ -691,7 +694,7 @@ H5Z_prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id,
case H5Z_PRELUDE_CAN_APPLY:
/* Check if filter is configured to be able to encode */
if (!fclass->encoder_present)
- HGOTO_ERROR (H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled.");
+ HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled.");
/* Check if there is a "can apply" callback */
@@ -716,12 +719,12 @@ H5Z_prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id,
/* Make callback to filter's "set local" function */
if ((fclass->set_local)(dcpl_id, type_id, space_id) < 0)
/* Indicate error during filter callback */
- HGOTO_ERROR (H5E_PLINE, H5E_SETLOCAL, FAIL, "error during user callback")
+ HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "error during user callback")
} /* end if */
break;
default:
- HDassert ("invalid prelude type" && 0);
+ HDassert("invalid prelude type" && 0);
} /* end switch */
} /* end else */
} /* end for */
@@ -749,28 +752,32 @@ static herr_t
H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_type)
{
hid_t space_id = -1; /* ID for dataspace describing chunk */
+ H5O_layout_t *dcpl_layout = NULL; /* Dataset's layout information */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- HDassert (H5I_GENPROP_LST == H5I_get_type(dcpl_id));
- HDassert (H5I_DATATYPE == H5I_get_type(type_id));
+ HDassert(H5I_GENPROP_LST == H5I_get_type(dcpl_id));
+ HDassert(H5I_DATATYPE == H5I_get_type(type_id));
/* Check if the property list is non-default */
if (dcpl_id != H5P_DATASET_CREATE_DEFAULT) {
- H5P_genplist_t *dc_plist; /* Dataset creation property list object */
- H5O_layout_t dcpl_layout; /* Dataset's layout information */
+ H5P_genplist_t *dc_plist; /* Dataset creation property list object */
+
+ /* Get memory for the layout */
+ if (NULL == (dcpl_layout = (H5O_layout_t *)H5MM_calloc(sizeof(H5O_layout_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate dcpl layout buffer")
/* Get dataset creation property list object */
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")
/* Peek at the layout information */
- if (H5P_peek(dc_plist, H5D_CRT_LAYOUT_NAME, &dcpl_layout) < 0)
+ 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 */
- if (H5D_CHUNKED == dcpl_layout.type) {
+ if (H5D_CHUNKED == dcpl_layout->type) {
H5O_pline_t dcpl_pline; /* Object's I/O pipeline information */
/* Get I/O pipeline information */
@@ -784,28 +791,31 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type
size_t u; /* Local index variable */
/* Create a dataspace for a chunk & set the extent */
- for (u = 0; u < dcpl_layout.u.chunk.ndims; u++)
- chunk_dims[u] = dcpl_layout.u.chunk.dim[u];
- if (NULL == (space = H5S_create_simple(dcpl_layout.u.chunk.ndims, chunk_dims, NULL)))
+ for (u = 0; u < dcpl_layout->u.chunk.ndims; u++)
+ chunk_dims[u] = dcpl_layout->u.chunk.dim[u];
+ if (NULL == (space = H5S_create_simple(dcpl_layout->u.chunk.ndims, chunk_dims, NULL)))
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
/* Get ID for dataspace to pass to filter routines */
if ((space_id = H5I_register(H5I_DATASPACE, space, FALSE)) < 0) {
- (void)H5S_close (space);
+ (void)H5S_close(space);
HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
- } /* end if */
+ }
/* Make the callbacks */
if (H5Z_prelude_callback(&dcpl_pline, dcpl_id, type_id, space_id, prelude_type) < 0)
HGOTO_ERROR (H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter")
- } /* end if */
- } /* end if */
- } /* end if */
+ }
+ }
+ }
done:
if (space_id > 0 && H5I_dec_ref(space_id) < 0)
HDONE_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace")
+ if (dcpl_layout)
+ dcpl_layout = (H5O_layout_t *)H5MM_xfree(dcpl_layout);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5Z_prepare_prelude_callback_dcpl() */
@@ -834,7 +844,7 @@ H5Z_can_apply(hid_t dcpl_id, hid_t type_id)
/* Make "can apply" callbacks for filters in pipeline */
if (H5Z_prepare_prelude_callback_dcpl(dcpl_id, type_id, H5Z_PRELUDE_CAN_APPLY) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -865,7 +875,7 @@ H5Z_set_local(hid_t dcpl_id, hid_t type_id)
/* Make "set local" callbacks for filters in pipeline */
if (H5Z_prepare_prelude_callback_dcpl(dcpl_id, type_id, H5Z_PRELUDE_SET_LOCAL) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set")
+ HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -890,11 +900,11 @@ H5Z_can_apply_direct(const H5O_pline_t *pline)
FUNC_ENTER_NOAPI(FAIL)
- HDassert (pline->nused > 0);
+ HDassert(pline->nused > 0);
/* Make "can apply" callbacks for filters in pipeline */
if (H5Z_prelude_callback(pline, (hid_t)-1, (hid_t)-1, (hid_t)-1, H5Z_PRELUDE_CAN_APPLY) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -923,11 +933,11 @@ H5Z_set_local_direct(const H5O_pline_t *pline)
FUNC_ENTER_NOAPI(FAIL)
- HDassert (pline->nused > 0);
+ HDassert(pline->nused > 0);
/* Make "set local" callbacks for filters in pipeline */
if (H5Z_prelude_callback(pline, (hid_t)-1, (hid_t)-1, (hid_t)-1, H5Z_PRELUDE_SET_LOCAL) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set")
+ HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -952,10 +962,10 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags,
FUNC_ENTER_NOAPI(FAIL)
- HDassert (pline);
- HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX);
- HDassert (0 == (flags & ~((unsigned)H5Z_FLAG_DEFMASK)));
- HDassert (0 == cd_nelmts || cd_values);
+ HDassert(pline);
+ HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX);
+ HDassert(0 == (flags & ~((unsigned)H5Z_FLAG_DEFMASK)));
+ HDassert(0 == cd_nelmts || cd_values);
/* Locate the filter in the pipeline */
for (idx = 0; idx < pline->nused; idx++)
@@ -964,7 +974,7 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags,
/* Check if the filter was not already in the pipeline */
if (idx > pline->nused)
- HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline")
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline")
/* Change parameters for filter */
pline->filter[idx].flags = flags;
@@ -982,7 +992,7 @@ H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags,
if (cd_nelmts > H5Z_COMMON_CD_VALUES) {
pline->filter[idx].cd_values = (unsigned *)H5MM_malloc(cd_nelmts * sizeof(unsigned));
if (NULL == pline->filter[idx].cd_values)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter parameters")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter parameters")
} /* end if */
else
pline->filter[idx].cd_values = pline->filter[idx]._cd_values;
@@ -1017,10 +1027,10 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags,
FUNC_ENTER_NOAPI(FAIL)
- HDassert (pline);
- HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX);
- HDassert (0 == (flags & ~((unsigned)H5Z_FLAG_DEFMASK)));
- HDassert (0 == cd_nelmts || cd_values);
+ HDassert(pline);
+ HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX);
+ HDassert(0 == (flags & ~((unsigned)H5Z_FLAG_DEFMASK)));
+ HDassert(0 == cd_nelmts || cd_values);
/*
* Check filter limit. We do it here for early warnings although we may
@@ -1052,13 +1062,13 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags,
x.nalloc = MAX(H5Z_MAX_NFILTERS, 2 * pline->nalloc);
x.filter = (H5Z_filter_info_t *)H5MM_realloc(pline->filter, x.nalloc * sizeof(x.filter[0]));
if (NULL == x.filter)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline")
/* Fix pointers in previous filters that need to point to their own
* internal data.
*/
- for(n = 0; n < pline->nalloc; ++n)
- if(x.filter[n].cd_values == (void *) ~((size_t) NULL))
+ for (n = 0; n < pline->nalloc; ++n)
+ if (x.filter[n].cd_values == (void *) ~((size_t) NULL))
x.filter[n].cd_values = x.filter[n]._cd_values;
/* Point to newly allocated buffer */
@@ -1079,7 +1089,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags,
if (cd_nelmts > H5Z_COMMON_CD_VALUES) {
pline->filter[idx].cd_values = (unsigned *)H5MM_malloc(cd_nelmts * sizeof(unsigned));
if (NULL == pline->filter[idx].cd_values)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter")
} /* end if */
else
pline->filter[idx].cd_values = pline->filter[idx]._cd_values;
@@ -1118,7 +1128,7 @@ H5Z_find_idx(H5Z_filter_t id)
for (i = 0; i < H5Z_table_used_g; i++)
if (H5Z_table_g[i].id == id)
- HGOTO_DONE ((int)i)
+ HGOTO_DONE((int)i)
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1145,10 +1155,10 @@ H5Z_find(H5Z_filter_t id)
/* Get the index in the global table */
if ((idx = H5Z_find_idx(id)) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, NULL, "required filter %d is not registered", id)
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, NULL, "required filter %d is not registered", id)
/* Set return value */
- ret_value = H5Z_table_g+idx;
+ ret_value = H5Z_table_g + idx;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1197,12 +1207,12 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
FUNC_ENTER_NOAPI(FAIL)
- HDassert (0 == (flags & ~((unsigned)H5Z_FLAG_INVMASK)));
- HDassert (filter_mask);
- HDassert (nbytes && *nbytes>0);
- HDassert (buf_size && *buf_size>0);
- HDassert (buf && *buf);
- HDassert (!pline || pline->nused<H5Z_MAX_NFILTERS);
+ HDassert(0 == (flags & ~((unsigned)H5Z_FLAG_INVMASK)));
+ HDassert(filter_mask);
+ HDassert(nbytes && *nbytes>0);
+ HDassert(buf_size && *buf_size>0);
+ HDassert(buf && *buf);
+ HDassert(!pline || pline->nused < H5Z_MAX_NFILTERS);
if (pline && (flags & H5Z_FLAG_REVERSE)) { /* Read */
for (i = pline->nused; i > 0; --i) {
@@ -1219,18 +1229,20 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
*/
if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) {
hbool_t issue_error = FALSE;
+ H5PL_key_t key;
const H5Z_class2_t *filter_info;
/* Try loading the filter */
- if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) {
+ key.id = (int)(pline->filter[idx].id);
+ if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, key))) {
/* Register the filter we loaded */
- if (H5Z_register(filter_info) < 0)
- HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
+ if(H5Z_register(filter_info) < 0)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter")
/* Search in the table of registered filters again to find the dynamic filter just loaded and registered */
if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0)
issue_error = TRUE;
- } /* end if */
+ }
else
issue_error = TRUE;
@@ -1242,7 +1254,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", pline->filter[idx].name)
else
HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter (name unavailable) is not registered")
- } /* end if */
+ }
} /* end if */
fclass = &H5Z_table_g[fclass_idx];
@@ -1258,12 +1270,13 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
#ifdef H5Z_DEBUG
H5_timer_end (&(fstats->stats[1].timer), &timer);
fstats->stats[1].total += MAX(*nbytes, new_nbytes);
- if (0 == new_nbytes) fstats->stats[1].errors += *nbytes;
+ if (0 == new_nbytes)
+ fstats->stats[1].errors += *nbytes;
#endif
if (0 == new_nbytes) {
- if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func (pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) || !cb_struct.func)
- HGOTO_ERROR (H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read")
+ if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) || !cb_struct.func)
+ HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read")
*nbytes = *buf_size;
failed |= (unsigned)1 << idx;
@@ -1298,12 +1311,13 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags,
#ifdef H5Z_DEBUG
H5_timer_end (&(fstats->stats[0].timer), &timer);
fstats->stats[0].total += MAX(*nbytes, new_nbytes);
- if (0 == new_nbytes) fstats->stats[0].errors += *nbytes;
+ if (0 == new_nbytes)
+ fstats->stats[0].errors += *nbytes;
#endif
if (0 == new_nbytes) {
if (0 == (pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) {
if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func (pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data))) || !cb_struct.func)
- HGOTO_ERROR (H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure")
+ HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure")
*nbytes = *buf_size;
}
@@ -1340,8 +1354,8 @@ H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter)
FUNC_ENTER_NOAPI(NULL)
- HDassert (pline);
- HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX);
+ HDassert(pline);
+ HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX);
/* Locate the filter in the pipeline */
for (idx = 0; idx < pline->nused; idx++)
@@ -1350,7 +1364,7 @@ H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter)
/* Check if the filter was not already in the pipeline */
if (idx >= pline->nused)
- HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, NULL, "filter not in pipeline")
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, NULL, "filter not in pipeline")
/* Set return value */
ret_value = &pline->filter[idx];
@@ -1379,8 +1393,8 @@ H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter)
FUNC_ENTER_NOAPI(FAIL)
- HDassert (pline);
- HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX);
+ HDassert(pline);
+ HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX);
/* Locate the filter in the pipeline */
for (idx = 0; idx < pline->nused; idx++)
@@ -1416,7 +1430,7 @@ H5Z_all_filters_avail(const H5O_pline_t *pline)
FUNC_ENTER_NOAPI(FAIL)
/* Check args */
- HDassert (pline);
+ HDassert(pline);
/* Iterate through all the filters in pipeline */
for (i = 0; i < pline->nused; i++) {
@@ -1427,7 +1441,7 @@ H5Z_all_filters_avail(const H5O_pline_t *pline)
/* Check if we didn't find the filter */
if (j == H5Z_table_used_g)
- HGOTO_DONE (FALSE)
+ HGOTO_DONE(FALSE)
} /* end for */
done:
@@ -1454,8 +1468,8 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
FUNC_ENTER_NOAPI(FAIL)
/* Check args */
- HDassert (pline);
- HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX);
+ HDassert(pline);
+ HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX);
/* if the pipeline has no filters, just return */
if (pline->nused == 0)
@@ -1465,7 +1479,7 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
if (H5Z_FILTER_ALL == filter) {
if (H5O_msg_reset(H5O_PLINE_ID, pline) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTFREE, FAIL, "can't release pipeline info")
- } /* end if */
+ }
/* Delete filter */
else {
size_t idx; /* Index of filter in pipeline */
@@ -1476,19 +1490,19 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
if (pline->filter[idx].id == filter) {
found = TRUE;
break;
- } /* end if */
+ }
/* filter was not found in the pipeline */
if (!found)
- HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline")
+ HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline")
/* Free information for deleted filter */
if (pline->filter[idx].name && pline->filter[idx].name != pline->filter[idx]._name)
- HDassert ((HDstrlen(pline->filter[idx].name) + 1) > H5Z_COMMON_NAME_LEN);
+ HDassert((HDstrlen(pline->filter[idx].name) + 1) > H5Z_COMMON_NAME_LEN);
if (pline->filter[idx].name != pline->filter[idx]._name)
pline->filter[idx].name = (char *)H5MM_xfree(pline->filter[idx].name);
if (pline->filter[idx].cd_values && pline->filter[idx].cd_values != pline->filter[idx]._cd_values)
- HDassert (pline->filter[idx].cd_nelmts > H5Z_COMMON_CD_VALUES);
+ HDassert(pline->filter[idx].cd_nelmts > H5Z_COMMON_CD_VALUES);
if (pline->filter[idx].cd_values != pline->filter[idx]._cd_values)
pline->filter[idx].cd_values = (unsigned *)H5MM_xfree(pline->filter[idx].cd_values);
@@ -1501,8 +1515,8 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter)
pline->filter[idx].name = pline->filter[idx]._name;
if (pline->filter[idx].cd_nelmts <= H5Z_COMMON_CD_VALUES)
pline->filter[idx].cd_values = pline->filter[idx]._cd_values;
- } /* end for */
- } /* end if */
+ }
+ }
/* Decrement number of used filters */
pline->nused--;
@@ -1563,7 +1577,7 @@ H5Z_get_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags)
/* Look up the filter class info */
if (NULL == (fclass = H5Z_find(filter)))
- HGOTO_ERROR (H5E_PLINE, H5E_BADVALUE, FAIL, "Filter not defined")
+ HGOTO_ERROR(H5E_PLINE, H5E_BADVALUE, FAIL, "Filter not defined")
/* Set the filter config flags for the application */
if (filter_config_flags != NULL) {
diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h
index fe182ad..26e35a7 100644
--- a/src/H5Zprivate.h
+++ b/src/H5Zprivate.h
@@ -18,6 +18,9 @@
#ifndef _H5Zprivate_H
#define _H5Zprivate_H
+/* Early typedefs to avoid circular dependencies */
+typedef struct H5Z_filter_info_t H5Z_filter_info_t;
+
/* Include package's public header */
#include "H5Zpublic.h"
@@ -49,7 +52,7 @@
/****************************/
/* Structure to store information about each filter's parameters */
-typedef struct H5Z_filter_info_t {
+struct H5Z_filter_info_t {
H5Z_filter_t id; /*filter identification number */
unsigned flags; /*defn and invocation flags */
char _name[H5Z_COMMON_NAME_LEN]; /*internal filter name */
@@ -57,7 +60,7 @@ typedef struct H5Z_filter_info_t {
size_t cd_nelmts; /*number of elements in cd_values[] */
unsigned _cd_values[H5Z_COMMON_CD_VALUES]; /*internal client data values */
unsigned *cd_values; /*client data values */
-} H5Z_filter_info_t;
+};
/*****************************/
/* Library-private Variables */
diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h
index f6b313e..fcb2d37 100644
--- a/src/H5Zpublic.h
+++ b/src/H5Zpublic.h
@@ -129,8 +129,8 @@ typedef H5Z_cb_return_t (*H5Z_filter_func_t)(H5Z_filter_t filter, void* buf,
/* Structure for filter callback property */
typedef struct H5Z_cb_t {
- H5Z_filter_func_t func;
- void* op_data;
+ H5Z_filter_func_t func;
+ void *op_data;
} H5Z_cb_t;
#ifdef __cplusplus
@@ -206,14 +206,14 @@ typedef size_t (*H5Z_func_t)(unsigned int flags, size_t cd_nelmts,
* contain a pointers to the filter function and timing statistics.
*/
typedef struct H5Z_class2_t {
- int version; /* Version number of the H5Z_class_t struct */
- H5Z_filter_t id; /* Filter ID number */
- unsigned encoder_present; /* Does this filter have an encoder? */
- unsigned decoder_present; /* Does this filter have a decoder? */
- const char *name; /* Comment for debugging */
- H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */
- H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */
- H5Z_func_t filter; /* The actual filter function */
+ int version; /* Version number of the H5Z_class_t struct */
+ H5Z_filter_t id; /* Filter ID number */
+ unsigned encoder_present; /* Does this filter have an encoder? */
+ unsigned decoder_present; /* Does this filter have a decoder? */
+ const char *name; /* Comment for debugging */
+ H5Z_can_apply_func_t can_apply; /* The "can apply" callback for a filter */
+ H5Z_set_local_func_t set_local; /* The "set local" callback for a filter */
+ H5Z_func_t filter; /* The actual filter function */
} H5Z_class2_t;
H5_DLL herr_t H5Zregister(const void *cls);
diff --git a/src/H5Zszip.c b/src/H5Zszip.c
index 769011c..0c60239 100644
--- a/src/H5Zszip.c
+++ b/src/H5Zszip.c
@@ -70,8 +70,6 @@ H5Z_class2_t H5Z_SZIP[1] = {{
* Programmer: Quincey Koziol
* Monday, April 7, 2003
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static htri_t
@@ -86,24 +84,24 @@ H5Z_can_apply_szip(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UN
/* Get datatype */
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Get datatype's size, for checking the "bits-per-pixel" */
if((dtype_size = (8 * H5T_get_size(type))) == 0)
- HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
+ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
/* Range check datatype's size */
if(dtype_size > 32 && dtype_size != 64)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype size")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype size")
/* Get datatype's endianness order */
if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR)
- HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order")
+ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order")
/* Range check datatype's endianness order */
/* (Note: this may not handle non-atomic datatypes well) */
if(dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -157,19 +155,19 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
/* Get datatype */
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
/* Get the filter's current parameters */
if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SZIP, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters")
/* Get datatype's size, for checking the "bits-per-pixel" */
if((dtype_size = (8 * H5T_get_size(type))) == 0)
- HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size");
+ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size");
/* Get datatype's precision, in case is less than full bits */
if((dtype_precision = H5T_get_precision(type)) == 0)
- HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision");
+ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision");
if(dtype_precision < dtype_size) {
dtype_offset = H5T_get_offset(type);
@@ -177,9 +175,9 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
dtype_precision = dtype_size;
} /* end if */
if(dtype_precision > 24) {
- if(dtype_precision <= 32)
+ if(dtype_precision <= 32)
dtype_precision = 32;
- else if(dtype_precision <= 64)
+ else if(dtype_precision <= 64)
dtype_precision = 64;
} /* end if */
@@ -227,7 +225,7 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
/* Get datatype's endianness order */
if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR)
- HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order")
+ HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order")
/* Set the correct endianness flag for szip */
/* (Note: this may not handle non-atomic datatypes well) */
@@ -241,13 +239,17 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id)
cd_values[H5Z_SZIP_PARM_MASK] |= SZ_MSB_OPTION_MASK;
break;
+ case H5T_ORDER_ERROR:
+ case H5T_ORDER_VAX:
+ case H5T_ORDER_MIXED:
+ case H5T_ORDER_NONE:
default:
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order")
} /* end switch */
/* Modify the filter's parameters for this dataset */
if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_SZIP, flags, H5Z_SZIP_TOTAL_NPARMS, cd_values) < 0)
- HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local szip parameters")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local szip parameters")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -266,10 +268,6 @@ done:
* Programmer: Kent Yang
* Tuesday, April 1, 2003
*
- * Modifications:
- * Quincey Koziol, April 2, 2003
- * Cleaned up code.
- *
*-------------------------------------------------------------------------
*/
static size_t
@@ -296,7 +294,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
/* Check arguments */
if (cd_nelmts!=4)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid number of filter parameters")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid number of filter parameters")
/* Copy the filter parameters into the szip parameter block */
H5_CHECKED_ASSIGN(sz_param.options_mask, int, cd_values[H5Z_SZIP_PARM_MASK], unsigned);
@@ -310,12 +308,12 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
size_t nalloc; /* Number of bytes the compressed block will expand into */
/* Get the size of the uncompressed buffer */
- newbuf = *buf;
+ newbuf = (unsigned char *)(*buf);
UINT32DECODE(newbuf,stored_nalloc);
H5_CHECKED_ASSIGN(nalloc, size_t, stored_nalloc, uint32_t);
/* Allocate space for the uncompressed buffer */
- if(NULL==(outbuf = H5MM_malloc(nalloc)))
+ if(NULL == (outbuf = (unsigned char *)H5MM_malloc(nalloc)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for szip decompression")
/* Decompress the buffer */
@@ -338,7 +336,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
unsigned char *dst = NULL; /* Temporary pointer to new output buffer */
/* Allocate space for the compressed buffer & header (assume data won't get bigger) */
- if(NULL==(dst=outbuf = H5MM_malloc(nbytes+4)))
+ if(NULL == (dst=outbuf = (unsigned char *)H5MM_malloc(nbytes+4)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate szip destination buffer")
/* Encode the uncompressed length */
@@ -348,7 +346,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
/* Compress the buffer */
size_out = nbytes;
if(SZ_OK!= SZ_BufftoBuffCompress(dst, &size_out, *buf, nbytes, &sz_param))
- HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow")
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow")
HDassert(size_out<=nbytes);
/* Free the input buffer */
diff --git a/src/H5system.c b/src/H5system.c
index a1cdf19..a8726c2 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -977,7 +977,7 @@ Wround(double arg)
float
Wroundf(float arg)
{
- return arg < 0.0F ? HDceil(arg - 0.5F) : HDfloor(arg + 0.5F);
+ return (float)(arg < 0.0F ? HDceil(arg - 0.5F) : HDfloor(arg + 0.5F));
}
#endif /* H5_HAVE_WIN32_API */
diff --git a/src/Makefile.am b/src/Makefile.am
index 9a64717..d8d2cc2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -84,7 +84,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5Ochunk.c \
H5Ocont.c H5Ocopy.c H5Odbg.c H5Odrvinfo.c H5Odtype.c H5Oefl.c \
H5Ofill.c H5Oflush.c H5Ofsinfo.c H5Oginfo.c \
- H5Olayout.c \
+ H5Oint.c H5Olayout.c \
H5Olinfo.c H5Olink.c H5Omessage.c H5Omtime.c \
H5Oname.c H5Onull.c H5Opline.c H5Orefcount.c \
H5Osdspace.c H5Oshared.c \
@@ -98,7 +98,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \
H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \
H5PB.c \
H5PL.c H5PLint.c H5PLpath.c H5PLplugin_cache.c \
- H5R.c H5Rdeprec.c \
+ H5R.c H5Rint.c H5Rdeprec.c \
H5UC.c \
H5RS.c \
H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Snone.c H5Spoint.c \
diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in
index 8017594..51b24dc 100644
--- a/src/libhdf5.settings.in
+++ b/src/libhdf5.settings.in
@@ -28,6 +28,7 @@ Linking Options:
AM_LDFLAGS: @AM_LDFLAGS@
Extra libraries: @LIBS@
Archiver: @AR@
+ AR_FLAGS: @AR_FLAGS@
Ranlib: @RANLIB@
Languages: