summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-07-18 00:18:42 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-07-18 00:18:42 (GMT)
commitbb19817c9fd5d46cdc1ab5a396f38f0561dfa167 (patch)
tree69498cabeabf6f68faa23b835e24cb7ef4f80563 /src
parentc8f4641507bf4ca85c70c39c786c07f8ef4a24ed (diff)
downloadhdf5-bb19817c9fd5d46cdc1ab5a396f38f0561dfa167.zip
hdf5-bb19817c9fd5d46cdc1ab5a396f38f0561dfa167.tar.gz
hdf5-bb19817c9fd5d46cdc1ab5a396f38f0561dfa167.tar.bz2
[svn-r30189] Description:
Clean up more warnings: drop the warning count from ~1310 down to ~940, with only 31 types of warnings in 148 files (down from 38 types in 167 files). Tested on: MacOSX/64 10.11.5 (amazon) w/serial & parallel (h5committest forthcoming)
Diffstat (limited to 'src')
-rw-r--r--src/H5Dchunk.c19
-rw-r--r--src/H5Dfill.c25
-rw-r--r--src/H5Dio.c37
-rw-r--r--src/H5Dscatgath.c333
-rw-r--r--src/H5Dselect.c84
-rw-r--r--src/H5FDfamily.c44
-rw-r--r--src/H5FL.c18
-rw-r--r--src/H5FLprivate.h12
-rw-r--r--src/H5HFcache.c4
-rw-r--r--src/H5Oalloc.c5
-rw-r--r--src/H5Ocache.c4
-rw-r--r--src/H5Pfapl.c2
-rw-r--r--src/H5Shyper.c60
-rw-r--r--src/H5Sselect.c111
-rw-r--r--src/H5system.c29
-rw-r--r--src/H5timer.c38
16 files changed, 475 insertions, 350 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 8cf86ac..dde83fe 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -364,6 +364,9 @@ H5FL_DEFINE(H5D_chunk_info_t);
/* Declare a free list to manage the chunk sequence information */
H5FL_BLK_DEFINE_STATIC(chunk);
+/* Declare extern free list to manage the H5S_sel_iter_t struct */
+H5FL_EXTERN(H5S_sel_iter_t);
+
/*-------------------------------------------------------------------------
* Function: H5D__chunk_direct_write
@@ -4557,14 +4560,14 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk)
const H5O_layout_t *layout = &(dset->shared->layout); /* Dataset's layout */
unsigned rank = udata->common.layout->ndims - 1; /* Dataset rank */
const hsize_t *scaled = udata->common.scaled; /* Scaled chunk offset */
- H5S_sel_iter_t chunk_iter; /* Memory selection iteration info */
+ H5S_sel_iter_t *chunk_iter = NULL; /* Memory selection iteration info */
+ hbool_t chunk_iter_init = FALSE; /* Whether the chunk iterator has been initialized */
hssize_t sel_nelmts; /* Number of elements in selection */
hsize_t count[H5O_LAYOUT_NDIMS]; /* Element count of hyperslab */
size_t chunk_size; /*size of a chunk */
void *chunk; /* The file chunk */
H5D_chunk_ud_t chk_udata; /* User data for locking chunk */
uint32_t bytes_accessed; /* Bytes accessed in chunk */
- hbool_t chunk_iter_init = FALSE; /* Whether the chunk iterator has been initialized */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
@@ -4629,13 +4632,17 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk)
if(H5D__fill_refill_vl(&udata->fb_info, (size_t)sel_nelmts, io_info->md_dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "can't refill fill value buffer")
+ /* Allocate the chunk selection iterator */
+ if(NULL == (chunk_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk selection iterator")
+
/* Create a selection iterator for scattering the elements to memory buffer */
- if(H5S_select_iter_init(&chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank]) < 0)
+ if(H5S_select_iter_init(chunk_iter, udata->chunk_space, layout->u.chunk.dim[rank]) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize chunk selection information")
chunk_iter_init = TRUE;
/* Scatter the data into memory */
- if(H5D__scatter_mem(udata->fb_info.fill_buf, udata->chunk_space, &chunk_iter, (size_t)sel_nelmts, io_info->dxpl_cache, chunk/*out*/) < 0)
+ if(H5D__scatter_mem(udata->fb_info.fill_buf, udata->chunk_space, chunk_iter, (size_t)sel_nelmts, io_info->dxpl_cache, chunk/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed")
@@ -4650,8 +4657,10 @@ H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata, hbool_t new_unfilt_chunk)
done:
/* Release the selection iterator */
- if(chunk_iter_init && H5S_SELECT_ITER_RELEASE(&chunk_iter) < 0)
+ if(chunk_iter_init && H5S_SELECT_ITER_RELEASE(chunk_iter) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(chunk_iter)
+ chunk_iter = H5FL_FREE(H5S_sel_iter_t, chunk_iter);
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__chunk_prune_fill */
diff --git a/src/H5Dfill.c b/src/H5Dfill.c
index e5b2161..50c964b 100644
--- a/src/H5Dfill.c
+++ b/src/H5Dfill.c
@@ -88,6 +88,9 @@ H5FL_BLK_DEFINE_STATIC(non_zero_fill);
/* Declare the free list to manage blocks of zero fill-value data */
H5FL_BLK_DEFINE_STATIC(zero_fill);
+/* Declare extern free list to manage the H5S_sel_iter_t struct */
+H5FL_EXTERN(H5S_sel_iter_t);
+
/*--------------------------------------------------------------------------
NAME
@@ -174,6 +177,8 @@ herr_t
H5D__fill(const void *fill, const H5T_t *fill_type, void *buf,
const H5T_t *buf_type, const H5S_t *space, hid_t dxpl_id)
{
+ H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info */
+ hbool_t mem_iter_init = FALSE; /* Whether the memory selection iterator has been initialized */
H5WB_t *elem_wb = NULL; /* Wrapped buffer for element data */
uint8_t elem_buf[H5T_ELEM_BUF_SIZE]; /* Buffer for element data */
H5WB_t *bkg_elem_wb = NULL; /* Wrapped buffer for background data */
@@ -246,7 +251,6 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf,
if(TRUE == H5T_detect_class(fill_type, H5T_VLEN, FALSE)) {
H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */
H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */
- H5S_sel_iter_t mem_iter; /* Memory selection iteration info */
hssize_t nelmts; /* Number of data elements */
/* Get the number of elements in the selection */
@@ -273,19 +277,18 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf,
if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache")
+ /* Allocate the chunk selection iterator */
+ if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory selection iterator")
+
/* Create a selection iterator for scattering the elements to memory buffer */
- if(H5S_select_iter_init(&mem_iter, space, dst_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, space, dst_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
+ mem_iter_init = TRUE;
/* Scatter the data into memory */
- if(H5D__scatter_mem(tmp_buf, space, &mem_iter, (size_t)nelmts, dxpl_cache, buf/*out*/) < 0) {
- H5S_SELECT_ITER_RELEASE(&mem_iter);
+ if(H5D__scatter_mem(tmp_buf, space, mem_iter, (size_t)nelmts, dxpl_cache, buf/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed")
- } /* end if */
-
- /* Release the selection iterator */
- if(H5S_SELECT_ITER_RELEASE(&mem_iter) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
} /* end if */
else {
const uint8_t *fill_buf; /* Buffer to use for writing fill values */
@@ -335,6 +338,10 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf,
} /* end else */
done:
+ if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(mem_iter)
+ mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter);
if(src_id != (-1) && H5I_dec_ref(src_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(dst_id != (-1) && H5I_dec_ref(dst_id) < 0)
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 5004132..f5087da 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -87,6 +87,9 @@ static herr_t H5D__typeinfo_term(const H5D_type_info_t *type_info);
/* Declare a free list to manage blocks of type conversion data */
H5FL_BLK_DEFINE(type_conv);
+/* Declare a free list to manage the H5D_chunk_map_t struct */
+H5FL_DEFINE(H5D_chunk_map_t);
+
/*-------------------------------------------------------------------------
@@ -366,7 +369,7 @@ herr_t
H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
const H5S_t *file_space, hid_t dxpl_id, void *buf/*out*/)
{
- H5D_chunk_map_t fm; /* Chunk file<->memory mapping */
+ H5D_chunk_map_t *fm = NULL; /* Chunk file<->memory mapping */
H5D_io_info_t io_info; /* Dataset I/O info */
H5D_type_info_t type_info; /* Datatype info for operation */
hbool_t type_info_init = FALSE; /* Whether the datatype info has been initialized */
@@ -523,26 +526,31 @@ H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
|| dataset->shared->dcpl_cache.efl.nused > 0
|| dataset->shared->layout.type == H5D_COMPACT);
+ /* Allocate the chunk map */
+ if(NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk map")
+
/* Call storage method's I/O initialization routine */
- HDmemset(&fm, 0, sizeof(H5D_chunk_map_t));
- if(io_info.layout_ops.io_init && (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, &fm) < 0)
+ if(io_info.layout_ops.io_init && (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info")
io_op_init = TRUE;
#ifdef H5_HAVE_PARALLEL
/* Adjust I/O info for any parallel I/O */
- if(H5D__ioinfo_adjust(&io_info, dataset, dxpl_id, file_space, mem_space, &type_info, &fm) < 0)
+ if(H5D__ioinfo_adjust(&io_info, dataset, dxpl_id, file_space, mem_space, &type_info, fm) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to adjust I/O info for parallel I/O")
#endif /*H5_HAVE_PARALLEL*/
/* Invoke correct "high level" I/O routine */
- if((*io_info.io_ops.multi_read)(&io_info, &type_info, nelmts, file_space, mem_space, &fm) < 0)
+ if((*io_info.io_ops.multi_read)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
done:
/* Shut down the I/O op information */
- if(io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(&fm) < 0)
+ if(io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(fm) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info")
+ if(fm)
+ fm = H5FL_FREE(H5D_chunk_map_t, fm);
if(io_info_init) {
#ifdef H5_DEBUG_BUILD
@@ -587,7 +595,7 @@ herr_t
H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
const H5S_t *file_space, hid_t dxpl_id, const void *buf)
{
- H5D_chunk_map_t fm; /* Chunk file<->memory mapping */
+ H5D_chunk_map_t *fm = NULL; /* Chunk file<->memory mapping */
H5D_io_info_t io_info; /* Dataset I/O info */
H5D_type_info_t type_info; /* Datatype info for operation */
hbool_t type_info_init = FALSE; /* Whether the datatype info has been initialized */
@@ -765,20 +773,23 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize storage")
} /* end if */
+ /* Allocate the chunk map */
+ if(NULL == (fm = H5FL_CALLOC(H5D_chunk_map_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate chunk map")
+
/* Call storage method's I/O initialization routine */
- HDmemset(&fm, 0, sizeof(H5D_chunk_map_t));
- if(io_info.layout_ops.io_init && (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, &fm) < 0)
+ if(io_info.layout_ops.io_init && (*io_info.layout_ops.io_init)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize I/O info")
io_op_init = TRUE;
#ifdef H5_HAVE_PARALLEL
/* Adjust I/O info for any parallel I/O */
- if(H5D__ioinfo_adjust(&io_info, dataset, dxpl_id, file_space, mem_space, &type_info, &fm) < 0)
+ if(H5D__ioinfo_adjust(&io_info, dataset, dxpl_id, file_space, mem_space, &type_info, fm) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to adjust I/O info for parallel I/O")
#endif /*H5_HAVE_PARALLEL*/
/* Invoke correct "high level" I/O routine */
- if((*io_info.io_ops.multi_write)(&io_info, &type_info, nelmts, file_space, mem_space, &fm) < 0)
+ if((*io_info.io_ops.multi_write)(&io_info, &type_info, nelmts, file_space, mem_space, fm) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")
#ifdef OLD_WAY
@@ -801,8 +812,10 @@ H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space,
done:
/* Shut down the I/O op information */
- if(io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(&fm) < 0)
+ if(io_op_init && io_info.layout_ops.io_term && (*io_info.layout_ops.io_term)(fm) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, FAIL, "unable to shut down I/O op info")
+ if(fm)
+ fm = H5FL_FREE(H5D_chunk_map_t, fm);
if(io_info_init) {
#ifdef H5_DEBUG_BUILD
diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c
index 7c1abca..55111f0 100644
--- a/src/H5Dscatgath.c
+++ b/src/H5Dscatgath.c
@@ -67,10 +67,13 @@ static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type
/* Local Variables */
/*******************/
-/* Declare a free list to manage sequences of size_t */
+/* Declare extern free list to manage the H5S_sel_iter_t struct */
+H5FL_EXTERN(H5S_sel_iter_t);
+
+/* Declare extern free list to manage sequences of size_t */
H5FL_SEQ_EXTERN(size_t);
-/* Declare a free list to manage sequences of hsize_t */
+/* Declare extern free list to manage sequences of hsize_t */
H5FL_SEQ_EXTERN(hsize_t);
@@ -97,17 +100,16 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
const void *_buf)
{
H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
- hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
hsize_t *off = NULL; /* Pointer to sequence offsets */
hsize_t mem_off; /* Offset in memory */
size_t mem_curr_seq; /* "Current sequence" in memory */
size_t dset_curr_seq; /* "Current sequence" in dataset */
- size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
size_t *len = NULL; /* Array to store sequence lengths */
size_t orig_mem_len, mem_len; /* Length of sequence in memory */
- size_t nseq; /* Number of sequences generated */
- size_t nelem; /* Number of elements used in sequences */
- herr_t ret_value = SUCCEED; /* Return value */
+ size_t nseq; /* Number of sequences generated */
+ size_t nelem; /* Number of elements used in sequences */
+ size_t vec_size; /* Vector length */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -124,21 +126,19 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
tmp_io_info.u.wbuf = _buf;
/* Allocate the vector I/O arrays */
- if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, tmp_io_info.dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array")
- if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, tmp_io_info.dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- len = _len;
- off = _off;
- } /* end else */
+ if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = tmp_io_info.dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array")
/* Loop until all elements are written */
while(nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, tmp_io_info.dxpl_cache->vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Reset the current sequence information */
@@ -160,9 +160,9 @@ H5D__scatter_file(const H5D_io_info_t *_io_info,
done:
/* Release resources, if allocated */
- if(len && len != _len)
+ if(len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off && off != _off)
+ if(off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
@@ -196,16 +196,15 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
void *_buf/*out*/)
{
H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
- hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
hsize_t *off = NULL; /* Pointer to sequence offsets */
hsize_t mem_off; /* Offset in memory */
size_t mem_curr_seq; /* "Current sequence" in memory */
size_t dset_curr_seq; /* "Current sequence" in dataset */
- size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
size_t *len = NULL; /* Pointer to sequence lengths */
size_t orig_mem_len, mem_len; /* Length of sequence in memory */
size_t nseq; /* Number of sequences generated */
size_t nelem; /* Number of elements used in sequences */
+ size_t vec_size; /* Vector length */
size_t ret_value = nelmts; /* Return value */
FUNC_ENTER_STATIC
@@ -225,21 +224,19 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
tmp_io_info.u.rbuf = _buf;
/* Allocate the vector I/O arrays */
- if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, tmp_io_info.dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O length vector array")
- if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, tmp_io_info.dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- len = _len;
- off = _off;
- } /* end else */
+ if(tmp_io_info.dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = tmp_io_info.dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O offset vector array")
/* Loop until all elements are read */
while(nelmts > 0) {
/* Get list of sequences for selection to read */
- if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, tmp_io_info.dxpl_cache->vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, H5S_GET_SEQ_LIST_SORTED, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Reset the current sequence information */
@@ -261,9 +258,9 @@ H5D__gather_file(const H5D_io_info_t *_io_info,
done:
/* Release resources, if allocated */
- if(len && len != _len)
+ if(len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off && off != _off)
+ if(off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
@@ -292,15 +289,14 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
{
uint8_t *buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */
const uint8_t *tscat_buf = (const uint8_t *)_tscat_buf;
- hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
- hsize_t *off = NULL; /* Pointer to sequence offsets */
- size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
- size_t *len = NULL; /* Pointer to sequence lengths */
+ hsize_t *off = NULL; /* Pointer to sequence offsets */
+ size_t *len = NULL; /* Pointer to sequence lengths */
size_t curr_len; /* Length of bytes left to process in sequence */
size_t nseq; /* Number of sequences generated */
size_t curr_seq; /* Current sequence being processed */
size_t nelem; /* Number of elements used in sequences */
- herr_t ret_value = SUCCEED; /* Number of elements scattered */
+ size_t vec_size; /* Vector length */
+ herr_t ret_value = SUCCEED; /* Number of elements scattered */
FUNC_ENTER_PACKAGE
@@ -312,21 +308,19 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
HDassert(buf);
/* Allocate the vector I/O arrays */
- if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array")
- if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- len = _len;
- off = _off;
- } /* end else */
+ if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array")
/* Loop until all elements are written */
while(nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, dxpl_cache->vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -346,9 +340,9 @@ H5D__scatter_mem (const void *_tscat_buf, const H5S_t *space,
done:
/* Release resources, if allocated */
- if(len && len != _len)
+ if(len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off && off != _off)
+ if(off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
@@ -379,15 +373,14 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
{
const uint8_t *buf = (const uint8_t *)_buf; /* Get local copies for address arithmetic */
uint8_t *tgath_buf = (uint8_t *)_tgath_buf;
- hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
hsize_t *off = NULL; /* Pointer to sequence offsets */
- size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
- size_t *len = NULL; /* Pointer to sequence lengths */
+ size_t *len = NULL; /* Pointer to sequence lengths */
size_t curr_len; /* Length of bytes left to process in sequence */
size_t nseq; /* Number of sequences generated */
size_t curr_seq; /* Current sequence being processed */
size_t nelem; /* Number of elements used in sequences */
- size_t ret_value = nelmts; /* Number of elements gathered */
+ size_t vec_size; /* Vector length */
+ size_t ret_value = nelmts; /* Number of elements gathered */
FUNC_ENTER_STATIC
@@ -399,21 +392,19 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
HDassert(tgath_buf);
/* Allocate the vector I/O arrays */
- if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O length vector array")
- if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- len = _len;
- off = _off;
- } /* end else */
+ if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, 0, "can't allocate I/O offset vector array")
/* Loop until all elements are written */
while(nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, dxpl_cache->vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -433,9 +424,9 @@ H5D__gather_mem(const void *_buf, const H5S_t *space,
done:
/* Release resources, if allocated */
- if(len && len != _len)
+ if(len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off && off != _off)
+ if(off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
@@ -460,15 +451,15 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
{
const H5D_dxpl_cache_t *dxpl_cache = io_info->dxpl_cache; /* Local pointer to dataset transfer info */
void *buf = io_info->u.rbuf; /* Local pointer to application buffer */
- H5S_sel_iter_t mem_iter; /*memory selection iteration info*/
- hbool_t mem_iter_init = FALSE; /*memory selection iteration info has been initialized */
- H5S_sel_iter_t bkg_iter; /*background iteration info*/
- hbool_t bkg_iter_init = FALSE; /*background iteration info has been initialized */
- H5S_sel_iter_t file_iter; /*file selection iteration info*/
- hbool_t file_iter_init = FALSE; /*file selection iteration info has been initialized */
- hsize_t smine_start; /*strip mine start loc */
- size_t smine_nelmts; /*elements per strip */
- herr_t ret_value = SUCCEED; /*return value */
+ H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/
+ hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */
+ H5S_sel_iter_t *bkg_iter = NULL; /* Background iteration info*/
+ hbool_t bkg_iter_init = FALSE; /* Background iteration info has been initialized */
+ H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info*/
+ hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */
+ hsize_t smine_start; /* Strip mine start loc */
+ size_t smine_nelmts; /* Elements per strip */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -483,14 +474,22 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
if(nelmts == 0)
HGOTO_DONE(SUCCEED)
+ /* Allocate the iterators */
+ if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator")
+ if(NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate background iterator")
+ if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
+
/* Figure out the strip mine size. */
- if(H5S_select_iter_init(&file_iter, file_space, type_info->src_type_size) < 0)
+ if(H5S_select_iter_init(file_iter, file_space, type_info->src_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
file_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(&mem_iter, mem_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, mem_space, type_info->dst_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(&bkg_iter, mem_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(bkg_iter, mem_space, type_info->dst_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information")
bkg_iter_init = TRUE; /*file selection iteration info has been initialized */
@@ -499,7 +498,7 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
size_t n; /* Elements operated on */
/* Go figure out how many elements to read from the file */
- HDassert(H5S_SELECT_ITER_NELMTS(&file_iter) == (nelmts - smine_start));
+ HDassert(H5S_SELECT_ITER_NELMTS(file_iter) == (nelmts - smine_start));
smine_nelmts = (size_t)MIN(type_info->request_nelmts, (nelmts - smine_start));
/*
@@ -511,8 +510,7 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/*
* Gather data
*/
- n = H5D__gather_file(io_info, file_space, &file_iter, smine_nelmts,
- type_info->tconv_buf/*out*/);
+ n = H5D__gather_file(io_info, file_space, file_iter, smine_nelmts, type_info->tconv_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed")
@@ -521,14 +519,12 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
* bypass the rest of steps.
*/
if(type_info->cmpd_subset && H5T_SUBSET_FALSE != type_info->cmpd_subset->subset) {
- if(H5D__compound_opt_read(smine_nelmts, mem_space, &mem_iter, dxpl_cache,
- type_info, buf /*out*/) < 0)
+ if(H5D__compound_opt_read(smine_nelmts, mem_space, mem_iter, dxpl_cache, type_info, buf /*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "datatype conversion failed")
} /* end if */
else {
if(H5T_BKG_YES == type_info->need_bkg) {
- n = H5D__gather_mem(buf, mem_space, &bkg_iter, smine_nelmts,
- dxpl_cache, type_info->bkg_buf/*out*/);
+ n = H5D__gather_mem(buf, mem_space, bkg_iter, smine_nelmts, dxpl_cache, type_info->bkg_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "mem gather failed")
} /* end if */
@@ -549,26 +545,25 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
/*
* Scatter the data into memory.
*/
- if(H5D__scatter_mem(type_info->tconv_buf, mem_space, &mem_iter,
- smine_nelmts, dxpl_cache, buf/*out*/) < 0)
+ if(H5D__scatter_mem(type_info->tconv_buf, mem_space, mem_iter, smine_nelmts, dxpl_cache, buf/*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed")
} /* end else */
} /* end for */
done:
/* Release selection iterators */
- if(file_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&file_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
- if(mem_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&mem_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
- if(bkg_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&bkg_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
+ if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(file_iter)
+ file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter);
+ if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(mem_iter)
+ mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter);
+ if(bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(bkg_iter)
+ bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__scatgath_read() */
@@ -592,15 +587,15 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
{
const H5D_dxpl_cache_t *dxpl_cache = io_info->dxpl_cache; /* Local pointer to dataset transfer info */
const void *buf = io_info->u.wbuf; /* Local pointer to application buffer */
- H5S_sel_iter_t mem_iter; /*memory selection iteration info*/
- hbool_t mem_iter_init = FALSE; /*memory selection iteration info has been initialized */
- H5S_sel_iter_t bkg_iter; /*background iteration info*/
- hbool_t bkg_iter_init = FALSE; /*background iteration info has been initialized */
- H5S_sel_iter_t file_iter; /*file selection iteration info*/
- hbool_t file_iter_init = FALSE; /*file selection iteration info has been initialized */
- hsize_t smine_start; /*strip mine start loc */
- size_t smine_nelmts; /*elements per strip */
- herr_t ret_value = SUCCEED; /*return value */
+ H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info*/
+ hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */
+ H5S_sel_iter_t *bkg_iter = NULL; /* Background iteration info*/
+ hbool_t bkg_iter_init = FALSE; /* Background iteration info has been initialized */
+ H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info*/
+ hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */
+ hsize_t smine_start; /* Strip mine start loc */
+ size_t smine_nelmts; /* Elements per strip */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -615,14 +610,22 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
if(nelmts == 0)
HGOTO_DONE(SUCCEED)
+ /* Allocate the iterators */
+ if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator")
+ if(NULL == (bkg_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate background iterator")
+ if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
+
/* Figure out the strip mine size. */
- if(H5S_select_iter_init(&file_iter, file_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information")
file_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(&mem_iter, mem_space, type_info->src_type_size) < 0)
+ if(H5S_select_iter_init(mem_iter, mem_space, type_info->src_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information")
mem_iter_init = TRUE; /*file selection iteration info has been initialized */
- if(H5S_select_iter_init(&bkg_iter, file_space, type_info->dst_type_size) < 0)
+ if(H5S_select_iter_init(bkg_iter, file_space, type_info->dst_type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize background selection information")
bkg_iter_init = TRUE; /*file selection iteration info has been initialized */
@@ -631,7 +634,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
size_t n; /* Elements operated on */
/* Go figure out how many elements to read from the file */
- HDassert(H5S_SELECT_ITER_NELMTS(&file_iter) == (nelmts - smine_start));
+ HDassert(H5S_SELECT_ITER_NELMTS(file_iter) == (nelmts - smine_start));
smine_nelmts = (size_t)MIN(type_info->request_nelmts, (nelmts - smine_start));
/*
@@ -639,8 +642,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
* buffer. Also gather data from the file into the background buffer
* if necessary.
*/
- n = H5D__gather_mem(buf, mem_space, &mem_iter, smine_nelmts,
- dxpl_cache, type_info->tconv_buf/*out*/);
+ n = H5D__gather_mem(buf, mem_space, mem_iter, smine_nelmts, dxpl_cache, type_info->tconv_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed")
@@ -657,8 +659,7 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
} /* end if */
else {
if(H5T_BKG_YES == type_info->need_bkg) {
- n = H5D__gather_file(io_info, file_space, &bkg_iter, smine_nelmts,
- type_info->bkg_buf/*out*/);
+ n = H5D__gather_file(io_info, file_space, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/);
if(n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed")
} /* end if */
@@ -681,25 +682,24 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
/*
* Scatter the data out to the file.
*/
- if(H5D__scatter_file(io_info, file_space, &file_iter, smine_nelmts,
- type_info->tconv_buf) < 0)
+ if(H5D__scatter_file(io_info, file_space, file_iter, smine_nelmts, type_info->tconv_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "scatter failed")
} /* end for */
done:
/* Release selection iterators */
- if(file_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&file_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
- if(mem_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&mem_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
- if(bkg_iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&bkg_iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
+ if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(file_iter)
+ file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter);
+ if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(mem_iter)
+ mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter);
+ if(bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(bkg_iter)
+ bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__scatgath_write() */
@@ -744,12 +744,11 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
{
uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */
uint8_t *xdbuf; /* Pointer into dataset buffer */
- hsize_t _off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
hsize_t *off = NULL; /* Pointer to sequence offsets */
- size_t _len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
size_t *len = NULL; /* Pointer to sequence lengths */
size_t src_stride, dst_stride, copy_size;
- herr_t ret_value = SUCCEED; /*return value */
+ size_t vec_size; /* Vector length */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -765,16 +764,14 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
HDassert(user_buf);
/* Allocate the vector I/O arrays */
- if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array")
- if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- len = _len;
- off = _off;
- } /* end else */
+ if(dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array")
/* Get source & destination strides */
src_stride = type_info->src_type_size;
@@ -791,7 +788,7 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
size_t elmtno; /* Element counter */
/* Get list of sequences for selection to write */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, dxpl_cache->vec_size, nelmts, &nseq, &elmtno, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -827,9 +824,9 @@ H5D__compound_opt_read(size_t nelmts, const H5S_t *space,
done:
/* Release resources, if allocated */
- if(len && len != _len)
+ if(len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off && off != _off)
+ if(off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
@@ -923,7 +920,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
{
H5T_t *type; /* Datatype */
H5S_t *dst_space; /* Dataspace */
- H5S_sel_iter_t iter; /* Selection iteration info*/
+ H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/
hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */
const void *src_buf = NULL; /* Source (contiguous) data buffer */
size_t src_buf_nbytes = 0; /* Size of src_buf */
@@ -959,8 +956,12 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(dst_space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection")
+ /* Allocate the selection iterator */
+ if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
+
/* Initialize selection iterator */
- if(H5S_select_iter_init(&iter, dst_space, type_size) < 0)
+ if(H5S_select_iter_init(iter, dst_space, type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information")
iter_init = TRUE;
@@ -984,7 +985,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection")
/* Scatter data */
- if(H5D__scatter_mem(src_buf, dst_space, &iter, nelmts_scatter, dxpl_cache, dst_buf) < 0)
+ if(H5D__scatter_mem(src_buf, dst_space, iter, nelmts_scatter, dxpl_cache, dst_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed")
nelmts -= (hssize_t)nelmts_scatter;
@@ -992,10 +993,10 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
done:
/* Release selection iterator */
- if(iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
+ if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(iter)
+ iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_API(ret_value)
} /* H5Dscatter() */
@@ -1023,7 +1024,7 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
{
H5T_t *type; /* Datatype */
H5S_t *src_space; /* Dataspace */
- H5S_sel_iter_t iter; /* Selection iteration info*/
+ H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/
hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */
size_t type_size; /* Datatype element size */
hssize_t nelmts; /* Number of remaining elements in selection */
@@ -1071,15 +1072,19 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
if(((size_t)nelmts > dst_buf_nelmts) && (op == NULL))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback supplied and destination buffer too small")
+ /* Allocate the selection iterator */
+ if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
+
/* Initialize selection iterator */
- if(H5S_select_iter_init(&iter, src_space, type_size) < 0)
+ if(H5S_select_iter_init(iter, src_space, type_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information")
iter_init = TRUE;
/* Loop until all data has been scattered */
while(nelmts > 0) {
/* Gather data */
- if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, src_space, &iter, MIN(dst_buf_nelmts, (size_t)nelmts), dxpl_cache, dst_buf)))
+ if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, src_space, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dxpl_cache, dst_buf)))
HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed")
HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts));
@@ -1093,10 +1098,10 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
done:
/* Release selection iterator */
- if(iter_init) {
- if(H5S_SELECT_ITER_RELEASE(&iter) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- } /* end if */
+ if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
+ if(iter)
+ iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_API(ret_value)
} /* H5Dgather() */
diff --git a/src/H5Dselect.c b/src/H5Dselect.c
index 312beba..53829e5 100644
--- a/src/H5Dselect.c
+++ b/src/H5Dselect.c
@@ -68,6 +68,9 @@ H5FL_SEQ_DEFINE(size_t);
/* Declare a free list to manage sequences of hsize_t */
H5FL_SEQ_DEFINE(hsize_t);
+/* Declare extern free list to manage the H5S_sel_iter_t struct */
+H5FL_EXTERN(H5S_sel_iter_t);
+
/*-------------------------------------------------------------------------
@@ -86,22 +89,19 @@ static herr_t
H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
size_t nelmts, const H5S_t *file_space, const H5S_t *mem_space)
{
- H5S_sel_iter_t mem_iter; /* Memory selection iteration info */
- hbool_t mem_iter_init = 0; /* Memory selection iteration info has been initialized */
- H5S_sel_iter_t file_iter; /* File selection iteration info */
- hbool_t file_iter_init = 0; /* File selection iteration info has been initialized */
- hsize_t _mem_off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets in memory */
+ H5S_sel_iter_t *mem_iter = NULL; /* Memory selection iteration info */
+ hbool_t mem_iter_init = FALSE; /* Memory selection iteration info has been initialized */
+ H5S_sel_iter_t *file_iter = NULL; /* File selection iteration info */
+ hbool_t file_iter_init = FALSE; /* File selection iteration info has been initialized */
hsize_t *mem_off = NULL; /* Pointer to sequence offsets in memory */
- hsize_t _file_off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets in the file */
hsize_t *file_off = NULL; /* Pointer to sequence offsets in the file */
- size_t _mem_len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths in memory */
size_t *mem_len = NULL; /* Pointer to sequence lengths in memory */
- size_t _file_len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths in the file */
size_t *file_len = NULL; /* Pointer to sequence lengths in the file */
size_t curr_mem_seq; /* Current memory sequence to operate on */
size_t curr_file_seq; /* Current file sequence to operate on */
size_t mem_nseq; /* Number of sequences generated in the file */
size_t file_nseq; /* Number of sequences generated in memory */
+ size_t vec_size; /* Vector length */
ssize_t tmp_file_len; /* Temporary number of bytes in file sequence */
herr_t ret_value = SUCCEED; /* Return value */
@@ -115,22 +115,18 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
HDassert(io_info->u.rbuf);
/* Allocate the vector I/O arrays */
- if(io_info->dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE) {
- if(NULL == (mem_len = H5FL_SEQ_MALLOC(size_t,io_info->dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array")
- if(NULL == (mem_off = H5FL_SEQ_MALLOC(hsize_t,io_info->dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array")
- if(NULL == (file_len = H5FL_SEQ_MALLOC(size_t,io_info->dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O length vector array")
- if(NULL == (file_off = H5FL_SEQ_MALLOC(hsize_t,io_info->dxpl_cache->vec_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array")
- } /* end if */
- else {
- mem_len = _mem_len;
- mem_off = _mem_off;
- file_len = _file_len;
- file_off = _file_off;
- } /* end else */
+ if(io_info->dxpl_cache->vec_size > H5D_IO_VECTOR_SIZE)
+ vec_size = io_info->dxpl_cache->vec_size;
+ else
+ vec_size = H5D_IO_VECTOR_SIZE;
+ if(NULL == (mem_len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array")
+ if(NULL == (mem_off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array")
+ if(NULL == (file_len = H5FL_SEQ_MALLOC(size_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O length vector array")
+ if(NULL == (file_off = H5FL_SEQ_MALLOC(hsize_t, vec_size)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate I/O offset vector array")
/* Check for only one element in selection */
if(nelmts == 1) {
@@ -169,13 +165,19 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
size_t mem_nelem; /* Number of elements used in memory sequences */
size_t file_nelem; /* Number of elements used in file sequences */
+ /* Allocate the iterators */
+ if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate memory iterator")
+ if(NULL == (file_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate file iterator")
+
/* Initialize file iterator */
- if(H5S_select_iter_init(&file_iter, file_space, elmt_size) < 0)
+ if(H5S_select_iter_init(file_iter, file_space, elmt_size) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
file_iter_init = 1; /* File selection iteration info has been initialized */
/* Initialize memory iterator */
- if(H5S_select_iter_init(&mem_iter, mem_space, elmt_size) < 0)
+ if(H5S_select_iter_init(mem_iter, mem_space, elmt_size) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
mem_iter_init = 1; /* Memory selection iteration info has been initialized */
@@ -188,7 +190,7 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
/* Check if more file sequences are needed */
if(curr_file_seq >= file_nseq) {
/* Get sequences for file selection */
- if(H5S_SELECT_GET_SEQ_LIST(file_space, H5S_GET_SEQ_LIST_SORTED, &file_iter, io_info->dxpl_cache->vec_size, nelmts, &file_nseq, &file_nelem, file_off, file_len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(file_space, H5S_GET_SEQ_LIST_SORTED, file_iter, vec_size, nelmts, &file_nseq, &file_nelem, file_off, file_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Start at the beginning of the sequences again */
@@ -198,7 +200,7 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
/* Check if more memory sequences are needed */
if(curr_mem_seq >= mem_nseq) {
/* Get sequences for memory selection */
- if(H5S_SELECT_GET_SEQ_LIST(mem_space, 0, &mem_iter, io_info->dxpl_cache->vec_size, nelmts, &mem_nseq, &mem_nelem, mem_off, mem_len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(mem_space, 0, mem_iter, vec_size, nelmts, &mem_nseq, &mem_nelem, mem_off, mem_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Start at the beginning of the sequences again */
@@ -227,24 +229,24 @@ H5D__select_io(const H5D_io_info_t *io_info, size_t elmt_size,
} /* end else */
done:
- /* Release file selection iterator */
- if(file_iter_init)
- if(H5S_SELECT_ITER_RELEASE(&file_iter) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
-
- /* Release memory selection iterator */
- if(mem_iter_init)
- if(H5S_SELECT_ITER_RELEASE(&mem_iter) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ /* Release selection iterators */
+ if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ if(file_iter)
+ file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter);
+ if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ if(mem_iter)
+ mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter);
/* Release vector arrays, if allocated */
- if(file_len && file_len != _file_len)
+ if(file_len)
file_len = H5FL_SEQ_FREE(size_t, file_len);
- if(file_off && file_off != _file_off)
+ if(file_off)
file_off = H5FL_SEQ_FREE(hsize_t, file_off);
- if(mem_len && mem_len != _mem_len)
+ if(mem_len)
mem_len = H5FL_SEQ_FREE(size_t, mem_len);
- if(mem_off && mem_off != _mem_off)
+ if(mem_off)
mem_off = H5FL_SEQ_FREE(hsize_t, mem_off);
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index 3b38836..7ec8751 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -46,10 +46,8 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
-#undef MAX
-#define MAX(X,Y) ((X)>(Y)?(X):(Y))
-#undef MIN
-#define MIN(X,Y) ((X)<(Y)?(X):(Y))
+/* The size of the member name buffers */
+#define H5FD_FAM_MEMB_NAME_BUF_SIZE 4096
/* The driver identification number, initialized at runtime */
static hid_t H5FD_FAMILY_g = 0;
@@ -623,11 +621,11 @@ static H5FD_t *
H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
haddr_t maxaddr)
{
- H5FD_family_t *file=NULL;
- H5FD_t *ret_value=NULL;
- char memb_name[4096], temp[4096];
- hsize_t eof=HADDR_UNDEF;
+ H5FD_family_t *file = NULL;
+ char *memb_name = NULL, *temp = NULL;
+ hsize_t eof = HADDR_UNDEF;
unsigned t_flags = flags & ~H5F_ACC_CREAT;
+ H5FD_t *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
@@ -683,15 +681,21 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
file->name = H5MM_strdup(name);
file->flags = flags;
+ /* Allocate space for the string buffers */
+ if(NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "unable to allocate member name")
+ if(NULL == (temp = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "unable to allocate temporary member name")
+
/* Check that names are unique */
- HDsnprintf(memb_name, sizeof(memb_name), name, 0);
- HDsnprintf(temp, sizeof(temp), name, 1);
+ HDsnprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, 0);
+ HDsnprintf(temp, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, 1);
if(!HDstrcmp(memb_name, temp))
HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file names not unique")
/* Open all the family members */
while(1) {
- HDsnprintf(memb_name, sizeof(memb_name), name, file->nmembs);
+ HDsnprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, name, file->nmembs);
/* Enlarge member array */
if(file->nmembs >= file->amembs) {
@@ -732,6 +736,12 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
ret_value=(H5FD_t *)file;
done:
+ /* Release resources */
+ if(memb_name)
+ H5MM_xfree(memb_name);
+ if(temp)
+ H5MM_xfree(temp);
+
/* Cleanup and fail */
if(ret_value == NULL && file != NULL) {
unsigned nerrors = 0; /* Number of errors closing member files */
@@ -941,12 +951,16 @@ H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa)
{
H5FD_family_t *file = (H5FD_family_t*)_file;
haddr_t addr = abs_eoa;
- char memb_name[4096];
+ char *memb_name = NULL;
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
+ /* Allocate space for the member name buffer */
+ if(NULL == (memb_name = (char *)H5MM_malloc(H5FD_FAM_MEMB_NAME_BUF_SIZE)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, FAIL, "unable to allocate member name")
+
for(u = 0; addr || u < file->nmembs; u++) {
/* Enlarge member array */
@@ -964,7 +978,7 @@ H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa)
/* Create another file if necessary */
if(u >= file->nmembs || !file->memb[u]) {
file->nmembs = MAX(file->nmembs, u+1);
- HDsnprintf(memb_name, sizeof(memb_name), file->name, u);
+ HDsnprintf(memb_name, H5FD_FAM_MEMB_NAME_BUF_SIZE, file->name, u);
H5E_BEGIN_TRY {
H5_CHECK_OVERFLOW(file->memb_size, hsize_t, haddr_t);
file->memb[u] = H5FDopen(memb_name, file->flags | H5F_ACC_CREAT,
@@ -992,6 +1006,10 @@ H5FD_family_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t abs_eoa)
file->eoa = abs_eoa;
done:
+ /* Release resources */
+ if(memb_name)
+ H5MM_xfree(memb_name);
+
FUNC_LEAVE_NOAPI(ret_value)
}
diff --git a/src/H5FL.c b/src/H5FL.c
index 00cbf0c..db51809 100644
--- a/src/H5FL.c
+++ b/src/H5FL.c
@@ -293,7 +293,7 @@ H5FL_reg_init(H5FL_reg_head_t *head)
H5FL_reg_gc_head.first=new_node;
/* Indicate that the free list is initialized */
- head->init=1;
+ head->init = TRUE;
/* Make certain that the space allocated is large enough to store a free list pointer (eventually) */
if(head->size<sizeof(H5FL_reg_node_t))
@@ -655,7 +655,7 @@ printf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.fir
/* No allocations left open for list, get rid of it */
else {
/* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */
- H5FL_reg_gc_head.first->list->init = 0;
+ H5FL_reg_gc_head.first->list->init = FALSE;
/* Free the node from the garbage collection list */
H5MM_xfree(H5FL_reg_gc_head.first);
@@ -822,7 +822,7 @@ H5FL_blk_init(H5FL_blk_head_t *head)
H5FL_blk_gc_head.first=new_node;
/* Indicate that the PQ is initialized */
- head->init=1;
+ head->init = TRUE;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1326,7 +1326,7 @@ printf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.fir
/* No allocations left open for list, get rid of it */
else {
/* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */
- H5FL_blk_gc_head.first->pq->init = 0;
+ H5FL_blk_gc_head.first->pq->init = FALSE;
/* Free the node from the garbage collection list */
H5MM_free(H5FL_blk_gc_head.first);
@@ -1379,7 +1379,7 @@ H5FL_arr_init(H5FL_arr_head_t *head)
H5FL_arr_gc_head.first=new_node;
/* Allocate room for the free lists */
- if(NULL == (head->list_arr = (H5FL_arr_node_t *)H5MM_calloc((size_t)head->maxelem*sizeof(H5FL_arr_node_t))))
+ if(NULL == (head->list_arr = (H5FL_arr_node_t *)H5MM_calloc((size_t)head->maxelem * sizeof(H5FL_arr_node_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
/* Initialize the size of each array */
@@ -1387,7 +1387,7 @@ H5FL_arr_init(H5FL_arr_head_t *head)
head->list_arr[u].size = head->base_size + (head->elem_size * u);
/* Indicate that the free list is initialized */
- head->init = 1;
+ head->init = TRUE;
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1795,7 +1795,7 @@ printf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.fir
H5MM_xfree(H5FL_arr_gc_head.first->list->list_arr);
/* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */
- H5FL_arr_gc_head.first->list->init = 0;
+ H5FL_arr_gc_head.first->list->init = FALSE;
/* Free the node from the garbage collection list */
H5MM_free(H5FL_arr_gc_head.first);
@@ -2007,7 +2007,7 @@ H5FL_fac_init(size_t size)
#endif /* H5FL_TRACK */
/* Indicate that the free list is initialized */
- factory->init = 1;
+ factory->init = TRUE;
/* Set return value */
ret_value = factory;
@@ -2417,7 +2417,7 @@ printf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_hea
HDassert(H5FL_fac_gc_head.first->list->allocated == 0);
/* Reset the "initialized" flag, in case we restart this list somehow (I don't know how..) */
- H5FL_fac_gc_head.first->list->init = 0;
+ H5FL_fac_gc_head.first->list->init = FALSE;
/* Free the node from the garbage collection list */
H5FL_fac_gc_head.first = H5FL_FREE(H5FL_fac_gc_node_t, H5FL_fac_gc_head.first);
diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h
index 3cd30a6..f44d359 100644
--- a/src/H5FLprivate.h
+++ b/src/H5FLprivate.h
@@ -97,7 +97,7 @@ typedef struct H5FL_reg_node_t {
/* Data structure for free list of blocks */
typedef struct H5FL_reg_head_t {
- unsigned init; /* Whether the free list has been initialized */
+ hbool_t init; /* Whether the free list has been initialized */
unsigned allocated; /* Number of blocks allocated */
unsigned onlist; /* Number of blocks on free list */
const char *name; /* Name of the type */
@@ -166,9 +166,9 @@ typedef struct H5FL_blk_node_t {
/* Data structure for priority queue of native block free lists */
typedef struct H5FL_blk_head_t {
- unsigned init; /* Whether the free list has been initialized */
- unsigned allocated; /* Number of blocks allocated */
- unsigned onlist; /* Number of blocks on free list */
+ hbool_t init; /* Whether the free list has been initialized */
+ unsigned allocated; /* Number of blocks allocated */
+ unsigned onlist; /* Number of blocks on free list */
size_t list_mem; /* Amount of memory in block on free list */
const char *name; /* Name of the type */
H5FL_blk_node_t *head; /* Pointer to first free list in queue */
@@ -237,7 +237,7 @@ typedef struct H5FL_arr_node_t {
/* Data structure for free list of array blocks */
typedef struct H5FL_arr_head_t {
- unsigned init; /* Whether the free list has been initialized */
+ hbool_t init; /* Whether the free list has been initialized */
unsigned allocated; /* Number of blocks allocated */
size_t list_mem; /* Amount of memory in block on free list */
const char *name; /* Name of the type */
@@ -354,7 +354,7 @@ typedef struct H5FL_fac_node_t H5FL_fac_node_t;
/* Data structure for free list block factory */
typedef struct H5FL_fac_head_t {
- unsigned init; /* Whether the free list has been initialized */
+ hbool_t init; /* Whether the free list has been initialized */
unsigned allocated; /* Number of blocks allocated */
unsigned onlist; /* Number of blocks on free list */
size_t size; /* Size of the blocks in the list */
diff --git a/src/H5HFcache.c b/src/H5HFcache.c
index 759fff0..31ecc62 100644
--- a/src/H5HFcache.c
+++ b/src/H5HFcache.c
@@ -618,8 +618,8 @@ H5HF__cache_hdr_image_len(const void *_thing, size_t *image_len,
*-------------------------------------------------------------------------
*/
static herr_t
-H5HF__cache_hdr_pre_serialize(const H5F_t *f, hid_t dxpl_id, void *_thing,
- haddr_t addr, size_t len, size_t H5_ATTR_UNUSED compressed_len,
+H5HF__cache_hdr_pre_serialize(const H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id,
+ void *_thing, haddr_t addr, size_t len, size_t H5_ATTR_UNUSED compressed_len,
haddr_t H5_ATTR_UNUSED *new_addr, size_t H5_ATTR_UNUSED *new_len,
size_t H5_ATTR_UNUSED *new_compressed_len, unsigned *flags)
{
diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c
index 99f1322..69b4b11 100644
--- a/src/H5Oalloc.c
+++ b/src/H5Oalloc.c
@@ -763,7 +763,7 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size, size_t *new
size_t idx; /* Message number */
uint8_t *p = NULL; /*ptr into new chunk */
H5O_cont_t *cont = NULL; /*native continuation message */
- size_t chunkno; /* Chunk allocated */
+ unsigned chunkno; /* Chunk allocated */
haddr_t new_chunk_addr;
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
@@ -921,7 +921,8 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size, size_t *new
oh->chunk = x;
} /* end if */
- chunkno = (unsigned)oh->nchunks++;
+ H5_CHECKED_ASSIGN(chunkno, unsigned, oh->nchunks, size_t);
+ oh->nchunks++;
oh->chunk[chunkno].addr = new_chunk_addr;
oh->chunk[chunkno].size = size;
oh->chunk[chunkno].gap = 0;
diff --git a/src/H5Ocache.c b/src/H5Ocache.c
index fbbbe60..3803978 100644
--- a/src/H5Ocache.c
+++ b/src/H5Ocache.c
@@ -770,7 +770,7 @@ H5O__cache_chk_deserialize(const void *image, size_t len, void *_udata,
/* Set the fields for the chunk proxy */
chk_proxy->oh = udata->oh;
- chk_proxy->chunkno = udata->oh->nchunks - 1;
+ H5_CHECKED_ASSIGN(chk_proxy->chunkno, unsigned, udata->oh->nchunks - 1, size_t);
} /* end if */
else {
/* Sanity check */
@@ -1324,7 +1324,7 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image
/* Decode continuation message */
cont = (H5O_cont_t *)(H5O_MSG_CONT->decode)(udata->f, udata->dxpl_id, NULL, 0, &ioflags, oh->mesg[curmesg].raw);
- cont->chunkno = udata->cont_msg_info->nmsgs + 1; /*the next continuation message/chunk */
+ H5_CHECKED_ASSIGN(cont->chunkno, unsigned, udata->cont_msg_info->nmsgs + 1, size_t); /* the next continuation message/chunk */
/* Save 'native' form of continuation message */
oh->mesg[curmesg].native = cont;
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index a315f92..96de39c 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -778,7 +778,7 @@ done:
const void *
H5P_peek_driver_info(H5P_genplist_t *plist)
{
- void *ret_value = NULL; /* Return value */
+ const void *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI(NULL)
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index fe013a7..5231c6e 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -145,6 +145,9 @@ H5FL_DEFINE_STATIC(H5S_hyper_span_t);
/* Declare a free list to manage the H5S_hyper_span_info_t struct */
H5FL_DEFINE_STATIC(H5S_hyper_span_info_t);
+/* Declare extern free list to manage the H5S_sel_iter_t struct */
+H5FL_EXTERN(H5S_sel_iter_t);
+
/* #define H5S_HYPER_DEBUG */
#ifdef H5S_HYPER_DEBUG
static herr_t
@@ -9288,7 +9291,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
size_t ss_nelem; /* Number of elements for src_space */
size_t ss_i = (size_t)0; /* Index into offset/length arrays for src_space */
hbool_t advance_ss = FALSE; /* Whether to advance ss_i on the next iteration */
- H5S_sel_iter_t ss_iter; /* Selection iterator for src_space */
+ H5S_sel_iter_t *ss_iter = NULL; /* Selection iterator for src_space */
hbool_t ss_iter_init = FALSE; /* Whether ss_iter is initialized */
hsize_t ss_sel_off = (hsize_t)0; /* Offset within src_space selection */
hsize_t ds_off[H5S_PROJECT_INTERSECT_NSEQS]; /* Offset array for dst_space */
@@ -9296,7 +9299,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
size_t ds_nseq; /* Number of sequences for dst_space */
size_t ds_nelem; /* Number of elements for dst_space */
size_t ds_i = (size_t)0; /* Index into offset/length arrays for dst_space */
- H5S_sel_iter_t ds_iter; /* Selection iterator for dst_space */
+ H5S_sel_iter_t *ds_iter = NULL; /* Selection iterator for dst_space */
hbool_t ds_iter_init = FALSE; /* Whether ds_iter is initialized */
hsize_t ds_sel_off = (hsize_t)0; /* Offset within dst_space selection */
hsize_t sis_off[H5S_PROJECT_INTERSECT_NSEQS]; /* Offset array for src_intersect_space */
@@ -9305,7 +9308,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
size_t sis_nelem; /* Number of elements for src_intersect_space */
size_t sis_i = (size_t)0; /* Index into offset/length arrays for src_intersect_space */
hbool_t advance_sis = FALSE; /* Whether to advance sis_i on the next iteration */
- H5S_sel_iter_t sis_iter; /* Selection iterator for src_intersect_space */
+ H5S_sel_iter_t *sis_iter = NULL; /* Selection iterator for src_intersect_space */
hbool_t sis_iter_init = FALSE; /* Whether sis_iter is initialized */
hsize_t int_sel_off; /* Offset within intersected selections (ss/sis and ds/ps) */
size_t int_len; /* Length of segment in intersected selections */
@@ -9384,35 +9387,47 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
/* Set unlim_dim */
proj_space->select.sel_info.hslab->unlim_dim = -1;
+ /* Allocate the source space iterator */
+ if(NULL == (ss_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate source space iterator")
+
/* Initialize source space iterator */
- if(H5S_select_iter_init(&ss_iter, src_space, (size_t)1) < 0)
+ if(H5S_select_iter_init(ss_iter, src_space, (size_t)1) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
ss_iter_init = TRUE;
/* Get sequence list for source space */
- if(H5S_SELECT_GET_SEQ_LIST(src_space, 0u, &ss_iter, H5S_PROJECT_INTERSECT_NSEQS, ss_nelem, &ss_nseq, &nelem, ss_off, ss_len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(src_space, 0u, ss_iter, H5S_PROJECT_INTERSECT_NSEQS, ss_nelem, &ss_nseq, &nelem, ss_off, ss_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
ss_nelem -= nelem;
HDassert(ss_nseq > 0);
+ /* Allocate the destination space iterator */
+ if(NULL == (ds_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate destination space iterator")
+
/* Initialize destination space iterator */
- if(H5S_select_iter_init(&ds_iter, dst_space, (size_t)1) < 0)
+ if(H5S_select_iter_init(ds_iter, dst_space, (size_t)1) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
ds_iter_init = TRUE;
/* Get sequence list for destination space */
- if(H5S_SELECT_GET_SEQ_LIST(dst_space, 0u, &ds_iter, H5S_PROJECT_INTERSECT_NSEQS, ds_nelem, &ds_nseq, &nelem, ds_off, ds_len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(dst_space, 0u, ds_iter, H5S_PROJECT_INTERSECT_NSEQS, ds_nelem, &ds_nseq, &nelem, ds_off, ds_len) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
ds_nelem -= nelem;
HDassert(ds_nseq > 0);
+ /* Allocate the source intersect space iterator */
+ if(NULL == (sis_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate source intersect space iterator")
+
/* Initialize source intersect space iterator */
- if(H5S_select_iter_init(&sis_iter, src_intersect_space, (size_t)1) < 0)
+ if(H5S_select_iter_init(sis_iter, src_intersect_space, (size_t)1) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
sis_iter_init = TRUE;
/* Get sequence list for source intersect space */
- if(H5S_SELECT_GET_SEQ_LIST(src_intersect_space, 0u, &sis_iter, H5S_PROJECT_INTERSECT_NSEQS, sis_nelem, &sis_nseq, &nelem, sis_off, sis_len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(src_intersect_space, 0u, sis_iter, H5S_PROJECT_INTERSECT_NSEQS, sis_nelem, &sis_nseq, &nelem, sis_off, sis_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
sis_nelem -= nelem;
HDassert(sis_nseq > 0);
@@ -9427,7 +9442,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
if(++ss_i == ss_nseq) {
if(ss_nelem > 0) {
/* Try to grab more sequences from src_space */
- if(H5S_SELECT_GET_SEQ_LIST(src_space, 0u, &ss_iter, H5S_PROJECT_INTERSECT_NSEQS, ss_nelem, &ss_nseq, &nelem, ss_off, ss_len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(src_space, 0u, ss_iter, H5S_PROJECT_INTERSECT_NSEQS, ss_nelem, &ss_nseq, &nelem, ss_off, ss_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
HDassert(ss_len[0] > 0);
@@ -9459,7 +9474,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
if(sis_nelem > 0) {
/* Try to grab more sequences from src_intersect_space
*/
- if(H5S_SELECT_GET_SEQ_LIST(src_intersect_space, 0u, &sis_iter, H5S_PROJECT_INTERSECT_NSEQS, sis_nelem, &sis_nseq, &nelem, sis_off, sis_len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(src_intersect_space, 0u, sis_iter, H5S_PROJECT_INTERSECT_NSEQS, sis_nelem, &sis_nseq, &nelem, sis_off, sis_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
HDassert(sis_len[0] > 0);
@@ -9511,7 +9526,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
HDassert(ds_nelem > 0);
/* Try to grab more sequences from dst_space */
- if(H5S_SELECT_GET_SEQ_LIST(dst_space, 0u, &ds_iter, H5S_PROJECT_INTERSECT_NSEQS, ds_nelem, &ds_nseq, &nelem, ds_off, ds_len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(dst_space, 0u, ds_iter, H5S_PROJECT_INTERSECT_NSEQS, ds_nelem, &ds_nseq, &nelem, ds_off, ds_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
HDassert(ds_len[0] > 0);
@@ -9625,19 +9640,22 @@ loop_end:
done:
/* Release source selection iterator */
- if(ss_iter_init)
- if(H5S_SELECT_ITER_RELEASE(&ss_iter) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ if(ss_iter_init && H5S_SELECT_ITER_RELEASE(ss_iter) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ if(ss_iter)
+ ss_iter = H5FL_FREE(H5S_sel_iter_t, ss_iter);
/* Release destination selection iterator */
- if(ds_iter_init)
- if(H5S_SELECT_ITER_RELEASE(&ds_iter) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ if(ds_iter_init && H5S_SELECT_ITER_RELEASE(ds_iter) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ if(ds_iter)
+ ds_iter = H5FL_FREE(H5S_sel_iter_t, ds_iter);
/* Release source intersect selection iterator */
- if(sis_iter_init)
- if(H5S_SELECT_ITER_RELEASE(&sis_iter) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ if(sis_iter_init && H5S_SELECT_ITER_RELEASE(sis_iter) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ if(sis_iter)
+ sis_iter = H5FL_FREE(H5S_sel_iter_t, sis_iter);
/* Cleanup on error */
if(ret_value < 0) {
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index d4a4d69..2968bed 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -39,6 +39,15 @@ static htri_t H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter);
static herr_t H5S_select_iter_next_block(H5S_sel_iter_t *iter);
#endif /* LATER */
+/* Declare a free list to manage the H5S_sel_iter_t struct */
+H5FL_DEFINE(H5S_sel_iter_t);
+
+/* Declare extern free list to manage sequences of size_t */
+H5FL_SEQ_EXTERN(size_t);
+
+/* Declare extern free list to manage sequences of hsize_t */
+H5FL_SEQ_EXTERN(hsize_t);
+
/*--------------------------------------------------------------------------
@@ -1364,8 +1373,10 @@ herr_t
H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
const H5S_sel_iter_op_t *op, void *op_data)
{
- H5S_sel_iter_t iter; /* Selection iteration info */
+ H5S_sel_iter_t *iter = NULL; /* Selection iteration info */
hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */
+ hsize_t *off = NULL; /* Array to store sequence offsets */
+ size_t *len = NULL; /* Array to store sequence lengths */
hssize_t nelmts; /* Number of elements in selection */
hsize_t space_size[H5O_LAYOUT_NDIMS]; /* Dataspace size */
size_t max_elem; /* Maximum number of elements allowed in sequences */
@@ -1386,8 +1397,12 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
if(0 == (elmt_size = H5T_get_size(type)))
HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid")
+ /* Allocate the selection iterator */
+ if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
+
/* Initialize iterator */
- if(H5S_select_iter_init(&iter, space, elmt_size) < 0)
+ if(H5S_select_iter_init(iter, space, elmt_size) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
iter_init = TRUE; /* Selection iteration info has been initialized */
@@ -1408,16 +1423,20 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
/* Compute the maximum number of bytes required */
H5_CHECKED_ASSIGN(max_elem, size_t, nelmts, hssize_t);
+ /* Allocate the offset & length arrays */
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, H5D_IO_VECTOR_SIZE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, H5D_IO_VECTOR_SIZE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate offset vector array")
+
/* Loop, while elements left in selection */
while(max_elem > 0 && user_ret == 0) {
- hsize_t off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
- size_t len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
size_t nelem; /* Number of elements used in sequences */
size_t nseq; /* Number of sequences generated */
size_t curr_seq; /* Current sequence being worked on */
/* Get the sequences of bytes */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, &iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Loop, while sequences left to process */
@@ -1477,9 +1496,17 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space,
ret_value = user_ret;
done:
+ /* Release resources, if allocated */
+ if(len)
+ len = H5FL_SEQ_FREE(size_t, len);
+ if(off)
+ off = H5FL_SEQ_FREE(hsize_t, off);
+
/* Release selection iterator */
- if(iter_init && H5S_SELECT_ITER_RELEASE(&iter) < 0)
+ if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ if(iter)
+ iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_select_iterate() */
@@ -1583,8 +1610,8 @@ H5S_get_select_type(const H5S_t *space)
htri_t
H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
{
- H5S_sel_iter_t iter_a; /* Selection a iteration info */
- H5S_sel_iter_t iter_b; /* Selection b iteration info */
+ H5S_sel_iter_t *iter_a = NULL; /* Selection a iteration info */
+ H5S_sel_iter_t *iter_b = NULL; /* Selection b iteration info */
hbool_t iter_a_init = 0; /* Selection a iteration info has been initialized */
hbool_t iter_b_init = 0; /* Selection b iteration info has been initialized */
htri_t ret_value = TRUE; /* Return value */
@@ -1729,15 +1756,21 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
hsize_t off_b[H5O_LAYOUT_NDIMS]; /* Offset of selection b blocks */
hbool_t first_block = TRUE; /* Flag to indicate the first block */
+ /* Allocate the selection iterators */
+ if(NULL == (iter_a = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
+ if(NULL == (iter_b = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
+
/* Initialize iterator for each dataspace selection
* Use '0' for element size instead of actual element size to indicate
* that the selection iterator shouldn't be "flattened", since we
* aren't actually going to be doing I/O with the iterators.
*/
- if(H5S_select_iter_init(&iter_a, space_a, (size_t)0) < 0)
+ if(H5S_select_iter_init(iter_a, space_a, (size_t)0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator a")
iter_a_init = 1;
- if(H5S_select_iter_init(&iter_b, space_b, (size_t)0) < 0)
+ if(H5S_select_iter_init(iter_b, space_b, (size_t)0) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator b")
iter_b_init = 1;
@@ -1748,9 +1781,9 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
htri_t status_a, status_b; /* Status from next block checks */
/* Get the current block for each selection iterator */
- if(H5S_SELECT_ITER_BLOCK(&iter_a, start_a, end_a) < 0)
+ if(H5S_SELECT_ITER_BLOCK(iter_a, start_a, end_a) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator block a")
- if(H5S_SELECT_ITER_BLOCK(&iter_b, start_b, end_b) < 0)
+ if(H5S_SELECT_ITER_BLOCK(iter_b, start_b, end_b) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "unable to get iterator block b")
space_a_dim = (int)space_a_rank - 1;
@@ -1821,10 +1854,10 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
} /* end else */
/* Check if we are able to advance to the next selection block */
- if((status_a = H5S_SELECT_ITER_HAS_NEXT_BLOCK(&iter_a)) < 0)
+ if((status_a = H5S_SELECT_ITER_HAS_NEXT_BLOCK(iter_a)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to check iterator block a")
- if((status_b = H5S_SELECT_ITER_HAS_NEXT_BLOCK(&iter_b)) < 0)
+ if((status_b = H5S_SELECT_ITER_HAS_NEXT_BLOCK(iter_b)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to check iterator block b")
/* Did we run out of blocks at the same time? */
@@ -1834,10 +1867,10 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
HGOTO_DONE(FALSE)
else {
/* Advance to next block in selection iterators */
- if(H5S_SELECT_ITER_NEXT_BLOCK(&iter_a) < 0)
+ if(H5S_SELECT_ITER_NEXT_BLOCK(iter_a) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to advance to next iterator block a")
- if(H5S_SELECT_ITER_NEXT_BLOCK(&iter_b) < 0)
+ if(H5S_SELECT_ITER_NEXT_BLOCK(iter_b) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTNEXT, FAIL, "unable to advance to next iterator block b")
} /* end else */
} /* end while */
@@ -1845,12 +1878,14 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2)
} /* end else */
done:
- if(iter_a_init)
- if(H5S_SELECT_ITER_RELEASE(&iter_a) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator a")
- if(iter_b_init)
- if(H5S_SELECT_ITER_RELEASE(&iter_b) < 0)
- HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator b")
+ if(iter_a_init && H5S_SELECT_ITER_RELEASE(iter_a) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator a")
+ if(iter_a)
+ iter_a = H5FL_FREE(H5S_sel_iter_t, iter_a);
+ if(iter_b_init && H5S_SELECT_ITER_RELEASE(iter_b) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator b")
+ if(iter_b)
+ iter_b = H5FL_FREE(H5S_sel_iter_t, iter_b);
FUNC_LEAVE_NOAPI(ret_value)
} /* H5S_select_shape_same() */
@@ -2152,8 +2187,10 @@ done:
herr_t
H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_buf)
{
- H5S_sel_iter_t iter; /* Selection iteration info */
+ H5S_sel_iter_t *iter = NULL; /* Selection iteration info */
hbool_t iter_init = 0; /* Selection iteration info has been initialized */
+ hsize_t *off = NULL; /* Array to store sequence offsets */
+ size_t *len = NULL; /* Array to store sequence lengths */
hssize_t nelmts; /* Number of elements in selection */
size_t max_elem; /* Total number of elements in selection */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2166,8 +2203,12 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b
HDassert(space);
HDassert(_buf);
+ /* Allocate the selection iterator */
+ if(NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate selection iterator")
+
/* Initialize iterator */
- if(H5S_select_iter_init(&iter, space, fill_size) < 0)
+ if(H5S_select_iter_init(iter, space, fill_size) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator")
iter_init = 1; /* Selection iteration info has been initialized */
@@ -2178,16 +2219,20 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b
/* Compute the number of bytes to process */
H5_CHECKED_ASSIGN(max_elem, size_t, nelmts, hssize_t);
+ /* Allocate the offset & length arrays */
+ if(NULL == (len = H5FL_SEQ_MALLOC(size_t, H5D_IO_VECTOR_SIZE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate length vector array")
+ if(NULL == (off = H5FL_SEQ_MALLOC(hsize_t, H5D_IO_VECTOR_SIZE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate offset vector array")
+
/* Loop, while elements left in selection */
while(max_elem > 0) {
- hsize_t off[H5D_IO_VECTOR_SIZE]; /* Array to store sequence offsets */
- size_t len[H5D_IO_VECTOR_SIZE]; /* Array to store sequence lengths */
size_t nseq; /* Number of sequences generated */
size_t curr_seq; /* Current sequnce being worked on */
size_t nelem; /* Number of elements used in sequences */
/* Get the sequences of bytes */
- if(H5S_SELECT_GET_SEQ_LIST(space, 0, &iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
+ if(H5S_SELECT_GET_SEQ_LIST(space, 0, iter, (size_t)H5D_IO_VECTOR_SIZE, max_elem, &nseq, &nelem, off, len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed")
/* Loop over sequences */
@@ -2207,9 +2252,17 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b
} /* end while */
done:
- /* Release resouces */
- if(iter_init && H5S_SELECT_ITER_RELEASE(&iter) < 0)
+ /* Release resources, if allocated */
+ if(len)
+ len = H5FL_SEQ_FREE(size_t, len);
+ if(off)
+ off = H5FL_SEQ_FREE(hsize_t, off);
+
+ /* Release selection iterator */
+ if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
+ if(iter)
+ iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_NOAPI(ret_value)
} /* H5S_select_fill() */
diff --git a/src/H5system.c b/src/H5system.c
index e6ca5d4..e17373c 100644
--- a/src/H5system.c
+++ b/src/H5system.c
@@ -172,7 +172,7 @@ HDfprintf(FILE *stream, const char *fmt, ...)
s = rest;
} /* end if */
else if ('*'==*s) {
- fwidth = va_arg (ap, int);
+ fwidth = va_arg(ap, int);
if(fwidth < 0) {
leftjust = 1;
fwidth = -fwidth;
@@ -269,23 +269,22 @@ HDfprintf(FILE *stream, const char *fmt, ...)
len += HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%s", modifier);
HDsnprintf(format_templ + len, (sizeof(format_templ) - (size_t)(len + 1)), "%c", conv);
-
/* Conversion */
switch (conv) {
case 'd':
case 'i':
if(!HDstrcmp(modifier, "h")) {
- short x = (short)va_arg (ap, int);
- n = fprintf (stream, format_templ, x);
+ short x = (short)va_arg(ap, int);
+ n = fprintf(stream, format_templ, x);
} else if(!*modifier) {
- int x = va_arg (ap, int);
- n = fprintf (stream, format_templ, x);
- } else if(!HDstrcmp (modifier, "l")) {
- long x = va_arg (ap, long);
- n = fprintf (stream, format_templ, x);
+ int x = va_arg(ap, int);
+ n = fprintf(stream, format_templ, x);
+ } else if(!HDstrcmp(modifier, "l")) {
+ long x = va_arg(ap, long);
+ n = fprintf(stream, format_templ, x);
} else {
int64_t x = va_arg(ap, int64_t);
- n = fprintf (stream, format_templ, x);
+ n = fprintf(stream, format_templ, x);
}
break;
@@ -294,13 +293,13 @@ HDfprintf(FILE *stream, const char *fmt, ...)
case 'x':
case 'X':
if(!HDstrcmp(modifier, "h")) {
- unsigned short x = (unsigned short)va_arg (ap, unsigned int);
+ unsigned short x = (unsigned short)va_arg(ap, unsigned int);
n = fprintf(stream, format_templ, x);
} else if(!*modifier) {
- unsigned int x = va_arg (ap, unsigned int); /*lint !e732 Loss of sign not really occuring */
+ unsigned int x = va_arg(ap, unsigned int); /*lint !e732 Loss of sign not really occuring */
n = fprintf(stream, format_templ, x);
} else if(!HDstrcmp(modifier, "l")) {
- unsigned long x = va_arg (ap, unsigned long); /*lint !e732 Loss of sign not really occuring */
+ unsigned long x = va_arg(ap, unsigned long); /*lint !e732 Loss of sign not really occuring */
n = fprintf(stream, format_templ, x);
} else {
uint64_t x = va_arg(ap, uint64_t); /*lint !e732 Loss of sign not really occuring */
@@ -336,7 +335,7 @@ HDfprintf(FILE *stream, const char *fmt, ...)
case 'a':
{
- haddr_t x = va_arg (ap, haddr_t); /*lint !e732 Loss of sign not really occuring */
+ haddr_t x = va_arg(ap, haddr_t); /*lint !e732 Loss of sign not really occuring */
if(H5F_addr_defined(x)) {
len = 0;
@@ -405,7 +404,7 @@ HDfprintf(FILE *stream, const char *fmt, ...)
htri_t tri_var = va_arg(ap, htri_t);
if(tri_var > 0)
- fprintf (stream, "TRUE");
+ fprintf(stream, "TRUE");
else if(!tri_var)
fprintf(stream, "FALSE");
else
diff --git a/src/H5timer.c b/src/H5timer.c
index d9be6bb..f36681e 100644
--- a/src/H5timer.c
+++ b/src/H5timer.c
@@ -127,16 +127,16 @@ H5_timer_begin (H5_timer_t *timer)
#ifdef H5_HAVE_GETRUSAGE
HDgetrusage (RUSAGE_SELF, &rusage);
timer->utime = (double)rusage.ru_utime.tv_sec +
- ((double)rusage.ru_utime.tv_usec / 1e6F);
+ ((double)rusage.ru_utime.tv_usec / (double)1e6F);
timer->stime = (double)rusage.ru_stime.tv_sec +
- ((double)rusage.ru_stime.tv_usec / 1e6F);
+ ((double)rusage.ru_stime.tv_usec / (double)1e6F);
#else
timer->utime = 0.0F;
timer->stime = 0.0F;
#endif
#ifdef H5_HAVE_GETTIMEOFDAY
HDgettimeofday (&etime, NULL);
- timer->etime = (double)etime.tv_sec + ((double)etime.tv_usec / 1e6F);
+ timer->etime = (double)etime.tv_sec + ((double)etime.tv_usec / (double)1e6F);
#else
timer->etime = 0.0F;
#endif
@@ -166,9 +166,9 @@ H5_timer_end (H5_timer_t *sum/*in,out*/, H5_timer_t *timer/*in,out*/)
HDassert(timer);
H5_timer_begin(&now);
- timer->utime = MAX(0.0F, now.utime - timer->utime);
- timer->stime = MAX(0.0F, now.stime - timer->stime);
- timer->etime = MAX(0.0F, now.etime - timer->etime);
+ timer->utime = MAX((double)0.0F, now.utime - timer->utime);
+ timer->stime = MAX((double)0.0F, now.stime - timer->stime);
+ timer->etime = MAX((double)0.0F, now.etime - timer->etime);
if (sum) {
sum->utime += timer->utime;
@@ -208,28 +208,28 @@ H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds)
{
double bw;
- if(nseconds <= 0.0F)
+ if(nseconds <= (double)0.0F)
HDstrcpy(buf, " NaN");
else {
bw = nbytes/nseconds;
- if(H5_DBL_ABS_EQUAL(bw, 0.0F))
- HDstrcpy(buf, "0.000 B/s");
- else if(bw < 1.0F)
+ if(H5_DBL_ABS_EQUAL(bw, (double)0.0F))
+ HDstrcpy(buf, "0.000 B/s");
+ else if(bw < (double)1.0F)
sprintf(buf, "%10.4e", bw);
- else if(bw < H5_KB) {
+ else if(bw < (double)H5_KB) {
sprintf(buf, "%05.4f", bw);
HDstrcpy(buf+5, " B/s");
- } else if(bw < H5_MB) {
- sprintf(buf, "%05.4f", bw / H5_KB);
+ } else if(bw < (double)H5_MB) {
+ sprintf(buf, "%05.4f", bw / (double)H5_KB);
HDstrcpy(buf+5, " kB/s");
- } else if(bw < H5_GB) {
- sprintf(buf, "%05.4f", bw / H5_MB);
+ } else if(bw < (double)H5_GB) {
+ sprintf(buf, "%05.4f", bw / (double)H5_MB);
HDstrcpy(buf+5, " MB/s");
- } else if(bw < H5_TB) {
- sprintf(buf, "%05.4f", bw / H5_GB);
+ } else if(bw < (double)H5_TB) {
+ sprintf(buf, "%05.4f", bw / (double)H5_GB);
HDstrcpy(buf+5, " GB/s");
- } else if(bw < H5_PB) {
- sprintf(buf, "%05.4f", bw / H5_TB);
+ } else if(bw < (double)H5_PB) {
+ sprintf(buf, "%05.4f", bw / (double)H5_TB);
HDstrcpy(buf+5, " TB/s");
} else {
sprintf(buf, "%10.4e", bw);