diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2012-03-21 15:10:17 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2012-03-21 15:10:17 (GMT) |
commit | eb89d7b53ab95623ab454186a602e1cafc7391f0 (patch) | |
tree | ceafe458b3011e38853e765352d3c7e59bbecce1 /src/H5Ocopy.c | |
parent | 3e468e6ff65d540a439e99ea568a6bff7add7cea (diff) | |
download | hdf5-eb89d7b53ab95623ab454186a602e1cafc7391f0.zip hdf5-eb89d7b53ab95623ab454186a602e1cafc7391f0.tar.gz hdf5-eb89d7b53ab95623ab454186a602e1cafc7391f0.tar.bz2 |
[svn-r22105] Description:
Bring r20557:22085 from trunk to this branch, also fixing some other
issues/failures in the branch simultaneously. The h5repack tests are still
failing, but Neil will be checking into those, so the branch can be fully
functional again.
Tested on:
Mac OSX/64 10.7.3 (amazon) w/debug
Diffstat (limited to 'src/H5Ocopy.c')
-rw-r--r-- | src/H5Ocopy.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 1ecd16f..dd649ff 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -186,7 +186,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(H5Ocopy, FAIL) + FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id); @@ -293,6 +293,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, unsigned mesgno = 0; haddr_t addr_new = HADDR_UNDEF; hbool_t *deleted = NULL; /* Array of flags indicating whether messages should be copied */ + hbool_t inserted = FALSE; /* Whether the destination object header has been inserted into the cache */ size_t null_msgs; /* Number of NULL messages found in each loop */ size_t orig_dst_msgs; /* Original # of messages in dest. object */ H5O_mesg_t *mesg_src; /* Message in source object header */ @@ -307,7 +308,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, size_t msghdr_size; herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT_TAG(H5O_copy_header_real, dxpl_id, oloc_src->addr, FAIL) + FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, oloc_src->addr, FAIL) HDassert(oloc_src); HDassert(oloc_src->file); @@ -370,9 +371,9 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, /* Allocate memory for "deleted" array. This array marks the message in * the source that shouldn't be copied to the destination. */ - if(NULL == (deleted = (hbool_t *)HDmalloc(sizeof(hbool_t) * oh_src->nmesgs))) + if(NULL == (deleted = (hbool_t *)HDmalloc(sizeof(hbool_t) * oh_src->nmesgs))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - HDmemset(deleted, FALSE, sizeof(hbool_t) * oh_src->nmesgs); + HDmemset(deleted, FALSE, sizeof(hbool_t) * oh_src->nmesgs); /* "pre copy" pass over messages, to gather information for actual message copy operation * (for messages which depend on information from other messages) @@ -745,6 +746,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, if(H5AC_insert_entry(oloc_dst->file, dxpl_id, H5AC_OHDR, oloc_dst->addr, oh_dst, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") oh_dst = NULL; + inserted = TRUE; /* Reset metadat tag */ H5_END_TAG(FAIL); @@ -769,9 +771,13 @@ done: if(oh_src && H5O_unprotect(oloc_src, dxpl_id, oh_src, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - /* Release pointer to destination object header */ - if(ret_value < 0 && oh_dst && H5O_free(oh_dst) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") + /* Free destination object header on failure */ + if(ret_value < 0 && oh_dst && !inserted) { + if(H5O_free(oh_dst) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") + if(H5O_loc_reset(oloc_dst) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") + } /* end if */ FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) } /* end H5O_copy_header_real() */ @@ -800,7 +806,7 @@ H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, hbool_t inc_link; /* Whether to increment the link count for the object */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5O_copy_header_map, FAIL) + FUNC_ENTER_NOAPI(FAIL) /* Sanity check */ HDassert(oloc_src); @@ -899,7 +905,7 @@ H5O_copy_free_addrmap_cb(void *_item, void UNUSED *key, void UNUSED *op_data) { H5O_addr_map_t *item = (H5O_addr_map_t *)_item; - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_copy_free_addrmap_cb) + FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(item); @@ -936,7 +942,7 @@ H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, H5O_copy_t cpy_info; /* Information for copying object */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT(H5O_copy_header) + FUNC_ENTER_NOAPI_NOINIT HDassert(oloc_src); HDassert(oloc_src->file); @@ -964,12 +970,11 @@ H5O_copy_header(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, cpy_info.preserve_null = TRUE; /* Create a skip list to keep track of which objects are copied */ - if((cpy_info.map_list = H5SL_create(H5SL_TYPE_OBJ)) == NULL) + if((cpy_info.map_list = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, FAIL, "cannot make skip list") /* copy the object from the source file to the destination file */ - if(H5O_copy_header_real(oloc_src, oloc_dst, dxpl_id, &cpy_info, NULL, NULL) - < 0) + if(H5O_copy_header_real(oloc_src, oloc_dst, dxpl_id, &cpy_info, NULL, NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: @@ -1006,7 +1011,7 @@ H5O_copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name, unsigned cpy_option = 0; /* Copy options */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5O_copy_obj, FAIL) + FUNC_ENTER_NOAPI(FAIL) HDassert(src_loc); HDassert(src_loc->oloc->file); @@ -1073,7 +1078,7 @@ H5O_copy_obj_by_ref(H5O_loc_t *src_oloc, hid_t dxpl_id, H5O_loc_t *dst_oloc, { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5O_copy_obj_by_ref, FAIL) + FUNC_ENTER_NOAPI(FAIL) HDassert(src_oloc); HDassert(dst_oloc); @@ -1141,7 +1146,7 @@ H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, hid_t dxpl_id, size_t i; /* Local index variable */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5O_copy_expand_ref, FAIL) + FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ HDassert(file_src); |