summaryrefslogtreecommitdiffstats
path: root/src/H5Ocopy.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2006-12-15 21:28:17 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2006-12-15 21:28:17 (GMT)
commit9236c9a148aaf206294be0554cf78e7ab769bd51 (patch)
treeafa397f1439fd0b6a45592cfc062102ea160d479 /src/H5Ocopy.c
parentaa646b5b43361597e547cea18af1825b43ad8ecb (diff)
downloadhdf5-9236c9a148aaf206294be0554cf78e7ab769bd51.zip
hdf5-9236c9a148aaf206294be0554cf78e7ab769bd51.tar.gz
hdf5-9236c9a148aaf206294be0554cf78e7ab769bd51.tar.bz2
[svn-r13065] Added support for copying shared messages (including turning unshared
messages to shared messages and vice versa). Extended objcopy test to test all "permutations" of shared/unshared and new/old group format. If this proves to take a long time to test, I'll go back and have it run fewer tests when HDF5_TEST_EXPRESS is enabled. Tested on smirom, kagiso, copper, and Windows.
Diffstat (limited to 'src/H5Ocopy.c')
-rw-r--r--src/H5Ocopy.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index e48f29c..cce2d6d 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -302,6 +302,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
size_t dst_oh_size; /* Total size of the destination OH */
uint8_t *current_pos; /* Current position in destination image */
size_t msghdr_size;
+ hbool_t shared; /* Whether copy_file callback created a shared message */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT(H5O_copy_header_real)
@@ -506,9 +507,32 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
/* Copy the source message */
if((mesg_dst->native = H5O_msg_copy_file(copy_type, mesg_dst->type,
oloc_src->file, mesg_src->native, oloc_dst->file, dxpl_id,
- cpy_info, udata)) == NULL)
+ &shared, cpy_info, udata)) == NULL)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object header message")
+ /* In being copied, the message may have become shared or stopped
+ * being shared. If its sharing status has changed, recalculate
+ * its size and set/unset its sharing flag.
+ */
+ if(shared == TRUE && !(mesg_dst->flags & H5O_MSG_FLAG_SHARED)) {
+ /* Set shared flag */
+ mesg_dst->flags |= H5O_MSG_FLAG_SHARED;
+
+ /* Recompute shared message size (mesg_dst->native is really
+ * an H5O_shared_t)
+ */
+ mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
+ H5O_msg_raw_size(oloc_dst->file, H5O_SHARED_ID, mesg_dst->native));
+ }
+ else if(shared == FALSE && (mesg_dst->flags & H5O_MSG_FLAG_SHARED)) {
+ /* Unset shared flag */
+ mesg_dst->flags &= ~H5O_MSG_FLAG_SHARED;
+
+ /* Recompute native message size */
+ mesg_dst->raw_size = H5O_ALIGN_OH(oh_dst,
+ H5O_msg_raw_size(oloc_dst->file, mesg_dst->type->id, mesg_dst->native));
+ }
+
/* Mark the message in the destination as dirty, so it'll get encoded when the object header is flushed */
mesg_dst->dirty = TRUE;
} /* end if (mesg_src->type->copy_file) */
@@ -528,7 +552,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */,
/* Add space for messages. */
for(mesgno = 0; mesgno < oh_dst->nmesgs; mesgno++) {
dst_oh_size += H5O_SIZEOF_MSGHDR_OH(oh_dst);
- dst_oh_size += H5O_ALIGN_OH(oh_dst, oh_dst->mesg[mesgno].raw_size);
+ dst_oh_size += oh_dst->mesg[mesgno].raw_size;
} /* end for */
/* Allocate space for chunk in destination file */