diff options
Diffstat (limited to 'src/H5Dfill.c')
-rw-r--r-- | src/H5Dfill.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/src/H5Dfill.c b/src/H5Dfill.c index db0989c..ed1ac3e 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -132,7 +132,7 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_ /* Make sure the dataspace has an extent set (or is NULL) */ if (!(H5S_has_extent(space))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace extent has not been set") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace extent has not been set"); /* Get the memory datatype size */ dst_type_size = H5T_get_size(buf_type); @@ -143,15 +143,15 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_ /* Wrap the local buffer for elements */ if (NULL == (elem_wb = H5WB_wrap(elem_buf, sizeof(elem_buf)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer"); /* Get a pointer to a buffer that's large enough for element */ if (NULL == (elem_ptr = H5WB_actual_clear(elem_wb, dst_type_size))) - HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer") + HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer"); /* Fill the selection in the memory buffer */ if (H5S_select_fill(elem_ptr, dst_type_size, space, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") + HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed"); } /* end if */ else { H5T_path_t *tpath; /* Conversion path information */ @@ -166,15 +166,16 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_ /* Set up type conversion function */ if (NULL == (tpath = H5T_path_find(fill_type, buf_type))) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatype") + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, + "unable to convert between src and dest datatype"); /* Construct source & destination datatype IDs, if we will need them */ if (!H5T_path_noop(tpath)) { if ((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill_type, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); if ((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(buf_type, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion") + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion"); } /* end if */ /* If there's VL type of data, make multiple copies of fill value first, @@ -190,12 +191,12 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_ /* Allocate a temporary buffer */ if (NULL == (tmp_buf = H5FL_BLK_MALLOC(type_conv, (size_t)nelmts * buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Allocate a background buffer, if necessary */ if (H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, (size_t)nelmts * buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Replicate the file's fill value into the temporary buffer */ H5VM_array_fill(tmp_buf, fill, src_type_size, (size_t)nelmts); @@ -203,21 +204,21 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_ /* Convert from file's fill value into memory form */ if (H5T_convert(tpath, src_id, dst_id, (size_t)nelmts, (size_t)0, (size_t)0, tmp_buf, bkg_buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") + HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed"); /* 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") + 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) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to initialize memory selection information") + "unable to initialize memory selection information"); mem_iter_init = TRUE; /* Scatter the data into memory */ if (H5D__scatter_mem(tmp_buf, mem_iter, (size_t)nelmts, buf /*out*/) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed") + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "scatter failed"); } /* end if */ else { const uint8_t *fill_buf; /* Buffer to use for writing fill values */ @@ -229,11 +230,11 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_ /* Wrap the local buffer for elements */ if (NULL == (elem_wb = H5WB_wrap(elem_buf, sizeof(elem_buf)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer"); /* Get a pointer to a buffer that's large enough for element */ if (NULL == (elem_ptr = H5WB_actual(elem_wb, buf_size))) - HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer") + HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer"); /* Copy the user's data into the buffer for conversion */ H5MM_memcpy(elem_ptr, fill, src_type_size); @@ -243,17 +244,17 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_ if (H5T_path_bkg(tpath)) { /* Wrap the local buffer for background elements */ if (NULL == (bkg_elem_wb = H5WB_wrap(bkg_elem_buf, sizeof(bkg_elem_buf)))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't wrap buffer"); /* Get a pointer to a buffer that's large enough for element */ if (NULL == (bkg_ptr = H5WB_actual_clear(bkg_elem_wb, buf_size))) - HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer") + HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't get actual buffer"); } /* end if */ /* Perform datatype conversion */ if (H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, elem_ptr, bkg_ptr) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") + HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed"); /* Point at element buffer */ fill_buf = (const uint8_t *)elem_ptr; @@ -263,7 +264,7 @@ H5D__fill(const void *fill, const H5T_t *fill_type, void *buf, const H5T_t *buf_ /* Fill the selection in the memory buffer */ if (H5S_select_fill(fill_buf, dst_type_size, space, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") + HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed"); } /* end else */ } /* end else */ @@ -330,16 +331,16 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, H5MM_allocat /* Detect whether the datatype has a VL component */ if ((has_vlen_type = H5T_detect_class(dset_type, H5T_VLEN, FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to detect vlen datatypes?") + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "unable to detect vlen datatypes?"); fb_info->has_vlen_fill_type = (hbool_t)has_vlen_type; /* If necessary, convert fill value datatypes (which copies VL components, etc.) */ if (fb_info->has_vlen_fill_type) { /* Create temporary datatype for conversion operation */ if (NULL == (fb_info->mem_type = H5T_copy(dset_type, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy file datatype") + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy file datatype"); if ((fb_info->mem_tid = H5I_register(H5I_DATATYPE, fb_info->mem_type, FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype"); /* Retrieve sizes of memory & file datatypes */ fb_info->mem_elmt_size = H5T_get_size(fb_info->mem_type); @@ -371,18 +372,18 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, H5MM_allocat else fb_info->fill_buf = H5FL_BLK_MALLOC(non_zero_fill, fb_info->fill_buf_size); if (NULL == fb_info->fill_buf) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer"); } /* end else */ /* Get the datatype conversion path for this operation */ if (NULL == (fb_info->fill_to_mem_tpath = H5T_path_find(dset_type, fb_info->mem_type))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to convert between src and dst datatypes") + "unable to convert between src and dst datatypes"); /* Get the inverse datatype conversion path for this operation */ if (NULL == (fb_info->mem_to_dset_tpath = H5T_path_find(fb_info->mem_type, dset_type))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to convert between src and dst datatypes") + "unable to convert between src and dst datatypes"); /* Check if we need to allocate a background buffer */ if (H5T_path_bkg(fb_info->fill_to_mem_tpath) || H5T_path_bkg(fb_info->mem_to_dset_tpath)) { @@ -395,7 +396,7 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, H5MM_allocat /* Allocate the background buffer */ if (NULL == (fb_info->bkg_buf = H5FL_BLK_MALLOC(type_conv, fb_info->bkg_buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } /* end if */ } /* end if */ else { @@ -424,7 +425,7 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, H5MM_allocat else fb_info->fill_buf = H5FL_BLK_MALLOC(non_zero_fill, fb_info->fill_buf_size); if (NULL == fb_info->fill_buf) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer"); } /* end else */ /* Replicate the fill value into the cached buffer */ @@ -472,7 +473,7 @@ H5D__fill_init(H5D_fill_buf_info_t *fb_info, void *caller_fill_buf, H5MM_allocat fb_info->fill_buf = H5FL_BLK_MALLOC(zero_fill, fb_info->fill_buf_size); } /* end else */ if (fb_info->fill_buf == NULL) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for fill buffer"); } /* end else */ } /* end else */ @@ -517,7 +518,7 @@ H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts) /* Type convert the dataset buffer, to copy any VL components */ if (H5T_convert(fb_info->fill_to_mem_tpath, fb_info->file_tid, fb_info->mem_tid, (size_t)1, (size_t)0, (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") + HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed"); /* Replicate the fill value into the cached buffer */ if (nelmts > 1) @@ -534,14 +535,14 @@ H5D__fill_refill_vl(H5D_fill_buf_info_t *fb_info, size_t nelmts) else buf = H5FL_BLK_MALLOC(non_zero_fill, fb_info->fill_buf_size); if (!buf) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary fill buffer") + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed for temporary fill buffer"); H5MM_memcpy(buf, fb_info->fill_buf, fb_info->fill_buf_size); /* Type convert the dataset buffer, to copy any VL components */ if (H5T_convert(fb_info->mem_to_dset_tpath, fb_info->mem_tid, fb_info->file_tid, nelmts, (size_t)0, (size_t)0, fb_info->fill_buf, fb_info->bkg_buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed") + HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "data type conversion failed"); done: if (buf) { |