diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2009-10-02 20:40:01 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2009-10-02 20:40:01 (GMT) |
commit | eed2ea424b233c451c81569aa2df48c99bc8c79e (patch) | |
tree | a555761e54042fe829b05539874d081fc4fa76d8 /src | |
parent | c53e577d1485c4d3e1985c3b7fb38a67fa42ec3f (diff) | |
download | hdf5-eed2ea424b233c451c81569aa2df48c99bc8c79e.zip hdf5-eed2ea424b233c451c81569aa2df48c99bc8c79e.tar.gz hdf5-eed2ea424b233c451c81569aa2df48c99bc8c79e.tar.bz2 |
[svn-r17585] Purpose: Fix bug 1597
Description:
When copying a dataset using a vlen inside a compound, the various dataset
copying callbacks would allocate a background buffer but would not use it when
converting from disk to memory, only memory to disk. This caused an assertion
failure as compounds always need a background buffer. These callbacks have
been modified to use the background buffer for both conversions.
Tested: jam, linew, smirom (h5committest)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Dchunk.c | 2 | ||||
-rw-r--r-- | src/H5Dcompact.c | 12 | ||||
-rw-r--r-- | src/H5Dcontig.c | 2 | ||||
-rw-r--r-- | src/H5Tconv.c | 85 |
4 files changed, 51 insertions, 50 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 62a3941..8788d86 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -4210,7 +4210,7 @@ H5D_chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) /* Convert from source file to memory */ H5_CHECK_OVERFLOW(udata->nelmts, uint32_t, size_t); - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, (size_t)udata->nelmts, (size_t)0, (size_t)0, buf, NULL, udata->idx_info_dst->dxpl_id) < 0) + if(H5T_convert(tpath_src_mem, tid_src, tid_mem, (size_t)udata->nelmts, (size_t)0, (size_t)0, buf, bkg, udata->idx_info_dst->dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5_ITER_ERROR, "datatype conversion failed") /* Copy into another buffer, to reclaim memory later */ diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index b52bd2c..33b92de 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -484,15 +484,19 @@ H5D_compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst, HDmemcpy(buf, storage_src->buf, storage_src->size); + /* allocate temporary bkg buff for data conversion */ + if(NULL == (bkg = H5FL_BLK_MALLOC(type_conv, buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + /* Convert from source file to memory */ - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, NULL, dxpl_id) < 0) + if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") + /* Copy into another buffer, to reclaim memory later */ HDmemcpy(reclaim_buf, buf, buf_size); - /* allocate temporary bkg buff for data conversion */ - if(NULL == (bkg = H5FL_BLK_CALLOC(type_conv, buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + /* Set background buffer to all zeros */ + HDmemset(bkg, 0, buf_size); /* Convert from memory to destination file */ if(H5T_convert(tpath_mem_dst, tid_mem, tid_dst, nelmts, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0) diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 0ff3964..3e88be6 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -1396,7 +1396,7 @@ H5D_contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, /* Perform datatype conversion, if necessary */ if(is_vlen) { /* Convert from source file to memory */ - if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, NULL, dxpl_id) < 0) + if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Copy into another buffer, to reclaim memory later */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 08e7fa1..ab9e703 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -1935,51 +1935,48 @@ H5T_conv_struct_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata, hid_t dxpl_id) } /* end if */ } /* end for */ - /* Check if we need a background buffer */ - if(H5T_detect_class(src, H5T_COMPOUND) == TRUE || H5T_detect_class(dst, H5T_COMPOUND) == TRUE) { - cdata->need_bkg = H5T_BKG_YES; - - if(src_nmembs < dst_nmembs) { - priv->subset_info.subset = H5T_SUBSET_SRC; - for(i = 0; i < src_nmembs; i++) { - /* If any of source members doesn't have counterpart in the same - * order or there's conversion between members, don't do the - * optimization. - */ - if(src2dst[i] != i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { - priv->subset_info.subset = H5T_SUBSET_FALSE; - break; - } /* end if */ - } /* end for */ - /* Compute the size of the data to be copied for each element. It - * may be smaller than either src or dst if there is extra space at - * the end of src. - */ - if(priv->subset_info.subset == H5T_SUBSET_SRC) - priv->subset_info.copy_size = src->shared->u.compnd.memb[src_nmembs-1].offset - + src->shared->u.compnd.memb[src_nmembs-1].size; - } else if(dst_nmembs < src_nmembs) { - priv->subset_info.subset = H5T_SUBSET_DST; - for(i = 0; i < dst_nmembs; i++) { - /* If any of source members doesn't have counterpart in the same order or - * there's conversion between members, don't do the optimization. */ - if(src2dst[i] != i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { - priv->subset_info.subset = H5T_SUBSET_FALSE; - break; - } - } /* end for */ - /* Compute the size of the data to be copied for each element. It - * may be smaller than either src or dst if there is extra space at - * the end of dst. - */ - if(priv->subset_info.subset == H5T_SUBSET_DST) - priv->subset_info.copy_size = dst->shared->u.compnd.memb[dst_nmembs-1].offset - + dst->shared->u.compnd.memb[dst_nmembs-1].size; - } else /* If the numbers of source and dest members are equal and no conversion is needed, - * the case should have been handled as noop earlier in H5Dio.c. */ - ; + /* The compound conversion functions need a background buffer */ + cdata->need_bkg = H5T_BKG_YES; - } /* end if */ + if(src_nmembs < dst_nmembs) { + priv->subset_info.subset = H5T_SUBSET_SRC; + for(i = 0; i < src_nmembs; i++) { + /* If any of source members doesn't have counterpart in the same + * order or there's conversion between members, don't do the + * optimization. + */ + if(src2dst[i] != i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { + priv->subset_info.subset = H5T_SUBSET_FALSE; + break; + } /* end if */ + } /* end for */ + /* Compute the size of the data to be copied for each element. It + * may be smaller than either src or dst if there is extra space at + * the end of src. + */ + if(priv->subset_info.subset == H5T_SUBSET_SRC) + priv->subset_info.copy_size = src->shared->u.compnd.memb[src_nmembs-1].offset + + src->shared->u.compnd.memb[src_nmembs-1].size; + } else if(dst_nmembs < src_nmembs) { + priv->subset_info.subset = H5T_SUBSET_DST; + for(i = 0; i < dst_nmembs; i++) { + /* If any of source members doesn't have counterpart in the same order or + * there's conversion between members, don't do the optimization. */ + if(src2dst[i] != i || (src->shared->u.compnd.memb[i].offset != dst->shared->u.compnd.memb[i].offset) || (priv->memb_path[i])->is_noop == FALSE) { + priv->subset_info.subset = H5T_SUBSET_FALSE; + break; + } + } /* end for */ + /* Compute the size of the data to be copied for each element. It + * may be smaller than either src or dst if there is extra space at + * the end of dst. + */ + if(priv->subset_info.subset == H5T_SUBSET_DST) + priv->subset_info.copy_size = dst->shared->u.compnd.memb[dst_nmembs-1].offset + + dst->shared->u.compnd.memb[dst_nmembs-1].size; + } else /* If the numbers of source and dest members are equal and no conversion is needed, + * the case should have been handled as noop earlier in H5Dio.c. */ + ; cdata->recalc = FALSE; |