summaryrefslogtreecommitdiffstats
path: root/src/H5Dcompact.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Dcompact.c')
-rw-r--r--src/H5Dcompact.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c
index 2d17a57..adc91eb 100644
--- a/src/H5Dcompact.c
+++ b/src/H5Dcompact.c
@@ -185,24 +185,33 @@ H5D_compact_copy(H5F_t *f_src, H5O_layout_t *layout_src, H5F_t *f_dst,
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(dt_src && (H5T_get_class(dt_src, FALSE) == H5T_REFERENCE) && (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")
+ 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
- /* Reset value to zero */
- HDmemset(layout_dst->u.compact.buf, 0, layout_src->u.compact.size);
+ /* Type conversion not necessary */
+ HDmemcpy(layout_dst->u.compact.buf, layout_src->u.compact.buf, layout_src->u.compact.size);
} /* end if */
- else if(dt_src && (H5T_detect_class(dt_src, H5T_VLEN) > 0) ) {
+ else 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 */