summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-30 21:38:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-30 21:38:30 (GMT)
commit27c0fb2220c241337bd82426ca2c178bff2e3870 (patch)
tree95ab5672227cef811d96033f16dc2b265f0a8501
parentce7f9328b67687756afa530885659bc2ced77539 (diff)
downloadhdf5-27c0fb2220c241337bd82426ca2c178bff2e3870.zip
hdf5-27c0fb2220c241337bd82426ca2c178bff2e3870.tar.gz
hdf5-27c0fb2220c241337bd82426ca2c178bff2e3870.tar.bz2
[svn-r13002] Description:
Fix problem with copying objects when the dataset to copy has an "older" version of the layout message and needs to compute the size of the dataset's storage after the dataspace information is available. Minor random cleanups also... Tested on: FreeBSD/32 4.11 (sleipnir) Too minor/weird to test w/h5committest...
-rw-r--r--src/H5Dcompact.c65
-rw-r--r--src/H5Dcontig.c157
-rw-r--r--src/H5Distore.c163
-rw-r--r--src/H5Doh.c4
-rw-r--r--src/H5Dpkg.h2
-rw-r--r--src/H5Oattr.c22
-rw-r--r--src/H5Ocopy.c3
-rw-r--r--src/H5Odtype.c33
-rw-r--r--src/H5Ofill.c24
-rw-r--r--src/H5Olayout.c26
-rw-r--r--src/H5Olink.c4
-rw-r--r--src/H5Opkg.h5
-rw-r--r--src/H5Opline.c33
-rw-r--r--src/H5Osdspace.c111
-rw-r--r--src/H5Oshared.c8
-rw-r--r--src/H5S.c26
-rw-r--r--src/H5Spkg.h4
-rw-r--r--src/H5Sprivate.h3
-rwxr-xr-xtest/objcopy.c95
19 files changed, 500 insertions, 288 deletions
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index adc91eb..66d4bfc 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -180,38 +180,10 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
HDassert(f_src);
HDassert(f_dst);
HDassert(layout_dst && H5D_COMPACT == layout_dst->type);
+ HDassert(dt_src);
- /* If there's a source datatype, set up type conversion information */
- if(!dt_src)
- /* Type conversion not necessary */
- HDmemcpy(layout_dst->u.compact.buf, layout_src->u.compact.buf, layout_src->u.compact.size);
- else if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) {
- /* Create datatype ID for src datatype, so it gets freed */
- if((tid_src = H5I_register(H5I_DATATYPE, dt_src)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
-
- if(f_src != f_dst) {
- /* Check for expanding references */
- if(cpy_info->expand_ref) {
- size_t ref_count;
-
- /* Determine # of reference elements to copy */
- ref_count = layout_src->u.compact.size / H5T_get_size(dt_src);
-
- /* Copy objects referenced in source buffer to destination file and set destination elements */
- if(H5O_copy_expand_ref(f_src, layout_src->u.compact.buf, dxpl_id, f_dst,
- layout_dst->u.compact.buf, ref_count, H5T_get_ref_type(dt_src), cpy_info) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute")
- } /* end if */
- else
- /* Reset value to zero */
- HDmemset(layout_dst->u.compact.buf, 0, layout_src->u.compact.size);
- } /* end if */
- else
- /* Type conversion not necessary */
- HDmemcpy(layout_dst->u.compact.buf, layout_src->u.compact.buf, layout_src->u.compact.size);
- } /* end if */
- else if(H5T_detect_class(dt_src, H5T_VLEN) > 0) {
+ /* If there's a VLEN source datatype, do type conversion information */
+ if(H5T_detect_class(dt_src, H5T_VLEN) > 0) {
H5T_path_t *tpath_src_mem, *tpath_mem_dst; /* Datatype conversion paths */
H5T_t *dt_dst; /* Destination datatype */
H5T_t *dt_mem; /* Memory datatype */
@@ -306,8 +278,35 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
if(H5D_vlen_reclaim(tid_mem, buf_space, H5P_DATASET_XFER_DEFAULT, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data")
} /* end if */
- else
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy dataset elements")
+ else if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) {
+ /* Create datatype ID for src datatype, so it gets freed */
+ if((tid_src = H5I_register(H5I_DATATYPE, dt_src)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
+
+ if(f_src != f_dst) {
+ /* Check for expanding references */
+ if(cpy_info->expand_ref) {
+ size_t ref_count;
+
+ /* Determine # of reference elements to copy */
+ ref_count = layout_src->u.compact.size / H5T_get_size(dt_src);
+
+ /* Copy objects referenced in source buffer to destination file and set destination elements */
+ if(H5O_copy_expand_ref(f_src, layout_src->u.compact.buf, dxpl_id, f_dst,
+ layout_dst->u.compact.buf, ref_count, H5T_get_ref_type(dt_src), cpy_info) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy reference attribute")
+ } /* end if */
+ else
+ /* Reset value to zero */
+ HDmemset(layout_dst->u.compact.buf, 0, layout_src->u.compact.size);
+ } /* end if */
+ else
+ /* Type conversion not necessary */
+ HDmemcpy(layout_dst->u.compact.buf, layout_src->u.compact.buf, layout_src->u.compact.size);
+ } /* end if */
+ else
+ /* Type conversion not necessary */
+ HDmemcpy(layout_dst->u.compact.buf, layout_src->u.compact.buf, layout_src->u.compact.size);
done:
if(buf_sid > 0)
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index ec8508c..f664715 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -94,16 +94,16 @@ H5FL_BLK_EXTERN(type_conv);
herr_t
H5D_contig_create(H5F_t *f, hid_t dxpl_id, H5O_layout_t *layout /*out */ )
{
- herr_t ret_value=SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5D_contig_create, FAIL)
/* check args */
- assert(f);
- assert(layout);
+ HDassert(f);
+ HDassert(layout);
/* Allocate space for the contiguous data */
- if (HADDR_UNDEF==(layout->u.contig.addr=H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, layout->u.contig.size)))
+ if(HADDR_UNDEF == (layout->u.contig.addr = H5MF_alloc(f, H5FD_MEM_DRAW, dxpl_id, layout->u.contig.size)))
HGOTO_ERROR(H5E_IO, H5E_NOSPACE, FAIL, "unable to reserve file space")
done:
@@ -996,7 +996,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5D_contig_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
+H5D_contig_copy(H5F_t *f_src, const H5O_layout_t *layout_src, H5F_t *f_dst,
H5O_layout_t *layout_dst, H5T_t *dt_src, H5O_copy_t *cpy_info, hid_t dxpl_id)
{
haddr_t addr_src; /* File offset in source dataset */
@@ -1034,83 +1034,85 @@ H5D_contig_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
HDassert(layout_src && H5D_CONTIGUOUS == layout_src->type);
HDassert(f_dst);
HDassert(layout_dst && H5D_CONTIGUOUS == layout_dst->type);
+ HDassert(dt_src);
/* Allocate space for destination raw data */
if(H5D_contig_create(f_dst, dxpl_id, layout_dst) < 0)
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to allocate contiguous storage")
/* Set up number of bytes to copy, and initial buffer size */
- total_src_nbytes = layout_src->u.contig.size;
- H5_CHECK_OVERFLOW(total_src_nbytes,hsize_t,size_t);
+ /* (actually use the destination size, which has been fixed up, if necessary) */
+ total_src_nbytes = layout_dst->u.contig.size;
+ H5_CHECK_OVERFLOW(total_src_nbytes, hsize_t, size_t);
buf_size = MIN(H5D_TEMP_BUF_SIZE, (size_t)total_src_nbytes);
- /* If there's a source datatype, set up type conversion information */
- if(dt_src) {
- if(H5T_detect_class(dt_src, H5T_VLEN) > 0) {
- /* Create datatype ID for src datatype */
- if((tid_src = H5I_register(H5I_DATATYPE, dt_src)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
-
- /* create a memory copy of the variable-length datatype */
- if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
- if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype")
-
- /* create variable-length datatype at the destinaton file */
- if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
- if(H5T_set_loc(dt_dst, f_dst, H5T_LOC_DISK) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
- if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype")
-
- /* Set up the conversion functions */
- if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem, NULL, NULL, dxpl_id, FALSE)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes")
- if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst, NULL, NULL, dxpl_id, FALSE)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes")
-
- /* Determine largest datatype size */
- if(0 == (src_dt_size = H5T_get_size(dt_src)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
- if(0 == (mem_dt_size = H5T_get_size(dt_mem)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
- max_dt_size = MAX(src_dt_size, mem_dt_size);
- if(0 == (dst_dt_size = H5T_get_size(dt_dst)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
- max_dt_size = MAX(max_dt_size, dst_dt_size);
-
- /* Set maximum number of whole elements that fit in buffer */
- if(0 == (nelmts = buf_size / max_dt_size))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "element size too large")
-
- /* Set the number of bytes to transfer */
- src_nbytes = nelmts * src_dt_size;
- dst_nbytes = nelmts * dst_dt_size;
- mem_nbytes = nelmts * mem_dt_size;
-
- /* Adjust buffer size to be multiple of elements */
- buf_size = nelmts * max_dt_size;
-
- /* Create dataspace for number of elements in buffer */
- buf_dim = nelmts;
-
- /* Create the space and set the initial extent */
- if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
-
- /* Atomize */
- if((buf_sid = H5I_register(H5I_DATASPACE, buf_space)) < 0) {
- H5S_close(buf_space);
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
- } /* end if */
+ /* If there's a VLEN source datatype, set up type conversion information */
+ if(H5T_detect_class(dt_src, H5T_VLEN) > 0) {
+ /* Create datatype ID for src datatype */
+ if((tid_src = H5I_register(H5I_DATATYPE, dt_src)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
+
+ /* create a memory copy of the variable-length datatype */
+ if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
+ if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype")
+
+ /* create variable-length datatype at the destinaton file */
+ if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
+ if(H5T_set_loc(dt_dst, f_dst, H5T_LOC_DISK) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
+ if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype")
+
+ /* Set up the conversion functions */
+ if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem, NULL, NULL, dxpl_id, FALSE)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes")
+ if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst, NULL, NULL, dxpl_id, FALSE)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes")
+
+ /* Determine largest datatype size */
+ if(0 == (src_dt_size = H5T_get_size(dt_src)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
+ if(0 == (mem_dt_size = H5T_get_size(dt_mem)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
+ max_dt_size = MAX(src_dt_size, mem_dt_size);
+ if(0 == (dst_dt_size = H5T_get_size(dt_dst)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
+ max_dt_size = MAX(max_dt_size, dst_dt_size);
+
+ /* Set maximum number of whole elements that fit in buffer */
+ if(0 == (nelmts = buf_size / max_dt_size))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "element size too large")
+
+ /* Set the number of bytes to transfer */
+ src_nbytes = nelmts * src_dt_size;
+ dst_nbytes = nelmts * dst_dt_size;
+ mem_nbytes = nelmts * mem_dt_size;
+
+ /* Adjust buffer size to be multiple of elements */
+ buf_size = nelmts * max_dt_size;
+
+ /* Create dataspace for number of elements in buffer */
+ buf_dim = nelmts;
+
+ /* Create the space and set the initial extent */
+ if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
+
+ /* Atomize */
+ if((buf_sid = H5I_register(H5I_DATASPACE, buf_space)) < 0) {
+ H5S_close(buf_space);
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
+ } /* end if */
- /* Set flag to do type conversion */
- is_vlen = TRUE;
- }
+ /* Set flag to do type conversion */
+ is_vlen = TRUE;
+ } /* end if */
+ else {
/* Check for reference datatype */
- else if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) {
+ if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) {
/* Create datatype ID for src datatype, so it gets freed */
if((tid_src = H5I_register(H5I_DATATYPE, dt_src)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
@@ -1118,16 +1120,7 @@ H5D_contig_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
/* Need to fix values of references when copying across files */
if(f_src != f_dst)
fix_ref = TRUE;
-
- /* Set the number of bytes to read & write to the buffer size */
- src_nbytes = dst_nbytes = mem_nbytes = buf_size;
} /* end if */
- else
- HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to copy dataset elements")
- } /* end if */
- else {
- /* Type conversion not necessary */
- is_vlen = FALSE;
/* Set the number of bytes to read & write to the buffer size */
src_nbytes = dst_nbytes = mem_nbytes = buf_size;
@@ -1200,7 +1193,7 @@ H5D_contig_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
if(H5D_vlen_reclaim(tid_mem, buf_space, H5P_DATASET_XFER_DEFAULT, reclaim_buf) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length data")
} /* end if */
- else if(fix_ref) {
+ else if(fix_ref) {
/* Check for expanding references */
if(cpy_info->expand_ref) {
size_t ref_count;
diff --git a/src/H5Distore.c b/src/H5Distore.c
index d4a9708..dc39802 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -197,6 +197,7 @@ typedef struct H5D_istore_it_ud4_t {
void *buf; /* Buffer to hold chunk data for read/write */
void *bkg; /* Buffer for background information during type conversion */
size_t buf_size; /* Buffer size */
+ hbool_t do_convert; /* Whether to perform type conversions */
/* needed for converting variable-length data */
hid_t tid_src; /* Datatype ID for source datatype */
@@ -1014,7 +1015,7 @@ H5D_istore_iter_copy(H5F_t *f_src, hid_t dxpl_id, const void *_lt_key,
FUNC_ENTER_NOAPI_NOINIT(H5D_istore_iter_copy)
/* Check parameter for type conversion */
- if(udata->dt_src) {
+ if(udata->do_convert) {
if(H5T_detect_class(udata->dt_src, H5T_VLEN) > 0)
is_vlen = TRUE;
else if((H5T_get_class(udata->dt_src, FALSE) == H5T_REFERENCE) && (udata->file_src != udata->file_dst))
@@ -3566,6 +3567,7 @@ H5D_istore_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
H5S_t *buf_space = NULL; /* Dataspace describing buffer */
hid_t sid_buf = -1; /* ID for buffer dataspace */
size_t nelmts = 0; /* Number of elements in buffer */
+ hbool_t do_convert = FALSE; /* Indicate that type conversions should be performed */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5D_istore_copy, FAIL)
@@ -3575,6 +3577,7 @@ H5D_istore_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
HDassert(f_dst);
HDassert(layout_src && H5D_CHUNKED == layout_src->type);
HDassert(layout_dst && H5D_CHUNKED == layout_dst->type);
+ HDassert(dt_src);
/* Create shared B-tree info for each file */
if(H5D_istore_shared_create(f_src, layout_src) < 0)
@@ -3589,87 +3592,94 @@ H5D_istore_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to initialize chunked storage")
} /* end if */
- /* If there's a source datatype, set up type conversion information */
- if(dt_src) {
- if(H5T_detect_class(dt_src, H5T_VLEN) > 0) {
- H5T_t *dt_dst; /* Destination datatype */
- H5T_t *dt_mem; /* Memory datatype */
- size_t mem_dt_size; /* Memory datatype size */
- size_t tmp_dt_size; /* Temp. datatype size */
- size_t max_dt_size; /* Max atatype size */
- hsize_t buf_dim; /* Dimension for buffer */
- unsigned u;
+ /* If there's a VLEN source datatype, set up type conversion information */
+ if(H5T_detect_class(dt_src, H5T_VLEN) > 0) {
+ H5T_t *dt_dst; /* Destination datatype */
+ H5T_t *dt_mem; /* Memory datatype */
+ size_t mem_dt_size; /* Memory datatype size */
+ size_t tmp_dt_size; /* Temp. datatype size */
+ size_t max_dt_size; /* Max atatype size */
+ hsize_t buf_dim; /* Dimension for buffer */
+ unsigned u;
+
+ /* Create datatype ID for src datatype */
+ if((tid_src = H5I_register(H5I_DATATYPE, dt_src)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
+
+ /* create a memory copy of the variable-length datatype */
+ if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
+ if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype")
+
+ /* create variable-length datatype at the destinaton file */
+ if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
+ if(H5T_set_loc(dt_dst, f_dst, H5T_LOC_DISK) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
+ if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype")
+
+ /* Set up the conversion functions */
+ if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem, NULL, NULL, dxpl_id, FALSE)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes")
+ if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst, NULL, NULL, dxpl_id, FALSE)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes")
+
+ /* Determine largest datatype size */
+ if(0 == (max_dt_size = H5T_get_size(dt_src)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
+ if(0 == (mem_dt_size = H5T_get_size(dt_mem)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
+ max_dt_size = MAX(max_dt_size, mem_dt_size);
+ if(0 == (tmp_dt_size = H5T_get_size(dt_dst)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
+ max_dt_size = MAX(max_dt_size, tmp_dt_size);
+
+ /* Compute the number of elements per chunk */
+ nelmts = 1;
+ for(u = 0; u < (layout_src->u.chunk.ndims - 1); u++)
+ nelmts *= layout_src->u.chunk.dim[u];
+
+ /* Create the space and set the initial extent */
+ buf_dim = nelmts;
+ if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
+
+ /* Atomize */
+ if((sid_buf = H5I_register(H5I_DATASPACE, buf_space)) < 0) {
+ H5S_close(buf_space);
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
+ } /* end if */
+
+ /* Set initial buffer sizes */
+ buf_size = nelmts * max_dt_size;
+ reclaim_buf_size = nelmts * mem_dt_size;
+ /* Allocate memory for reclaim buf */
+ if(NULL == (reclaim_buf = H5MM_malloc(reclaim_buf_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk")
+
+ /* Indicate that type conversion should be performed */
+ do_convert = TRUE;
+ } /* end if */
+ else {
+ /* Create datatype ID for source datatype, so it gets freed */
+ if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) {
/* Create datatype ID for src datatype */
if((tid_src = H5I_register(H5I_DATATYPE, dt_src)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
- /* create a memory copy of the variable-length datatype */
- if(NULL == (dt_mem = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
- if((tid_mem = H5I_register(H5I_DATATYPE, dt_mem)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register memory datatype")
-
- /* create variable-length datatype at the destinaton file */
- if(NULL == (dt_dst = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
- if(H5T_set_loc(dt_dst, f_dst, H5T_LOC_DISK) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
- if((tid_dst = H5I_register(H5I_DATATYPE, dt_dst)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register destination file datatype")
-
- /* Set up the conversion functions */
- if(NULL == (tpath_src_mem = H5T_path_find(dt_src, dt_mem, NULL, NULL, dxpl_id, FALSE)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and mem datatypes")
- if(NULL == (tpath_mem_dst = H5T_path_find(dt_mem, dt_dst, NULL, NULL, dxpl_id, FALSE)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between mem and dst datatypes")
-
- /* Determine largest datatype size */
- if(0 == (max_dt_size = H5T_get_size(dt_src)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
- if(0 == (mem_dt_size = H5T_get_size(dt_mem)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
- max_dt_size = MAX(max_dt_size, mem_dt_size);
- if(0 == (tmp_dt_size = H5T_get_size(dt_dst)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to determine datatype size")
- max_dt_size = MAX(max_dt_size, tmp_dt_size);
-
- /* Compute the number of elements per chunk */
- nelmts = 1;
- for(u = 0; u < (layout_src->u.chunk.ndims - 1); u++)
- nelmts *= layout_src->u.chunk.dim[u];
-
- /* Create the space and set the initial extent */
- buf_dim = nelmts;
- if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL)))
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace")
-
- /* Atomize */
- if((sid_buf = H5I_register(H5I_DATASPACE, buf_space)) < 0) {
- H5S_close(buf_space);
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID")
- } /* end if */
-
- /* Set initial buffer sizes */
- buf_size = nelmts * max_dt_size;
- reclaim_buf_size = nelmts * mem_dt_size;
-
- /* Allocate memory for reclaim buf */
- if(NULL == (reclaim_buf = H5MM_malloc(reclaim_buf_size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk")
+ /* Indicate that type conversion should be performed */
+ do_convert = TRUE;
} /* end if */
- else {
- /* Create datatype ID for source datatype, so it gets freed */
- if(H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) {
- /* Create datatype ID for src datatype */
- if((tid_src = H5I_register(H5I_DATATYPE, dt_src)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register source file datatype")
- } /* end if */
- buf_size = layout_src->u.chunk.size;
- reclaim_buf_size = 0;
- } /* end else */
+ buf_size = layout_src->u.chunk.size;
+ reclaim_buf_size = 0;
+ } /* end else */
+ /* Set up conversion buffer, if appropriate */
+ if(do_convert) {
/* Allocate background memory for converting the chunk */
if(NULL == (bkg = H5MM_malloc(buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for raw data chunk")
@@ -3680,10 +3690,6 @@ H5D_istore_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
/* Reset value to zero */
HDmemset(bkg, 0, buf_size);
} /* end if */
- else {
- buf_size = layout_src->u.chunk.size;
- reclaim_buf_size = 0;
- } /* end else */
/* Allocate memory for copying the chunk */
if(NULL == (buf = H5MM_malloc(buf_size)))
@@ -3701,6 +3707,7 @@ H5D_istore_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
udata.tid_mem = tid_mem;
udata.tid_dst = tid_dst;
udata.dt_src = dt_src;
+ udata.do_convert = do_convert;
udata.tpath_src_mem = tpath_src_mem;
udata.tpath_mem_dst = tpath_mem_dst;
udata.reclaim_buf = reclaim_buf;
diff --git a/src/H5Doh.c b/src/H5Doh.c
index 042d9c5..52ac017 100644
--- a/src/H5Doh.c
+++ b/src/H5Doh.c
@@ -130,6 +130,10 @@ H5O_dset_free_copy_file_udata(void *_udata)
/* Sanity check */
HDassert(udata);
+ /* Release copy of dataset's dataspace extent, if it was set */
+ if(udata->src_space_extent)
+ H5O_free(H5O_SDSPACE_ID, udata->src_space_extent);
+
/* Release copy of dataset's datatype, if it was set */
if(udata->src_dtype)
H5T_close(udata->src_dtype);
diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h
index 71b944c..c67527d 100644
--- a/src/H5Dpkg.h
+++ b/src/H5Dpkg.h
@@ -269,7 +269,7 @@ H5_DLL ssize_t H5D_contig_writevv(const H5D_io_info_t *io_info,
size_t dset_max_nseq, size_t *dset_curr_seq, size_t dset_len_arr[], hsize_t dset_offset_arr[],
size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[],
const void *buf);
-H5_DLL herr_t H5D_contig_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
+H5_DLL herr_t H5D_contig_copy(H5F_t *f_src, const H5O_layout_t *layout_src, H5F_t *f_dst,
H5O_layout_t *layout_dst, H5T_t *src_dtype, H5O_copy_t *cpy_info, hid_t dxpl_id);
/* Functions that operate on compact dataset storage */
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index 81690e0..f45c2fd 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -39,7 +39,7 @@ static herr_t H5O_attr_free(void *mesg);
static herr_t H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link);
static herr_t H5O_attr_link(H5F_t *f, hid_t dxpl_id, const void *_mesg);
static herr_t H5O_attr_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
- void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata);
+ const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata);
static void *H5O_attr_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info,
void *udata);
@@ -760,7 +760,7 @@ done:
*/
static herr_t
H5O_attr_pre_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *type,
- void UNUSED *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info,
+ const void UNUSED *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info,
void UNUSED *udata)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_pre_copy_file)
@@ -1064,9 +1064,10 @@ static herr_t
H5O_attr_get_share(H5F_t UNUSED *f, const void *_mesg,
H5O_shared_t *sh /*out*/)
{
- H5A_t *mesg = (H5A_t *)_mesg;
+ const H5A_t *mesg = (const H5A_t *)_mesg;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_get_share);
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_get_share)
HDassert (mesg);
HDassert (sh);
@@ -1074,8 +1075,9 @@ H5O_attr_get_share(H5F_t UNUSED *f, const void *_mesg,
if(NULL == H5O_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh))
ret_value = FAIL;
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
+
/*-------------------------------------------------------------------------
* Function: H5O_attr_set_share
@@ -1097,7 +1099,8 @@ H5O_attr_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
{
H5A_t *mesg = (H5A_t *)_mesg;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_set_share);
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_set_share)
HDassert (mesg);
HDassert (sh);
@@ -1105,8 +1108,9 @@ H5O_attr_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
if(NULL == H5O_copy(H5O_SHARED_ID, sh, &(mesg->sh_loc)))
ret_value = FAIL;
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
+
/*-------------------------------------------------------------------------
* Function: H5O_attr_is_shared
@@ -1126,8 +1130,9 @@ H5O_attr_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
static htri_t
H5O_attr_is_shared(const void *_mesg)
{
- H5A_t *mesg = (H5A_t *)_mesg;
+ const H5A_t *mesg = (const H5A_t *)_mesg;
htri_t ret_value;
+
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_is_shared)
HDassert(mesg);
@@ -1143,6 +1148,7 @@ H5O_attr_is_shared(const void *_mesg)
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_attr_is_shared */
+
/*--------------------------------------------------------------------------
NAME
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index 1eb21f3..38f4f43 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -665,9 +665,8 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
done:
/* Free deleted array */
- if(deleted) {
+ if(deleted)
HDfree(deleted);
- }
/* Release pointer to source object header and its derived objects */
if(oh_src != NULL) {
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index c0b29cf..1a3fd4c 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -39,7 +39,7 @@ static herr_t H5O_dtype_set_share(H5F_t *f, void *_mesg,
const H5O_shared_t *sh);
static herr_t H5O_dtype_is_shared (const void *_mesg);
static herr_t H5O_dtype_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
- void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
+ const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
static herr_t H5O_dtype_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -1338,9 +1338,7 @@ H5O_dtype_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
/* If this is now a committed datatype, set its state properly. */
if(sh->flags & H5O_COMMITTED_FLAG)
- {
dt->shared->state = H5T_STATE_NAMED;
- }
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_dtype_set_share() */
@@ -1364,8 +1362,9 @@ H5O_dtype_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
static htri_t
H5O_dtype_is_shared (const void *_mesg)
{
- H5T_t *dt = (H5T_t *)_mesg;
+ const H5T_t *dt = (const H5T_t *)_mesg;
htri_t ret_value;
+
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_dtype_is_shared)
HDassert(dt);
@@ -1376,7 +1375,6 @@ H5O_dtype_is_shared (const void *_mesg)
ret_value = FALSE;
FUNC_LEAVE_NOAPI(ret_value)
-
} /* end H5O_dtype_is_shared */
@@ -1397,10 +1395,10 @@ H5O_dtype_is_shared (const void *_mesg)
*/
static herr_t
H5O_dtype_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *type,
- void *mesg_src, hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info,
+ const void *mesg_src, hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info,
void *_udata)
{
- H5T_t *dt_src = (H5T_t *)mesg_src; /* Source datatype */
+ const H5T_t *dt_src = (const H5T_t *)mesg_src; /* Source datatype */
H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1413,19 +1411,18 @@ H5O_dtype_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *type,
/* If the user data is non-NULL, assume we are copying a dataset
* and check if we need to make a copy of the datatype for later in
* the object copying process. (We currently only need to make a copy
- * of the datatype if it's a vlen or reference datatype)
+ * of the datatype if it's a vlen or reference datatype, or if the layout
+ * message is an early version, but since the layout information isn't
+ * available here, we just make a copy in all situations)
*/
if(udata) {
- if((H5T_detect_class(dt_src, H5T_VLEN) > 0) ||
- (H5T_get_class(dt_src, FALSE) == H5T_REFERENCE)) {
- /* Create a memory copy of the variable-length datatype */
- if(NULL == (udata->src_dtype = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
-
- /* Set the location of the source datatype */
- if(H5T_set_loc(udata->src_dtype, file_src, H5T_LOC_DISK) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
- } /* end if */
+ /* Create a memory copy of the variable-length datatype */
+ if(NULL == (udata->src_dtype = H5T_copy(dt_src, H5T_COPY_TRANSIENT)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy")
+
+ /* Set the location of the source datatype to describe the disk form of the data */
+ if(H5T_set_loc(udata->src_dtype, file_src, H5T_LOC_DISK) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "cannot mark datatype on disk")
} /* end if */
done:
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 22e0ae1..c9e1a4c 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -45,9 +45,9 @@ static void *H5O_fill_copy(const void *_mesg, void *_dest, unsigned update_flag
static size_t H5O_fill_size(const H5F_t *f, const void *_mesg);
static herr_t H5O_fill_reset(void *_mesg);
static herr_t H5O_fill_free(void *_mesg);
-static herr_t H5O_fill_new_get_share (H5F_t *f, const void *_mesg,
+static herr_t H5O_fill_new_get_share(H5F_t *f, const void *_mesg,
H5O_shared_t *sh);
-static herr_t H5O_fill_new_set_share (H5F_t *f, void *_mesg,
+static herr_t H5O_fill_new_set_share(H5F_t *f, void *_mesg,
const H5O_shared_t *sh);
static htri_t H5O_fill_new_is_shared(const void *_mesg);
static herr_t H5O_fill_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
@@ -688,9 +688,10 @@ static herr_t
H5O_fill_new_get_share(H5F_t UNUSED *f, const void *_mesg,
H5O_shared_t *sh /*out*/)
{
- H5O_fill_new_t *mesg = (H5O_fill_new_t *)_mesg;
+ const H5O_fill_new_t *mesg = (const H5O_fill_new_t *)_mesg;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_get_share);
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_get_share)
HDassert (mesg);
HDassert (sh);
@@ -698,7 +699,7 @@ H5O_fill_new_get_share(H5F_t UNUSED *f, const void *_mesg,
if(NULL == H5O_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh))
ret_value = FAIL;
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_fill_new_get_share() */
@@ -722,7 +723,8 @@ H5O_fill_new_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
{
H5O_fill_new_t *mesg = (H5O_fill_new_t *)_mesg;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_set_share);
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_set_share)
HDassert (mesg);
HDassert (sh);
@@ -730,8 +732,9 @@ H5O_fill_new_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
if(NULL == H5O_copy(H5O_SHARED_ID, sh, &(mesg->sh_loc)))
ret_value = FAIL;
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_fill_new_set_share() */
+
/*-------------------------------------------------------------------------
* Function: H5O_fill_new_is_shared
@@ -751,8 +754,9 @@ H5O_fill_new_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
static htri_t
H5O_fill_new_is_shared(const void *_mesg)
{
- H5O_fill_new_t *mesg = (H5O_fill_new_t *)_mesg;
+ const H5O_fill_new_t *mesg = (const H5O_fill_new_t *)_mesg;
htri_t ret_value;
+
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_fill_new_is_shared)
HDassert(mesg);
@@ -767,8 +771,8 @@ H5O_fill_new_is_shared(const void *_mesg)
ret_value = FALSE;
FUNC_LEAVE_NOAPI(ret_value)
-
} /* end H5O_fill_new_is_shared */
+
/*-------------------------------------------------------------------------
* Function: H5O_fill_new_debug
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 3b4d7e5..88a41e7 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -665,6 +665,14 @@ H5O_layout_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *mesg_type,
break;
case H5D_CONTIGUOUS:
+ /* Compute the size of the contiguous storage for versions of the
+ * layout message less than version 3 because versions 1 & 2 would
+ * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04
+ */
+ if(layout_src->version < 3)
+ layout_dst->u.contig.size = H5S_extent_nelem(udata->src_space_extent) *
+ H5T_get_size(udata->src_dtype);
+
if(H5F_addr_defined(layout_src->u.contig.addr)) {
/* create contig layout */
if(H5D_contig_copy(file_src, layout_src, file_dst, layout_dst, udata->src_dtype, cpy_info, dxpl_id) < 0)
@@ -729,13 +737,17 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_layout_debug);
/* check args */
- assert(f);
- assert(mesg);
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
+ HDassert(f);
+ HDassert(mesg);
+ HDassert(stream);
+ HDassert(indent >= 0);
+ HDassert(fwidth >= 0);
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Version:", mesg->version);
if(mesg->type==H5D_CHUNKED) {
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Type:", "Chunked");
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
"B-tree address:", mesg->u.chunk.addr);
HDfprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
@@ -750,12 +762,16 @@ H5O_layout_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE
HDfprintf(stream, "}\n");
} /* end if */
else if(mesg->type==H5D_CONTIGUOUS) {
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Type:", "Contiguous");
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
"Data address:", mesg->u.contig.addr);
HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth,
"Data Size:", mesg->u.contig.size);
} /* end if */
else {
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Type:", "Compact");
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Data Size:", mesg->u.compact.size);
} /* end else */
diff --git a/src/H5Olink.c b/src/H5Olink.c
index 8b7afbb..f7ee6e0 100644
--- a/src/H5Olink.c
+++ b/src/H5Olink.c
@@ -45,7 +45,7 @@ static herr_t H5O_link_reset(void *_mesg);
static herr_t H5O_link_free(void *_mesg);
/* static herr_t H5O_link_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link); */
static herr_t H5O_link_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
- void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata);
+ const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata);
static void *H5O_link_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info,
void *udata);
@@ -570,7 +570,7 @@ done:
*/
static herr_t
H5O_link_pre_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *type,
- void UNUSED *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info,
+ const void UNUSED *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info,
void UNUSED *udata)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_link_pre_copy_file)
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index b1c4498..a403680 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -166,7 +166,7 @@ struct H5O_msg_class_t {
herr_t (*get_share)(H5F_t*, const void*, struct H5O_shared_t*); /* Get shared information */
herr_t (*set_share)(H5F_t*, void*, const struct H5O_shared_t*); /* Set shared information */
htri_t (*is_shared)(const void*); /* Is message shared? */
- herr_t (*pre_copy_file)(H5F_t *, const H5O_msg_class_t *, void *, hbool_t *, const H5O_copy_t *, void *); /*"pre copy" action when copying native value to file */
+ herr_t (*pre_copy_file)(H5F_t *, const H5O_msg_class_t *, const void *, hbool_t *, const H5O_copy_t *, void *); /*"pre copy" action when copying native value to file */
void *(*copy_file)(H5F_t *, const H5O_msg_class_t *, void *, H5F_t *, hid_t, H5O_copy_t *, void *); /*copy native value to file */
herr_t (*post_copy_file)(const H5O_loc_t *, const void *, H5O_loc_t *, void *, hid_t, H5O_copy_t *); /*"post copy" action when copying native value to file */
herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int);
@@ -229,6 +229,7 @@ struct H5O_t {
/* Callback information for copying dataset */
typedef struct {
+ struct H5S_extent_t *src_space_extent; /* Copy of dataspace extent for dataset */
H5T_t *src_dtype; /* Copy of datatype for dataset */
H5O_pline_t *src_pline; /* Copy of filter pipeline for dataet */
} H5D_copy_file_ud_t;
@@ -396,7 +397,7 @@ H5_DLL herr_t H5O_assert(const H5O_t *oh);
H5_DLL herr_t H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, int indent, int fwidth);
/* Shared object operators */
-H5_DLL void * H5O_shared_read(H5F_t *f, hid_t dxpl_id, H5O_shared_t *shared,
+H5_DLL void * H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
const H5O_msg_class_t *type, void *mesg);
/* Useful metadata cache callbacks */
diff --git a/src/H5Opline.c b/src/H5Opline.c
index fae31fb..7210876 100644
--- a/src/H5Opline.c
+++ b/src/H5Opline.c
@@ -41,7 +41,7 @@ static herr_t H5O_pline_set_share (H5F_t *f, void *_mesg,
const H5O_shared_t *sh);
static htri_t H5O_pline_is_shared(const void *_mesg);
static herr_t H5O_pline_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
- void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
+ const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
static herr_t H5O_pline_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -571,10 +571,10 @@ H5O_pline_free(void *mesg)
*/
static herr_t
H5O_pline_pre_copy_file(H5F_t UNUSED *file_src, const H5O_msg_class_t UNUSED *type,
- void *mesg_src, hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info,
+ const void *mesg_src, hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info,
void *_udata)
{
- H5O_pline_t *pline_src = (H5O_pline_t *)mesg_src; /* Source datatype */
+ const H5O_pline_t *pline_src = (const H5O_pline_t *)mesg_src; /* Source datatype */
H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
herr_t ret_value = SUCCEED; /* Return value */
@@ -614,9 +614,10 @@ static herr_t
H5O_pline_get_share(H5F_t UNUSED *f, const void *_mesg,
H5O_shared_t *sh /*out*/)
{
- H5O_pline_t *mesg = (H5O_pline_t *)_mesg;
+ const H5O_pline_t *mesg = (const H5O_pline_t *)_mesg;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_get_share);
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_get_share)
HDassert (mesg);
HDassert (sh);
@@ -624,8 +625,9 @@ H5O_pline_get_share(H5F_t UNUSED *f, const void *_mesg,
if(NULL == H5O_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh))
ret_value = FAIL;
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_pline_get_share() */
+
/*-------------------------------------------------------------------------
* Function: H5O_pline_set_share
@@ -647,7 +649,8 @@ H5O_pline_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
{
H5O_pline_t *mesg = (H5O_pline_t *)_mesg;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_set_share);
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_set_share)
HDassert (mesg);
HDassert (sh);
@@ -655,8 +658,9 @@ H5O_pline_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
if(NULL == H5O_copy(H5O_SHARED_ID, sh, &(mesg->sh_loc)))
ret_value = FAIL;
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_pline_set_share() */
+
/*-------------------------------------------------------------------------
* Function: H5O_pline_is_shared
@@ -676,14 +680,15 @@ H5O_pline_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
static htri_t
H5O_pline_is_shared(const void *_mesg)
{
- H5O_pline_t *mesg = (H5O_pline_t *)_mesg;
+ const H5O_pline_t *mesg = (const H5O_pline_t *)_mesg;
htri_t ret_value;
+
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_pline_is_shared)
HDassert(mesg);
- /* Fill values can't currently be committed, but this should let the
- * library read a "committed fill value" if we ever create one in
+ /* I/O pipelines can't currently be committed, but this should let the
+ * library read a "committed I/O pipeline" if we ever create one in
* the future.
*/
if(mesg->sh_loc.flags & (H5O_COMMITTED_FLAG | H5O_SHARED_IN_HEAP_FLAG))
@@ -692,8 +697,8 @@ H5O_pline_is_shared(const void *_mesg)
ret_value = FALSE;
FUNC_LEAVE_NOAPI(ret_value)
-
} /* end H5O_pline_is_shared */
+
/*-------------------------------------------------------------------------
* Function: H5O_pline_debug
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 9c19675..bd2ee8d 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -15,13 +15,13 @@
#define H5O_PACKAGE /*suppress error about including H5Opkg */
#define H5S_PACKAGE /*prevent warning from including H5Spkg.h */
-#include "H5private.h"
-#include "H5Eprivate.h"
-#include "H5FLprivate.h" /*Free Lists */
-#include "H5Gprivate.h"
-#include "H5MMprivate.h"
-#include "H5Opkg.h" /* Object header functions */
-#include "H5Spkg.h"
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free lists */
+#include "H5Gprivate.h" /* Groups */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Opkg.h" /* Object headers */
+#include "H5Spkg.h" /* Dataspaces */
/* PRIVATE PROTOTYPES */
@@ -36,6 +36,8 @@ static herr_t H5O_sdspace_get_share (H5F_t *f, const void *_mesg,
static herr_t H5O_sdspace_set_share (H5F_t *f, void *_mesg,
const H5O_shared_t *sh);
static htri_t H5O_sdspace_is_shared (const void *_mesg);
+static herr_t H5O_sdspace_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
+ const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
static herr_t H5O_sdspace_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg,
FILE * stream, int indent, int fwidth);
@@ -55,7 +57,7 @@ const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{
H5O_sdspace_get_share, /* get share method */
H5O_sdspace_set_share, /* set share method */
H5O_sdspace_is_shared, /* is shared method */
- NULL, /* pre copy native value to file */
+ H5O_sdspace_pre_copy_file, /* pre copy native value to file */
NULL, /* copy native value to file */
NULL, /* post copy native value to file */
H5O_sdspace_debug /* debug the message */
@@ -323,22 +325,22 @@ H5O_sdspace_copy(const void *mesg, void *dest, unsigned UNUSED update_flags)
H5S_extent_t *dst = (H5S_extent_t *) dest;
void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_copy);
+ FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_copy)
/* check args */
assert(src);
if (!dst && NULL==(dst = H5FL_MALLOC(H5S_extent_t)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Copy extent information */
if(H5S_extent_copy(dst,src)<0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent")
/* Set return value */
ret_value=dst;
done:
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
@@ -412,11 +414,11 @@ H5O_sdspace_reset(void *_mesg)
{
H5S_extent_t *mesg = (H5S_extent_t*)_mesg;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_reset);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_reset)
H5S_extent_release(mesg);
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
}
@@ -437,13 +439,13 @@ H5O_sdspace_reset(void *_mesg)
static herr_t
H5O_sdspace_free (void *mesg)
{
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_free);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_free)
assert (mesg);
H5FL_FREE(H5S_extent_t,mesg);
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
}
@@ -465,19 +467,20 @@ static herr_t
H5O_sdspace_get_share(H5F_t UNUSED *f, const void *_mesg,
H5O_shared_t *sh /*out*/)
{
- H5S_extent_t *mesg = (H5S_extent_t *)_mesg;
+ const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_get_share);
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_get_share)
HDassert (mesg);
HDassert (sh);
-
if(NULL == H5O_copy(H5O_SHARED_ID, &(mesg->sh_loc), sh))
ret_value = FAIL;
- FUNC_LEAVE_NOAPI(ret_value);
-}
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_sdspace_get_share() */
+
/*-------------------------------------------------------------------------
* Function: H5O_sdspace_set_share
@@ -499,7 +502,8 @@ H5O_sdspace_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
{
H5S_extent_t *mesg = (H5S_extent_t *)_mesg;
herr_t ret_value = SUCCEED;
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_set_share);
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_set_share)
HDassert (mesg);
HDassert (sh);
@@ -507,8 +511,9 @@ H5O_sdspace_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
if(NULL == H5O_copy(H5O_SHARED_ID, sh, &(mesg->sh_loc)))
ret_value = FAIL;
- FUNC_LEAVE_NOAPI(ret_value);
+ FUNC_LEAVE_NOAPI(ret_value)
}
+
/*-------------------------------------------------------------------------
* Function: H5O_sdspace_is_shared
@@ -528,8 +533,9 @@ H5O_sdspace_set_share(H5F_t UNUSED *f, void *_mesg/*in,out*/,
static htri_t
H5O_sdspace_is_shared (const void *_mesg)
{
- H5S_extent_t *mesg = (H5S_extent_t *)_mesg;
+ const H5S_extent_t *mesg = (const H5S_extent_t *)_mesg;
htri_t ret_value;
+
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_is_shared)
HDassert(mesg);
@@ -544,8 +550,59 @@ H5O_sdspace_is_shared (const void *_mesg)
ret_value = FALSE;
FUNC_LEAVE_NOAPI(ret_value)
-
} /* end H5O_sdspace_is_shared */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_sdspace_pre_copy_file
+ *
+ * Purpose: Perform any necessary actions before copying message between
+ * files
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * November 30, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_sdspace_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *type,
+ const void *mesg_src, hbool_t UNUSED *deleted, const H5O_copy_t UNUSED *cpy_info,
+ void *_udata)
+{
+ const H5S_extent_t *src_space_extent = (const H5S_extent_t *)mesg_src; /* Source dataspace extent */
+ H5D_copy_file_ud_t *udata = (H5D_copy_file_ud_t *)_udata; /* Dataset copying user data */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_sdspace_pre_copy_file)
+
+ /* check args */
+ HDassert(file_src);
+ HDassert(src_space_extent);
+
+ /* If the user data is non-NULL, assume we are copying a dataset
+ * and make a copy of the dataspace extent for later in the object copying
+ * process. (We currently only need to make a copy of the dataspace extent
+ * if the layout is an early version, but that information isn't
+ * available here, so we just make a copy of it in all cases)
+ */
+ if(udata) {
+ /* Allocate copy of dataspace extent */
+ if(NULL == (udata->src_space_extent = H5FL_MALLOC(H5S_extent_t)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "dataspace extent allocation failed")
+
+ /* Create a copy of the dataspace extent */
+ if(H5S_extent_copy(udata->src_space_extent, src_space_extent) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent")
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dspace_pre_copy_file() */
+
/*--------------------------------------------------------------------------
NAME
@@ -572,7 +629,7 @@ H5O_sdspace_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg,
const H5S_extent_t *sdim = (const H5S_extent_t *) mesg;
unsigned u; /* local counting variable */
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_debug);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_debug)
/* check args */
assert(f);
@@ -607,6 +664,6 @@ H5O_sdspace_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *mesg,
}
} /* end if */
- FUNC_LEAVE_NOAPI(SUCCEED);
+ FUNC_LEAVE_NOAPI(SUCCEED)
}
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index 19c57b0..fa5f0d5 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -46,7 +46,7 @@ static herr_t H5O_shared_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg,
hbool_t adj_link);
static herr_t H5O_shared_link(H5F_t *f, hid_t dxpl_id, const void *_mesg);
static herr_t H5O_shared_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
- void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
+ const void *mesg_src, hbool_t *deleted, const H5O_copy_t *cpy_info, void *_udata);
static void *H5O_shared_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type,
void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t *cpy_info, void *udata);
static herr_t H5O_shared_debug (H5F_t*, hid_t dxpl_id, const void*, FILE*, int, int);
@@ -104,7 +104,7 @@ const H5O_msg_class_t H5O_MSG_SHARED[1] = {{
*-------------------------------------------------------------------------
*/
void *
-H5O_shared_read(H5F_t *f, hid_t dxpl_id, H5O_shared_t *shared,
+H5O_shared_read(H5F_t *f, hid_t dxpl_id, const H5O_shared_t *shared,
const H5O_msg_class_t *type, void *mesg)
{
H5HF_t *fheap = NULL;
@@ -611,10 +611,10 @@ done:
*/
static herr_t
H5O_shared_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type,
- void *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info,
+ const void *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info,
void *udata)
{
- H5O_shared_t *shared_src = (H5O_shared_t *)native_src;
+ const H5O_shared_t *shared_src = (const H5O_shared_t *)native_src;
void *mesg_native = NULL;
herr_t ret_value = SUCCEED; /* Return value */
diff --git a/src/H5S.c b/src/H5S.c
index fa58bc9..0fbb7fa 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -2306,6 +2306,32 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5S_extent_nelem
+ *
+ * Purpose: Determines how many elements a dataset extent describes.
+ *
+ * Return: Success: Number of data points in the dataset extent.
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 30, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+hsize_t
+H5S_extent_nelem(const H5S_extent_t *ext)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_extent_nelem)
+
+ /* check args */
+ HDassert(ext);
+
+ /* Return the number of elements in extent */
+ FUNC_LEAVE_NOAPI(ext->nelem)
+} /* end H5S_extent_nelem() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5S_debug
*
* Purpose: Prints debugging information about a data space.
diff --git a/src/H5Spkg.h b/src/H5Spkg.h
index 46f9201..c9b413e 100644
--- a/src/H5Spkg.h
+++ b/src/H5Spkg.h
@@ -37,7 +37,7 @@
* Dataspace extent information
*/
/* Extent container */
-typedef struct {
+struct H5S_extent_t {
H5S_class_t type; /* Type of extent */
hsize_t nelem; /* Number of elements in extent */
@@ -45,7 +45,7 @@ typedef struct {
hsize_t *size; /* Current size of the dimensions */
hsize_t *max; /* Maximum size of the dimensions */
H5O_shared_t sh_loc; /* location of this message if shared */
-} H5S_extent_t;
+};
/*
* Dataspace selection information
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index 9ea37bd..bdcd60a 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -45,6 +45,7 @@
/* Forward references of package typedefs */
typedef struct H5S_t H5S_t;
+typedef struct H5S_extent_t H5S_extent_t;
typedef struct H5S_pnt_node_t H5S_pnt_node_t;
typedef struct H5S_hyper_span_t H5S_hyper_span_t;
typedef struct H5S_hyper_span_info_t H5S_hyper_span_info_t;
@@ -215,6 +216,8 @@ H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/],
H5_DLL herr_t H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream,
int indent, int fwidth);
+H5_DLL hsize_t H5S_extent_nelem(const H5S_extent_t *ext);
+
/* Operations on selections */
H5_DLL herr_t H5S_select_deserialize(H5S_t *space, const uint8_t *buf);
H5_DLL H5S_sel_type H5S_get_select_type(const H5S_t *space);
diff --git a/test/objcopy.c b/test/objcopy.c
index d1f081e..21b4546 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -41,6 +41,11 @@ const char *FILENAME[] = {
};
#define FILE_EXT "objcopy_ext.dat"
+/* The fill_old.h5 is generated from gen_old_fill.c in HDF5 'test' directory
+ * for version 1.4(after 1.4.3). To get this data file, simply compile
+ * gen_old_fill.c with HDF5 library (before v1.5) and run it. */
+#define FILE_OLD_LAYOUT "fill_old.h5"
+
#define NAME_DATATYPE_SIMPLE "H5T_NATIVE_INT"
#define NAME_DATATYPE_SIMPLE2 "H5T_NATIVE_INT-2"
@@ -79,6 +84,7 @@ const char *FILENAME[] = {
#define NAME_LINK_EXTERN "/g_links/external_link_to_dataset_simple"
#define NAME_LINK_SOFT_DANGLE "/g_links/soft_link_to_nowhere"
#define NAME_LINK_SOFT_DANGLE2 "/g_links2/soft_link_to_nowhere"
+#define NAME_OLD_FORMAT "/dset1"
#define NAME_BUF_SIZE 1024
#define NUM_ATTRIBUTES 4
@@ -5490,6 +5496,94 @@ error:
/*-------------------------------------------------------------------------
+ * Function: test_copy_old_layout
+ *
+ * Purpose: Copy dataset that uses the "old" layout version (pre version 3)
+ * format.
+ *
+ * Note: This test uses the "fill_old.h5" file for convenience, since it
+ * has a dataset with the old layout format.
+ *
+ * Return: Success: 0
+ * Failure: number of errors
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, November 30, 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+test_copy_old_layout(hid_t fapl)
+{
+ hid_t fid_src = -1, fid_dst = -1; /* File IDs */
+ hid_t did = -1, did2 = -1; /* Dataset IDs */
+ char *srcdir = HDgetenv("srcdir"); /* Where the src code is located */
+ char src_filename[NAME_BUF_SIZE] = "";
+ char dst_filename[NAME_BUF_SIZE];
+
+ TESTING("H5Ocopy(): dataset with old layout format");
+
+ /* Generate correct name for source file by prepending the source path */
+ if(srcdir && ((HDstrlen(srcdir) + HDstrlen(FILE_OLD_LAYOUT) + 1) < sizeof(src_filename))) {
+ HDstrcpy(src_filename, srcdir);
+ HDstrcat(src_filename, "/");
+ } /* end if */
+ HDstrcat(src_filename, FILE_OLD_LAYOUT);
+
+ /* Initialize the destination filename */
+ h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename);
+
+ /* Reset file address checking info */
+ addr_reset();
+
+ /* open source file (read-only) */
+ if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR
+
+ /* create destination file */
+ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
+
+ /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */
+ if(H5Gclose(H5Gcreate(fid_dst, NAME_GROUP_UNCOPIED, (size_t)0)) < 0) TEST_ERROR
+
+ /* copy the dataset from SRC to DST */
+ if(H5Ocopy(fid_src, NAME_OLD_FORMAT, fid_dst, NAME_DATASET_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+
+ /* open the source dataset */
+ if((did = H5Dopen(fid_src, NAME_OLD_FORMAT)) < 0) TEST_ERROR
+
+ /* open the destination dataset */
+ if((did2 = H5Dopen(fid_dst, NAME_DATASET_SIMPLE)) < 0) TEST_ERROR
+
+ /* Check if the datasets are equal */
+ if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR
+
+ /* close the destination dataset */
+ if(H5Dclose(did2) < 0) TEST_ERROR
+
+ /* close the source dataset */
+ if(H5Dclose(did) < 0) TEST_ERROR
+
+ /* close the SRC file */
+ if(H5Fclose(fid_src) < 0) TEST_ERROR
+
+ /* close the DST file */
+ if(H5Fclose(fid_dst) < 0) TEST_ERROR
+
+ PASSED();
+ return 0;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(did2);
+ H5Dclose(did);
+ H5Fclose(fid_dst);
+ H5Fclose(fid_src);
+ } H5E_END_TRY;
+ return 1;
+} /* end test_copy_old_layout */
+
+
+/*-------------------------------------------------------------------------
* Function: test_copy_mount
*
* Purpose: Test copying objects between mounted files
@@ -7064,6 +7158,7 @@ main(void)
nerrors += test_copy_exist(my_fapl);
nerrors += test_copy_path(my_fapl);
nerrors += test_copy_same_file_named_datatype(my_fapl);
+ nerrors += test_copy_old_layout(my_fapl);
nerrors += test_copy_option(my_fapl, H5O_COPY_WITHOUT_ATTR_FLAG, FALSE, "H5Ocopy(): without attributes");
nerrors += test_copy_option(my_fapl, 0, TRUE, "H5Ocopy(): with missing groups");
nerrors += test_copy_option(my_fapl, H5O_COPY_EXPAND_SOFT_LINK_FLAG, FALSE, "H5Ocopy(): expand soft link");