summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2015-12-30 18:50:01 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2015-12-30 18:50:01 (GMT)
commit528ab9b810102a7cc7773c6403c8b2be6578d380 (patch)
treea7e40e1cdbd5155e0556be335ab4db8e4d7ae6d5 /src
parentc6949efd4fd5f5757f2d0443d51e4d635485595b (diff)
downloadhdf5-528ab9b810102a7cc7773c6403c8b2be6578d380.zip
hdf5-528ab9b810102a7cc7773c6403c8b2be6578d380.tar.gz
hdf5-528ab9b810102a7cc7773c6403c8b2be6578d380.tar.bz2
[svn-r28756] Description:
Minor code neatening and cleanups (same as r28755) on revise_chunks branch. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (Too minor for h5committest)
Diffstat (limited to 'src')
-rw-r--r--src/H5Dchunk.c40
-rw-r--r--src/H5Dpkg.h10
2 files changed, 29 insertions, 21 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 2e000e3..6b99a43 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -1034,9 +1034,8 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline)
FUNC_ENTER_STATIC_NOERR
HDassert(size);
- HDassert(pline);
- if(pline->nused > 0)
+ if(pline && pline->nused)
ret_value = H5MM_malloc(size);
else
ret_value = H5FL_BLK_MALLOC(chunk, size);
@@ -1064,10 +1063,8 @@ H5D__chunk_mem_xfree(void *chk, const H5O_pline_t *pline)
{
FUNC_ENTER_STATIC_NOERR
- HDassert(pline);
-
if(chk) {
- if(pline->nused > 0)
+ if(pline && pline->nused)
H5MM_xfree(chk);
else
chk = H5FL_BLK_FREE(chunk, chk);
@@ -1751,6 +1748,7 @@ H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_
FUNC_ENTER_PACKAGE
+ /* Sanity check */
HDassert(io_info);
HDassert(dataset);
@@ -2551,13 +2549,14 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled,
H5D_chunk_ud_t *udata)
{
H5D_rdcc_ent_t *ent = NULL; /* Cache entry */
- hbool_t found = FALSE; /* In cache? */
- unsigned u; /* Counter */
H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk);
- herr_t ret_value = SUCCEED; /* Return value */
+ unsigned idx; /* Index of chunk in cache, if present */
+ hbool_t found = FALSE; /* In cache? */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
+ /* Sanity checks */
HDassert(dset);
HDassert(dset->shared->layout.u.chunk.ndims > 0);
H5D_CHUNK_STORAGE_INDEX_CHK(sc);
@@ -2567,7 +2566,7 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled,
/* Initialize the query information about the chunk we are looking for */
udata->common.layout = &(dset->shared->layout.u.chunk);
udata->common.storage = &(dset->shared->layout.storage.u.chunk);
- udata->common.scaled = scaled;
+ udata->common.scaled = scaled;
/* Reset information about the chunk we are looking for */
udata->chunk_block.offset = HADDR_UNDEF;
@@ -2576,19 +2575,29 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled,
/* Check for chunk in cache */
if(dset->shared->cache.chunk.nslots > 0) {
- udata->idx_hint = H5D__chunk_hash_val(dset->shared, scaled);
- ent = dset->shared->cache.chunk.slot[udata->idx_hint];
+ /* Determine the chunk's location in the hash table */
+ idx = H5D__chunk_hash_val(dset->shared, scaled);
+
+ /* Get the chunk cache entry for that location */
+ ent = dset->shared->cache.chunk.slot[idx];
+ if(ent) {
+ unsigned u; /* Counter */
+
+ /* Speculatively set the 'found' flag */
+ found = TRUE;
- if(ent)
- for(u = 0, found = TRUE; u < dset->shared->ndims; u++)
+ /* Verify that the cache entry is the correct chunk */
+ for(u = 0; u < dset->shared->ndims; u++)
if(scaled[u] != ent->scaled[u]) {
found = FALSE;
break;
} /* end if */
+ } /* end if */
} /* end if */
- /* Find chunk addr */
+ /* Retrieve chunk addr */
if(found) {
+ udata->idx_hint = idx;
udata->chunk_block.offset = ent->chunk_block.offset;
udata->chunk_block.length = ent->chunk_block.length;;
udata->chunk_idx = ent->chunk_idx;
@@ -3287,6 +3296,7 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata,
FUNC_ENTER_PACKAGE
+ /* Sanity check */
HDassert(io_info);
HDassert(udata);
@@ -3294,8 +3304,6 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata,
/*
* It's not in the cache, probably because it's too big. If it's
* dirty then flush it to disk. In any case, free the chunk.
- * Note: we have to copy the layout and filter messages so we
- * don't discard the `const' qualifier.
*/
if(dirty) {
H5D_rdcc_ent_t fake_ent; /* "fake" chunk cache entry */
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index 06e763c..4e6376b 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -250,7 +250,6 @@ typedef struct H5D_chunk_rec_t {
* to which the index points.
*/
typedef struct H5D_chunk_common_ud_t {
- /* downward */
const H5O_layout_chunk_t *layout; /* Chunk layout description */
const H5O_storage_chunk_t *storage; /* Chunk storage description */
const hsize_t *scaled; /* Scaled coordinates for a chunk */
@@ -258,13 +257,14 @@ typedef struct H5D_chunk_common_ud_t {
/* B-tree callback info for various operations */
typedef struct H5D_chunk_ud_t {
+ /* Downward */
H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */
/* Upward */
- unsigned idx_hint; /*index of chunk in cache, if present */
- H5F_block_t chunk_block; /*offset/length of chunk in file */
- unsigned filter_mask; /*excluded filters */
- hsize_t chunk_idx; /*chunk index for EA, FA indexing */
+ unsigned idx_hint; /* Index of chunk in cache, if present */
+ H5F_block_t chunk_block; /* Offset/length of chunk in file */
+ unsigned filter_mask; /* Excluded filters */
+ hsize_t chunk_idx; /* Chunk index for EA, FA indexing */
} H5D_chunk_ud_t;
/* Typedef for "generic" chunk callbacks */