summaryrefslogtreecommitdiffstats
path: root/src/H5Dscatgath.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dscatgath.c')
-rw-r--r--src/H5Dscatgath.c623
1 files changed, 302 insertions, 321 deletions
diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c
index cdf9da2..1a272d8 100644
--- a/src/H5Dscatgath.c
+++ b/src/H5Dscatgath.c
@@ -15,48 +15,42 @@
/* Module Setup */
/****************/
-#include "H5Dmodule.h" /* This source code file is part of the H5D module */
-
+#include "H5Dmodule.h" /* This source code file is part of the H5D module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5CXprivate.h" /* API Contexts */
-#include "H5Dpkg.h" /* Dataset functions */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Iprivate.h" /* IDs */
-#include "H5MMprivate.h" /* Memory management */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Dpkg.h" /* Dataset functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
-
/********************/
/* Local Prototypes */
/********************/
-static herr_t H5D__scatter_file(const H5D_io_info_t *io_info,
- H5S_sel_iter_t *file_iter, size_t nelmts, const void *buf);
-static size_t H5D__gather_file(const H5D_io_info_t *io_info,
- H5S_sel_iter_t *file_iter, size_t nelmts, void *buf);
-static herr_t H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter,
- const H5D_type_info_t *type_info, void *user_buf/*out*/);
+static herr_t H5D__scatter_file(const H5D_io_info_t *io_info, H5S_sel_iter_t *file_iter, size_t nelmts,
+ const void *buf);
+static size_t H5D__gather_file(const H5D_io_info_t *io_info, H5S_sel_iter_t *file_iter, size_t nelmts,
+ void *buf);
+static herr_t H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, const H5D_type_info_t *type_info,
+ void *user_buf /*out*/);
static herr_t H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info);
-
/*********************/
/* Package Variables */
/*********************/
-
/*******************/
/* Local Variables */
/*******************/
@@ -70,8 +64,6 @@ H5FL_SEQ_EXTERN(size_t);
/* Declare extern free list to manage sequences of hsize_t */
H5FL_SEQ_EXTERN(hsize_t);
-
-
/*-------------------------------------------------------------------------
* Function: H5D__scatter_file
*
@@ -89,21 +81,20 @@ H5FL_SEQ_EXTERN(hsize_t);
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter,
- size_t nelmts, const void *_buf)
+H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, size_t nelmts, const void *_buf)
{
- H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
- 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 = 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 */
- size_t dxpl_vec_size; /* Vector length from API context's DXPL */
- size_t vec_size; /* Vector length */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
+ 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 = 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 */
+ size_t dxpl_vec_size; /* Vector length from API context's DXPL */
+ size_t vec_size; /* Vector length */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -116,36 +107,36 @@ H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter,
/* Set up temporary I/O info object */
H5MM_memcpy(&tmp_io_info, _io_info, sizeof(*_io_info));
tmp_io_info.op_type = H5D_IO_OP_WRITE;
- tmp_io_info.u.wbuf = _buf;
+ tmp_io_info.u.wbuf = _buf;
/* Get info from API context */
- if(H5CX_get_vec_size(&dxpl_vec_size) < 0)
+ if (H5CX_get_vec_size(&dxpl_vec_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size")
/* Allocate the vector I/O arrays */
- if(dxpl_vec_size > H5D_IO_VECTOR_SIZE)
+ if (dxpl_vec_size > H5D_IO_VECTOR_SIZE)
vec_size = dxpl_vec_size;
else
vec_size = H5D_IO_VECTOR_SIZE;
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_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)))
+ 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) {
+ while (nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if (H5S_SELECT_ITER_GET_SEQ_LIST(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 */
mem_curr_seq = dset_curr_seq = 0;
orig_mem_len = mem_len = nelem * iter->elmt_size;
- mem_off = 0;
+ mem_off = 0;
/* Write sequence list out */
- if((*tmp_io_info.layout_ops.writevv)(&tmp_io_info, nseq, &dset_curr_seq,
- len, off, (size_t)1, &mem_curr_seq, &mem_len, &mem_off) < 0)
+ if ((*tmp_io_info.layout_ops.writevv)(&tmp_io_info, nseq, &dset_curr_seq, len, off, (size_t)1,
+ &mem_curr_seq, &mem_len, &mem_off) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error")
/* Update buffer */
@@ -157,15 +148,14 @@ H5D__scatter_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter,
done:
/* Release resources, if allocated */
- if(len)
+ if (len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off)
+ if (off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__scatter_file() */
-
/*-------------------------------------------------------------------------
* Function: H5D__gather_file
*
@@ -188,21 +178,20 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter,
- size_t nelmts, void *_buf/*out*/)
+H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter, size_t nelmts, void *_buf /*out*/)
{
- H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
- 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 = 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 dxpl_vec_size; /* Vector length from API context's DXPL */
- size_t vec_size; /* Vector length */
- size_t ret_value = nelmts; /* Return value */
+ H5D_io_info_t tmp_io_info; /* Temporary I/O info object */
+ 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 = 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 dxpl_vec_size; /* Vector length from API context's DXPL */
+ size_t vec_size; /* Vector length */
+ size_t ret_value = nelmts; /* Return value */
FUNC_ENTER_STATIC
@@ -217,36 +206,36 @@ H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter,
/* Set up temporary I/O info object */
H5MM_memcpy(&tmp_io_info, _io_info, sizeof(*_io_info));
tmp_io_info.op_type = H5D_IO_OP_READ;
- tmp_io_info.u.rbuf = _buf;
+ tmp_io_info.u.rbuf = _buf;
/* Get info from API context */
- if(H5CX_get_vec_size(&dxpl_vec_size) < 0)
+ if (H5CX_get_vec_size(&dxpl_vec_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't retrieve I/O vector size")
/* Allocate the vector I/O arrays */
- if(dxpl_vec_size > H5D_IO_VECTOR_SIZE)
+ if (dxpl_vec_size > H5D_IO_VECTOR_SIZE)
vec_size = dxpl_vec_size;
else
vec_size = H5D_IO_VECTOR_SIZE;
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_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)))
+ 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) {
+ while (nelmts > 0) {
/* Get list of sequences for selection to read */
- if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
+ if (H5S_SELECT_ITER_GET_SEQ_LIST(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 */
mem_curr_seq = dset_curr_seq = 0;
orig_mem_len = mem_len = nelem * iter->elmt_size;
- mem_off = 0;
+ mem_off = 0;
/* Read sequence list in */
- if((*tmp_io_info.layout_ops.readvv)(&tmp_io_info, nseq, &dset_curr_seq,
- len, off, (size_t)1, &mem_curr_seq, &mem_len, &mem_off) < 0)
+ if ((*tmp_io_info.layout_ops.readvv)(&tmp_io_info, nseq, &dset_curr_seq, len, off, (size_t)1,
+ &mem_curr_seq, &mem_len, &mem_off) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error")
/* Update buffer */
@@ -258,15 +247,14 @@ H5D__gather_file(const H5D_io_info_t *_io_info, H5S_sel_iter_t *iter,
done:
/* Release resources, if allocated */
- if(len)
+ if (len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off)
+ if (off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__gather_file() */
-
/*-------------------------------------------------------------------------
* Function: H5D__scatter_mem
*
@@ -283,20 +271,19 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts,
- void *_buf/*out*/)
+H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_buf /*out*/)
{
- uint8_t *buf = (uint8_t *)_buf; /* Get local copies for address arithmetic */
+ 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 = 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 */
- size_t dxpl_vec_size; /* Vector length from API context's DXPL */
- size_t vec_size; /* Vector length */
- herr_t ret_value = SUCCEED; /* Number of elements scattered */
+ 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 */
+ size_t dxpl_vec_size; /* Vector length from API context's DXPL */
+ size_t vec_size; /* Vector length */
+ herr_t ret_value = SUCCEED; /* Number of elements scattered */
FUNC_ENTER_PACKAGE
@@ -307,27 +294,27 @@ H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts,
HDassert(buf);
/* Get info from API context */
- if(H5CX_get_vec_size(&dxpl_vec_size) < 0)
+ if (H5CX_get_vec_size(&dxpl_vec_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size")
/* Allocate the vector I/O arrays */
- if(dxpl_vec_size > H5D_IO_VECTOR_SIZE)
+ if (dxpl_vec_size > H5D_IO_VECTOR_SIZE)
vec_size = dxpl_vec_size;
else
vec_size = H5D_IO_VECTOR_SIZE;
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_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)))
+ 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) {
+ while (nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
- HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
+ if (H5S_SELECT_ITER_GET_SEQ_LIST(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 */
- for(curr_seq = 0; curr_seq < nseq; curr_seq++) {
+ for (curr_seq = 0; curr_seq < nseq; curr_seq++) {
/* Get the number of bytes in sequence */
curr_len = len[curr_seq];
@@ -343,15 +330,14 @@ H5D__scatter_mem(const void *_tscat_buf, H5S_sel_iter_t *iter, size_t nelmts,
done:
/* Release resources, if allocated */
- if(len)
+ if (len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off)
+ if (off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5D__scatter_mem() */
+} /* H5D__scatter_mem() */
-
/*-------------------------------------------------------------------------
* Function: H5D__gather_mem
*
@@ -370,20 +356,19 @@ done:
*-------------------------------------------------------------------------
*/
size_t
-H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts,
- void *_tgath_buf/*out*/)
+H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_tgath_buf /*out*/)
{
- 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 = 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 */
- size_t dxpl_vec_size; /* Vector length from API context's DXPL */
- size_t vec_size; /* Vector length */
- size_t ret_value = nelmts; /* Number of elements gathered */
+ 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 = 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 */
+ size_t dxpl_vec_size; /* Vector length from API context's DXPL */
+ size_t vec_size; /* Vector length */
+ size_t ret_value = nelmts; /* Number of elements gathered */
FUNC_ENTER_STATIC
@@ -394,27 +379,27 @@ H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts,
HDassert(tgath_buf);
/* Get info from API context */
- if(H5CX_get_vec_size(&dxpl_vec_size) < 0)
+ if (H5CX_get_vec_size(&dxpl_vec_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't retrieve I/O vector size")
/* Allocate the vector I/O arrays */
- if(dxpl_vec_size > H5D_IO_VECTOR_SIZE)
+ if (dxpl_vec_size > H5D_IO_VECTOR_SIZE)
vec_size = dxpl_vec_size;
else
vec_size = H5D_IO_VECTOR_SIZE;
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_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)))
+ 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) {
+ while (nelmts > 0) {
/* Get list of sequences for selection to write */
- if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &nelem, off, len) < 0)
- HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed")
+ if (H5S_SELECT_ITER_GET_SEQ_LIST(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 */
- for(curr_seq = 0; curr_seq < nseq; curr_seq++) {
+ for (curr_seq = 0; curr_seq < nseq; curr_seq++) {
/* Get the number of bytes in sequence */
curr_len = len[curr_seq];
@@ -430,15 +415,14 @@ H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts,
done:
/* Release resources, if allocated */
- if(len)
+ if (len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off)
+ if (off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5D__gather_mem() */
+} /* H5D__gather_mem() */
-
/*-------------------------------------------------------------------------
* Function: H5D__scatgath_read
*
@@ -452,19 +436,19 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
- hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space)
+H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts,
+ const H5S_t *file_space, const H5S_t *mem_space)
{
- void *buf = io_info->u.rbuf; /* Local pointer to application buffer */
- 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 */
+ void * buf = io_info->u.rbuf; /* Local pointer to application buffer */
+ 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
@@ -476,31 +460,32 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
HDassert(buf);
/* Check for NOOP read */
- if(nelmts == 0)
+ if (nelmts == 0)
HGOTO_DONE(SUCCEED)
/* Allocate the iterators */
- if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ 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)))
+ 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)))
+ 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, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
+ if (H5S_select_iter_init(file_iter, file_space, type_info->src_type_size,
+ H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 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) < 0)
+ 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) < 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) < 0)
+ 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) < 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 */
+ bkg_iter_init = TRUE; /*file selection iteration info has been initialized */
/* Start strip mining... */
- for(smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) {
- size_t n; /* Elements operated on */
+ for (smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) {
+ 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));
@@ -512,73 +497,72 @@ H5D__scatgath_read(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf
* if necessary.
*/
- /*
+ /*
* Gather data
*/
- n = H5D__gather_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf/*out*/);
- if(n != smine_nelmts)
+ n = H5D__gather_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf /*out*/);
+ if (n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file gather failed")
/* If the source and destination are compound types and subset of each other
* and no conversion is needed, copy the data directly into user's buffer and
* 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_iter, type_info, buf /*out*/) < 0)
+ if (type_info->cmpd_subset && H5T_SUBSET_FALSE != type_info->cmpd_subset->subset) {
+ if (H5D__compound_opt_read(smine_nelmts, mem_iter, 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, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/);
- if(n != smine_nelmts)
+ if (H5T_BKG_YES == type_info->need_bkg) {
+ n = H5D__gather_mem(buf, bkg_iter, smine_nelmts, type_info->bkg_buf /*out*/);
+ if (n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "mem gather failed")
} /* end if */
/*
* Perform datatype conversion.
*/
- if(H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id,
- smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf,
- type_info->bkg_buf) < 0)
+ if (H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id, smine_nelmts,
+ (size_t)0, (size_t)0, type_info->tconv_buf, type_info->bkg_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
/* Do the data transform after the conversion (since we're using type mem_type) */
- if(!type_info->is_xform_noop) {
- H5Z_data_xform_t *data_transform; /* Data transform info */
+ if (!type_info->is_xform_noop) {
+ H5Z_data_xform_t *data_transform; /* Data transform info */
/* Retrieve info from API context */
- if(H5CX_get_data_transform(&data_transform) < 0)
+ if (H5CX_get_data_transform(&data_transform) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info")
- if(H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0)
+ if (H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) <
+ 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Error performing data transform")
}
/* Scatter the data into memory */
- if(H5D__scatter_mem(type_info->tconv_buf, mem_iter, smine_nelmts, buf/*out*/) < 0)
+ if (H5D__scatter_mem(type_info->tconv_buf, mem_iter, smine_nelmts, buf /*out*/) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed")
} /* end else */
- } /* end for */
+ } /* end for */
done:
/* Release selection iterators */
- if(file_iter_init && H5S_SELECT_ITER_RELEASE(file_iter) < 0)
+ 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)
+ if (file_iter)
file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter);
- if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ 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)
+ if (mem_iter)
mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter);
- if(bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0)
+ 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)
+ if (bkg_iter)
bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__scatgath_read() */
-
/*-------------------------------------------------------------------------
* Function: H5D__scatgath_write
*
@@ -592,19 +576,19 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info,
- hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space)
+H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts,
+ const H5S_t *file_space, const H5S_t *mem_space)
{
- const void *buf = io_info->u.wbuf; /* Local pointer to application buffer */
- 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 */
+ const void * buf = io_info->u.wbuf; /* Local pointer to application buffer */
+ 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
@@ -616,31 +600,33 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
HDassert(buf);
/* Check for NOOP write */
- if(nelmts == 0)
+ if (nelmts == 0)
HGOTO_DONE(SUCCEED)
/* Allocate the iterators */
- if(NULL == (mem_iter = H5FL_MALLOC(H5S_sel_iter_t)))
+ 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)))
+ 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)))
+ 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, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
+ if (H5S_select_iter_init(file_iter, file_space, type_info->dst_type_size,
+ H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 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) < 0)
+ 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) < 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, H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 0)
+ 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,
+ H5S_SEL_ITER_GET_SEQ_LIST_SORTED) < 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 */
+ bkg_iter_init = TRUE; /*file selection iteration info has been initialized */
/* Start strip mining... */
- for(smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) {
- size_t n; /* Elements operated on */
+ for (smine_start = 0; smine_start < nelmts; smine_start += smine_nelmts) {
+ 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));
@@ -651,8 +637,8 @@ 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_iter, smine_nelmts, type_info->tconv_buf/*out*/);
- if(n != smine_nelmts)
+ n = H5D__gather_mem(buf, mem_iter, smine_nelmts, type_info->tconv_buf /*out*/);
+ if (n != smine_nelmts)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "mem gather failed")
/* If the source and destination are compound types and the destination is
@@ -661,66 +647,65 @@ H5D__scatgath_write(const H5D_io_info_t *io_info, const H5D_type_info_t *type_in
* is a subset of the destination, the optimization is done in conversion
* function H5T_conv_struct_opt to protect the background data.
*/
- if(type_info->cmpd_subset && H5T_SUBSET_DST == type_info->cmpd_subset->subset
- && type_info->dst_type_size == type_info->cmpd_subset->copy_size) {
- if(H5D__compound_opt_write(smine_nelmts, type_info) < 0)
+ if (type_info->cmpd_subset && H5T_SUBSET_DST == type_info->cmpd_subset->subset &&
+ type_info->dst_type_size == type_info->cmpd_subset->copy_size) {
+ if (H5D__compound_opt_write(smine_nelmts, type_info) < 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_file(io_info, bkg_iter, smine_nelmts, type_info->bkg_buf/*out*/);
- if(n != smine_nelmts)
+ if (H5T_BKG_YES == type_info->need_bkg) {
+ n = H5D__gather_file(io_info, 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 */
/* Do the data transform before the type conversion (since
* transforms must be done in the memory type). */
- if(!type_info->is_xform_noop) {
- H5Z_data_xform_t *data_transform; /* Data transform info */
+ if (!type_info->is_xform_noop) {
+ H5Z_data_xform_t *data_transform; /* Data transform info */
/* Retrieve info from API context */
- if(H5CX_get_data_transform(&data_transform) < 0)
+ if (H5CX_get_data_transform(&data_transform) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get data transform info")
- if(H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) < 0)
+ if (H5Z_xform_eval(data_transform, type_info->tconv_buf, smine_nelmts, type_info->mem_type) <
+ 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "Error performing data transform")
}
/*
* Perform datatype conversion.
*/
- if(H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id,
- smine_nelmts, (size_t)0, (size_t)0, type_info->tconv_buf,
- type_info->bkg_buf) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
+ if (H5T_convert(type_info->tpath, type_info->src_type_id, type_info->dst_type_id, smine_nelmts,
+ (size_t)0, (size_t)0, type_info->tconv_buf, type_info->bkg_buf) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
} /* end else */
/*
* Scatter the data out to the file.
*/
- if(H5D__scatter_file(io_info, file_iter, smine_nelmts, type_info->tconv_buf) < 0)
+ if (H5D__scatter_file(io_info, 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 && H5S_SELECT_ITER_RELEASE(file_iter) < 0)
+ 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)
+ if (file_iter)
file_iter = H5FL_FREE(H5S_sel_iter_t, file_iter);
- if(mem_iter_init && H5S_SELECT_ITER_RELEASE(mem_iter) < 0)
+ 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)
+ if (mem_iter)
mem_iter = H5FL_FREE(H5S_sel_iter_t, mem_iter);
- if(bkg_iter_init && H5S_SELECT_ITER_RELEASE(bkg_iter) < 0)
+ 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)
+ if (bkg_iter)
bkg_iter = H5FL_FREE(H5S_sel_iter_t, bkg_iter);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__scatgath_write() */
-
/*-------------------------------------------------------------------------
* Function: H5D__compound_opt_read
*
@@ -754,17 +739,17 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter,
- const H5D_type_info_t *type_info, void *user_buf/*out*/)
+H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter, const H5D_type_info_t *type_info,
+ void *user_buf /*out*/)
{
- uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */
- uint8_t *xdbuf; /* Pointer into dataset buffer */
- hsize_t *off = NULL; /* Pointer to sequence offsets */
- size_t *len = NULL; /* Pointer to sequence lengths */
- size_t src_stride, dst_stride, copy_size;
- size_t dxpl_vec_size; /* Vector length from API context's DXPL */
- size_t vec_size; /* Vector length */
- herr_t ret_value = SUCCEED; /* Return value */
+ uint8_t *ubuf = (uint8_t *)user_buf; /* Cast for pointer arithmetic */
+ uint8_t *xdbuf; /* Pointer into dataset buffer */
+ hsize_t *off = NULL; /* Pointer to sequence offsets */
+ size_t * len = NULL; /* Pointer to sequence lengths */
+ size_t src_stride, dst_stride, copy_size;
+ size_t dxpl_vec_size; /* Vector length from API context's DXPL */
+ size_t vec_size; /* Vector length */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -774,21 +759,21 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter,
HDassert(type_info);
HDassert(type_info->cmpd_subset);
HDassert(H5T_SUBSET_SRC == type_info->cmpd_subset->subset ||
- H5T_SUBSET_DST == type_info->cmpd_subset->subset);
+ H5T_SUBSET_DST == type_info->cmpd_subset->subset);
HDassert(user_buf);
/* Get info from API context */
- if(H5CX_get_vec_size(&dxpl_vec_size) < 0)
+ if (H5CX_get_vec_size(&dxpl_vec_size) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve I/O vector size")
/* Allocate the vector I/O arrays */
- if(dxpl_vec_size > H5D_IO_VECTOR_SIZE)
+ if (dxpl_vec_size > H5D_IO_VECTOR_SIZE)
vec_size = dxpl_vec_size;
else
vec_size = H5D_IO_VECTOR_SIZE;
- if(NULL == (len = H5FL_SEQ_MALLOC(size_t, vec_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)))
+ 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 */
@@ -800,22 +785,22 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter,
/* Loop until all elements are written */
xdbuf = type_info->tconv_buf;
- while(nelmts > 0) {
- size_t nseq; /* Number of sequences generated */
- size_t curr_seq; /* Current sequence being processed */
- size_t elmtno; /* Element counter */
+ while (nelmts > 0) {
+ size_t nseq; /* Number of sequences generated */
+ size_t curr_seq; /* Current sequence being processed */
+ size_t elmtno; /* Element counter */
/* Get list of sequences for selection to write */
- if(H5S_SELECT_ITER_GET_SEQ_LIST(iter, vec_size, nelmts, &nseq, &elmtno, off, len) < 0)
+ if (H5S_SELECT_ITER_GET_SEQ_LIST(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 */
- for(curr_seq = 0; curr_seq < nseq; curr_seq++) {
- size_t curr_off; /* Offset of bytes left to process in sequence */
- size_t curr_len; /* Length of bytes left to process in sequence */
- size_t curr_nelmts; /* Number of elements to process in sequence */
- uint8_t *xubuf;
- size_t i; /* Local index variable */
+ for (curr_seq = 0; curr_seq < nseq; curr_seq++) {
+ size_t curr_off; /* Offset of bytes left to process in sequence */
+ size_t curr_len; /* Length of bytes left to process in sequence */
+ size_t curr_nelmts; /* Number of elements to process in sequence */
+ uint8_t *xubuf;
+ size_t i; /* Local index variable */
/* Get the number of bytes and offset in sequence */
curr_len = len[curr_seq];
@@ -824,17 +809,17 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter,
/* Decide the number of elements and position in the buffer. */
curr_nelmts = curr_len / dst_stride;
- xubuf = ubuf + curr_off;
+ xubuf = ubuf + curr_off;
/* Copy the data into the right place. */
- for(i = 0; i < curr_nelmts; i++) {
+ for (i = 0; i < curr_nelmts; i++) {
HDmemmove(xubuf, xdbuf, copy_size);
/* Update pointers */
xdbuf += src_stride;
xubuf += dst_stride;
} /* end for */
- } /* end for */
+ } /* end for */
/* Decrement number of elements left to process */
nelmts -= elmtno;
@@ -842,15 +827,14 @@ H5D__compound_opt_read(size_t nelmts, H5S_sel_iter_t *iter,
done:
/* Release resources, if allocated */
- if(len)
+ if (len)
len = H5FL_SEQ_FREE(size_t, len);
- if(off)
+ if (off)
off = H5FL_SEQ_FREE(hsize_t, off);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__compound_opt_read() */
-
/*-------------------------------------------------------------------------
* Function: H5D__compound_opt_write
*
@@ -887,9 +871,9 @@ done:
static herr_t
H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info)
{
- uint8_t *xsbuf, *xdbuf; /* Source & destination pointers into dataset buffer */
- size_t src_stride, dst_stride; /* Strides through source & destination datatypes */
- size_t i; /* Local index variable */
+ uint8_t *xsbuf, *xdbuf; /* Source & destination pointers into dataset buffer */
+ size_t src_stride, dst_stride; /* Strides through source & destination datatypes */
+ size_t i; /* Local index variable */
FUNC_ENTER_STATIC_NOERR
@@ -904,7 +888,7 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info)
/* Loop until all elements are written */
xsbuf = (uint8_t *)type_info->tconv_buf;
xdbuf = (uint8_t *)type_info->tconv_buf;
- for(i = 0; i < nelmts; i++) {
+ for (i = 0; i < nelmts; i++) {
HDmemmove(xdbuf, xsbuf, dst_stride);
/* Update pointers */
@@ -915,7 +899,6 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5D__compound_opt_write() */
-
/*-------------------------------------------------------------------------
* Function: H5Dscatter
*
@@ -933,71 +916,70 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info)
*-------------------------------------------------------------------------
*/
herr_t
-H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
- hid_t dst_space_id, void *dst_buf)
+H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_id, void *dst_buf)
{
- H5T_t *type; /* Datatype */
- H5S_t *dst_space; /* Dataspace */
- 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 */
- size_t type_size; /* Datatype element size */
- hssize_t nelmts; /* Number of remaining elements in selection */
- size_t nelmts_scatter = 0; /* Number of elements to scatter to dst_buf */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5T_t * type; /* Datatype */
+ H5S_t * dst_space; /* Dataspace */
+ 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 */
+ size_t type_size; /* Datatype element size */
+ hssize_t nelmts; /* Number of remaining elements in selection */
+ size_t nelmts_scatter = 0; /* Number of elements to scatter to dst_buf */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "x*xii*x", op, op_data, type_id, dst_space_id, dst_buf);
/* Check args */
- if(op == NULL)
+ if (op == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback function pointer")
- if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if(NULL == (dst_space= (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE)))
+ if (NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
- if(dst_buf == NULL)
+ if (dst_buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided")
/* Get datatype element size */
- if(0 == (type_size = H5T_GET_SIZE(type)))
+ if (0 == (type_size = H5T_GET_SIZE(type)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size")
/* Get number of elements in dataspace */
- if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(dst_space)) < 0)
+ 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)))
+ 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) < 0)
+ if (H5S_select_iter_init(iter, dst_space, type_size, 0) < 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) {
+ while (nelmts > 0) {
/* Make callback to retrieve data */
- if(op(&src_buf, &src_buf_nbytes, op_data) < 0)
+ if (op(&src_buf, &src_buf_nbytes, op_data) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure")
/* Calculate number of elements */
nelmts_scatter = src_buf_nbytes / type_size;
/* Check callback results */
- if(!src_buf)
+ if (!src_buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback did not return a buffer")
- if(src_buf_nbytes == 0)
+ if (src_buf_nbytes == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned a buffer size of 0")
- if(src_buf_nbytes % type_size)
+ if (src_buf_nbytes % type_size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size is not a multiple of datatype size")
- if(nelmts_scatter > (size_t)nelmts)
+ if (nelmts_scatter > (size_t)nelmts)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection")
/* Scatter data */
- if(H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0)
+ if (H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed")
nelmts -= (hssize_t)nelmts_scatter;
@@ -1005,15 +987,14 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id,
done:
/* Release selection iterator */
- if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0)
+ if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- if(iter)
+ if (iter)
iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_API(ret_value)
-} /* H5Dscatter() */
+} /* H5Dscatter() */
-
/*-------------------------------------------------------------------------
* Function: H5Dgather
*
@@ -1031,71 +1012,72 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
- size_t dst_buf_size, void *dst_buf, H5D_gather_func_t op, void *op_data)
+H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, size_t dst_buf_size, void *dst_buf,
+ H5D_gather_func_t op, void *op_data)
{
- H5T_t *type; /* Datatype */
- H5S_t *src_space; /* Dataspace */
- 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 */
- size_t dst_buf_nelmts; /* Number of elements that can fit in dst_buf */
- size_t nelmts_gathered; /* Number of elements gathered from src_buf */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5T_t * type; /* Datatype */
+ H5S_t * src_space; /* Dataspace */
+ 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 */
+ size_t dst_buf_nelmts; /* Number of elements that can fit in dst_buf */
+ size_t nelmts_gathered; /* Number of elements gathered from src_buf */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE7("e", "i*xiz*xx*x", src_space_id, src_buf, type_id, dst_buf_size,
- dst_buf, op, op_data);
+ H5TRACE7("e", "i*xiz*xx*x", src_space_id, src_buf, type_id, dst_buf_size, dst_buf, op, op_data);
/* Check args */
- if(NULL == (src_space= (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE)))
+ if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
- if(src_buf == NULL)
+ if (src_buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source buffer provided")
- if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if(dst_buf_size == 0)
+ if (dst_buf_size == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer size is 0")
- if(dst_buf == NULL)
+ if (dst_buf == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided")
/* Get datatype element size */
- if(0 == (type_size = H5T_GET_SIZE(type)))
+ if (0 == (type_size = H5T_GET_SIZE(type)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size")
/* Get number of elements in dst_buf_size */
dst_buf_nelmts = dst_buf_size / type_size;
- if(dst_buf_nelmts == 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer is not large enough to hold one element")
+ if (dst_buf_nelmts == 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "destination buffer is not large enough to hold one element")
/* Get number of elements in dataspace */
- if((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(src_space)) < 0)
+ if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(src_space)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection")
/* If dst_buf is not large enough to hold all the elements, make sure there
* is a callback */
- if(((size_t)nelmts > dst_buf_nelmts) && (op == NULL))
+ 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)))
+ 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) < 0)
+ if (H5S_select_iter_init(iter, src_space, type_size, 0) < 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) {
+ while (nelmts > 0) {
/* Gather data */
- if(0 == (nelmts_gathered = H5D__gather_mem(src_buf, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf)))
+ if (0 ==
+ (nelmts_gathered = H5D__gather_mem(src_buf, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf)))
HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed")
HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts));
/* Make callback to process dst_buf */
- if(op && op(dst_buf, nelmts_gathered * type_size, op_data) < 0)
+ if (op && op(dst_buf, nelmts_gathered * type_size, op_data) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure")
nelmts -= (hssize_t)nelmts_gathered;
@@ -1104,11 +1086,10 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id,
done:
/* Release selection iterator */
- if(iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0)
+ if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator")
- if(iter)
+ if (iter)
iter = H5FL_FREE(H5S_sel_iter_t, iter);
FUNC_LEAVE_API(ret_value)
-} /* H5Dgather() */
-
+} /* H5Dgather() */