[svn-r19398] Descriptino:

Clean up the internal usage H5I_dec_ref() to eliminate the sequence of
flags that has been creeping in.

Tested on:
        FreeBSD/32 6.3 (duty) in debug mode
        FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
        Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
                w/C++ & FORTRAN, w/threadsafe, in debug mode
        Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
                w/C++ & FORTRAN, in production mode
        Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
                w/szip filter, w/threadsafe, in production mode
        Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
        Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
                in production mode
        Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
        Mac OS X/32 10.6.4 (amazon) in debug mode
        Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
                in production mode
        Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
This commit is contained in:
Quincey Koziol 2010-09-16 09:02:19 -05:00
parent e5575571d4
commit 1914737e06
35 changed files with 369 additions and 439 deletions

View File

@ -1029,10 +1029,10 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id)
done:
/* Release resources */
if(src_id >= 0)
(void)H5I_dec_ref(src_id, FALSE, FALSE);
if(dst_id >= 0)
(void)H5I_dec_ref(dst_id, FALSE, FALSE);
if(src_id >= 0 && H5I_dec_ref(src_id) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object")
if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object")
if(tconv_buf && !tconv_owned)
tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf);
if(bkg_buf)
@ -1175,10 +1175,10 @@ H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id)
done:
/* Release resources */
if(src_id >= 0)
(void)H5I_dec_ref(src_id, FALSE, FALSE);
if(dst_id >= 0)
(void)H5I_dec_ref(dst_id, FALSE, FALSE);
if(src_id >= 0 && H5I_dec_ref(src_id) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object")
if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object")
if(tconv_buf)
tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf);
if(bkg_buf)
@ -2047,8 +2047,8 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
done:
/* Release resources */
if(obj_loc_id > 0) {
if(H5I_dec_ref(obj_loc_id, TRUE, FALSE) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "unable to close temporary object")
if(H5I_dec_app_ref(obj_loc_id) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object")
} /* end if */
else if(loc_found && H5G_loc_free(&obj_loc) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location")
@ -2271,7 +2271,7 @@ H5Aclose(hid_t attr_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
/* Decrement references to that atom (and close it) */
if(H5I_dec_ref(attr_id, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(attr_id) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't close attribute")
done:

View File

@ -374,26 +374,26 @@ done:
int
H5AC_term_interface(void)
{
int n=0;
int n = 0;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5AC_term_interface)
if (H5_interface_initialize_g) {
#ifdef H5_HAVE_PARALLEL
if(H5AC_dxpl_id>0 || H5AC_noblock_dxpl_id>0 || H5AC_ind_dxpl_id>0) {
if(H5AC_dxpl_id > 0 || H5AC_noblock_dxpl_id > 0 || H5AC_ind_dxpl_id > 0) {
/* Indicate more work to do */
n = 1; /* H5I */
/* Close H5AC dxpl */
if (H5I_dec_ref(H5AC_dxpl_id, FALSE, FALSE) < 0 ||
H5I_dec_ref(H5AC_noblock_dxpl_id, FALSE, FALSE) < 0 ||
H5I_dec_ref(H5AC_ind_dxpl_id, FALSE, FALSE) < 0)
if(H5I_dec_ref(H5AC_dxpl_id) < 0 ||
H5I_dec_ref(H5AC_noblock_dxpl_id) < 0 ||
H5I_dec_ref(H5AC_ind_dxpl_id) < 0)
H5E_clear_stack(NULL); /*ignore error*/
else {
/* Reset static IDs */
H5AC_dxpl_id=(-1);
H5AC_noblock_dxpl_id=(-1);
H5AC_ind_dxpl_id=(-1);
H5AC_dxpl_id = (-1);
H5AC_noblock_dxpl_id = (-1);
H5AC_ind_dxpl_id = (-1);
/* Reset interface initialization flag */
H5_interface_initialize_g = 0;

View File

@ -1028,20 +1028,19 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si
ret_value = attr_dst;
done:
if(buf_sid > 0)
if(H5I_dec_ref(buf_sid, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary dataspace ID")
if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary dataspace ID")
if(tid_src > 0)
/* Don't decrement ID, we want to keep underlying datatype */
if(H5I_remove(tid_src) == NULL)
if(NULL == H5I_remove(tid_src))
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID")
if(tid_dst > 0)
/* Don't decrement ID, we want to keep underlying datatype */
if(H5I_remove(tid_dst) == NULL)
if(NULL == H5I_remove(tid_dst))
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID")
if(tid_mem > 0)
/* Decrement the memory datatype ID, it's transient */
if(H5I_dec_ref(tid_mem, FALSE, FALSE) < 0)
if(H5I_dec_ref(tid_mem) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID")
if(buf)
buf = H5FL_BLK_FREE(attr_buf, buf);

View File

@ -384,8 +384,8 @@ H5Dclose(hid_t dset_id)
* dataset's ID even though the freeing function might fail. Please
* see the comments in H5I_dec_ref for details. (SLU - 2010/9/7)
*/
if(H5I_dec_ref(dset_id, TRUE, TRUE) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free")
if(H5I_dec_app_ref_always_close(dset_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID")
done:
FUNC_LEAVE_API(ret_value)
@ -608,30 +608,32 @@ H5Dget_create_plist(hid_t dset_id)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype")
src_id = H5I_register(H5I_DATATYPE, H5T_copy(dset->shared->type, H5T_COPY_ALL), FALSE);
if(src_id < 0) {
H5I_dec_ref(dst_id, FALSE, FALSE);
H5I_dec_ref(dst_id);
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype")
} /* end if */
/* Allocate a background buffer */
bkg_size = MAX(H5T_GET_SIZE(copied_fill.type), H5T_GET_SIZE(dset->shared->type));
if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) {
H5I_dec_ref(src_id, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
} /* end if */
/* Convert fill value */
if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, copied_fill.buf, bkg_buf, H5AC_ind_dxpl_id) < 0) {
H5I_dec_ref(src_id, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
if(bkg_buf)
bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed")
} /* end if */
/* Release local resources */
H5I_dec_ref(src_id, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
if(H5I_dec_ref(src_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object")
if(H5I_dec_ref(dst_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object")
if(bkg_buf)
bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
} /* end if */
@ -647,7 +649,8 @@ H5Dget_create_plist(hid_t dset_id)
done:
if(ret_value < 0)
if(new_dcpl_id > 0)
(void)H5I_dec_ref(new_dcpl_id, TRUE, FALSE);
if(H5I_dec_app_ref(new_dcpl_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object")
FUNC_LEAVE_API(ret_value)
} /* end H5Dget_create_plist() */
@ -726,7 +729,8 @@ H5Dget_access_plist(hid_t dset_id)
done:
if(ret_value < 0)
if(new_dapl_id >= 0)
(void)H5I_dec_ref(new_dapl_id, TRUE, FALSE);
if(H5I_dec_app_ref(new_dapl_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object")
FUNC_LEAVE_API(ret_value)
} /* end H5Dget_access_plist() */
@ -1032,22 +1036,16 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id,
*size = vlen_bufsize.size;
done:
if(vlen_bufsize.fspace_id > 0) {
if(H5I_dec_ref(vlen_bufsize.fspace_id, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
} /* end if */
if(vlen_bufsize.mspace_id > 0) {
if(H5I_dec_ref(vlen_bufsize.mspace_id, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
} /* end if */
if(vlen_bufsize.fspace_id > 0 && H5I_dec_ref(vlen_bufsize.fspace_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
if(vlen_bufsize.mspace_id > 0 && H5I_dec_ref(vlen_bufsize.mspace_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
if(vlen_bufsize.fl_tbuf != NULL)
vlen_bufsize.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.fl_tbuf);
if(vlen_bufsize.vl_tbuf != NULL)
vlen_bufsize.vl_tbuf = H5FL_BLK_FREE(vlen_vl_buf, vlen_bufsize.vl_tbuf);
if(vlen_bufsize.xfer_pid > 0) {
if(H5I_dec_ref(vlen_bufsize.xfer_pid, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref count on property list")
} /* end if */
if(vlen_bufsize.xfer_pid > 0 && H5I_dec_ref(vlen_bufsize.xfer_pid) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref count on property list")
FUNC_LEAVE_API(ret_value)
} /* end H5Dvlen_get_buf_size() */

View File

@ -820,18 +820,14 @@ done:
fm->file_space = NULL;
fm->mem_space = NULL;
if(iter_init) {
if(H5S_SELECT_ITER_RELEASE(&(fm->mem_iter)) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
} /* end if */
if(f_tid!=(-1)) {
if(H5I_dec_ref(f_tid, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
} /* end if */
if(iter_init && H5S_SELECT_ITER_RELEASE(&(fm->mem_iter)) < 0)
HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator")
if(f_tid != (-1) && H5I_dec_ref(f_tid) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(file_space_normalized) {
/* (Casting away const OK -QAK) */
if(H5S_hyper_denormalize_offset((H5S_t *)file_space, old_offset) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset")
HDONE_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset")
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
@ -2516,7 +2512,6 @@ H5D_chunk_cache_evict(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *
/* Free */
ent = H5FL_FREE(H5D_rdcc_ent_t, ent);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_chunk_cache_evict() */
@ -4634,17 +4629,14 @@ H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src,
bkg = udata.bkg;
done:
if(sid_buf > 0 && H5I_dec_ref(sid_buf, FALSE, FALSE) < 0)
if(sid_buf > 0 && H5I_dec_ref(sid_buf) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID")
if(tid_src > 0)
if(H5I_dec_ref(tid_src, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_dst > 0)
if(H5I_dec_ref(tid_dst, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_mem > 0)
if(H5I_dec_ref(tid_mem, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_src > 0 && H5I_dec_ref(tid_src) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(buf)
H5MM_xfree(buf);
if(bkg)

View File

@ -558,17 +558,14 @@ H5D_compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst,
storage_dst->dirty = TRUE;
done:
if(buf_sid > 0 && H5I_dec_ref(buf_sid, FALSE, FALSE) < 0)
if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID")
if(tid_src > 0)
if(H5I_dec_ref(tid_src, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_dst > 0)
if(H5I_dec_ref(tid_dst, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_mem > 0)
if(H5I_dec_ref(tid_mem, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_src > 0 && H5I_dec_ref(tid_src) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(buf)
buf = H5FL_BLK_FREE(type_conv, buf);
if(reclaim_buf)

View File

@ -1450,17 +1450,14 @@ H5D_contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src,
} /* end while */
done:
if(buf_sid > 0 && H5I_dec_ref(buf_sid, FALSE, FALSE) < 0)
if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID")
if(tid_src > 0)
if(H5I_dec_ref(tid_src, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_dst > 0)
if(H5I_dec_ref(tid_dst, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_mem > 0)
if(H5I_dec_ref(tid_mem, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_src > 0 && H5I_dec_ref(tid_src) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(buf)
buf = H5FL_BLK_FREE(type_conv, buf);
if(reclaim_buf)

View File

@ -332,9 +332,9 @@ H5D_fill(const void *fill, const H5T_t *fill_type, void *buf,
} /* end else */
done:
if(src_id != (-1) && H5I_dec_ref(src_id, FALSE, FALSE) < 0)
if(src_id != (-1) && H5I_dec_ref(src_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(dst_id != (-1) && H5I_dec_ref(dst_id, FALSE, FALSE) < 0)
if(dst_id != (-1) && H5I_dec_ref(dst_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(tmp_buf)
tmp_buf = H5FL_BLK_FREE(type_conv, tmp_buf);
@ -693,7 +693,7 @@ H5D_fill_term(H5D_fill_buf_info_t *fb_info)
/* Free other resources for vlen fill values */
if(fb_info->has_vlen_fill_type) {
if(fb_info->mem_tid > 0)
H5I_dec_ref(fb_info->mem_tid, FALSE, FALSE);
H5I_dec_ref(fb_info->mem_tid);
else if(fb_info->mem_type)
H5T_close(fb_info->mem_type);
if(fb_info->bkg_buf)

View File

@ -560,8 +560,8 @@ H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type)
done:
if(ret_value == NULL)
if(new_dset != NULL) {
if(new_dset->dcpl_id != 0)
(void)H5I_dec_ref(new_dset->dcpl_id, FALSE, FALSE);
if(new_dset->dcpl_id != 0 && H5I_dec_ref(new_dset->dcpl_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement temporary datatype ID")
new_dset = H5FL_FREE(H5D_shared_t, new_dset);
} /* end if */
@ -1060,10 +1060,8 @@ done:
} /* end if */
if(new_dset->shared->space && H5S_close(new_dset->shared->space) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace")
if(new_dset->shared->type) {
if(H5I_dec_ref(new_dset->shared->type_id, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype")
} /* end if */
if(new_dset->shared->type && H5I_dec_ref(new_dset->shared->type_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype")
if(H5F_addr_defined(new_dset->oloc.addr)) {
if(H5O_close(&(new_dset->oloc)) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header")
@ -1072,7 +1070,7 @@ done:
HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header")
} /* end if */
} /* end if */
if(new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id, FALSE, FALSE) < 0)
if(new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list")
new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared);
} /* end if */
@ -1319,7 +1317,7 @@ done:
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
if(dataset->shared->type) {
if(dataset->shared->type_id > 0) {
if(H5I_dec_ref(dataset->shared->type_id, FALSE, FALSE) < 0)
if(H5I_dec_ref(dataset->shared->type_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
} /* end if */
else {
@ -1427,8 +1425,8 @@ H5D_close(H5D_t *dataset)
* Release datatype, dataspace and creation property list -- there isn't
* much we can do if one of these fails, so we just continue.
*/
free_failed = (unsigned)(H5I_dec_ref(dataset->shared->type_id, FALSE, FALSE) < 0 || H5S_close(dataset->shared->space) < 0 ||
H5I_dec_ref(dataset->shared->dcpl_id, FALSE, FALSE) < 0);
free_failed = (unsigned)(H5I_dec_ref(dataset->shared->type_id) < 0 || H5S_close(dataset->shared->space) < 0 ||
H5I_dec_ref(dataset->shared->dcpl_id) < 0);
/* Remove the dataset from the list of opened objects in the file */
if(H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0)

View File

@ -505,7 +505,7 @@ H5Eunregister_class(hid_t class_id)
* Decrement the counter on the dataset. It will be freed if the count
* reaches zero.
*/
if(H5I_dec_ref(class_id, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(class_id) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class")
done:
@ -684,7 +684,7 @@ H5Eclose_msg(hid_t err_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error class")
/* Decrement the counter. It will be freed if the count reaches zero. */
if(H5I_dec_ref(err_id, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(err_id) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message")
done:
@ -1036,7 +1036,7 @@ H5Eset_current_stack(hid_t err_stack)
* Decrement the counter on the error stack. It will be freed if the count
* reaches zero.
*/
if(H5I_dec_ref(err_stack, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(err_stack) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack")
} /* end if */
@ -1131,14 +1131,14 @@ H5Eclose_stack(hid_t stack_id)
if(H5E_DEFAULT != stack_id) {
/* Check arguments */
if (H5I_ERROR_STACK != H5I_get_type(stack_id))
if(H5I_ERROR_STACK != H5I_get_type(stack_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID")
/*
* Decrement the counter on the error stack. It will be freed if the count
* reaches zero.
*/
if(H5I_dec_ref(stack_id, TRUE, FALSE)<0)
if(H5I_dec_app_ref(stack_id) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack")
} /* end if */

View File

@ -892,11 +892,11 @@ H5E_clear_entries(H5E_t *estack, size_t nentries)
/* Decrement the IDs to indicate that they are no longer used by this stack */
/* (In reverse order that they were incremented, so that reference counts work well) */
if(H5I_dec_ref(error->min_num, FALSE, FALSE) < 0)
if(H5I_dec_ref(error->min_num) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message")
if(H5I_dec_ref(error->maj_num, FALSE, FALSE) < 0)
if(H5I_dec_ref(error->maj_num) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message")
if(H5I_dec_ref(error->cls_id, FALSE, FALSE) < 0)
if(H5I_dec_ref(error->cls_id) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class")
/* Release strings */

View File

@ -1062,10 +1062,10 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush)
/* Destroy file creation properties */
if(H5I_GENPROP_LST != H5I_get_type(f->shared->fcpl_id))
/* Push error, but keep going*/
HDONE_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list")
if(H5I_dec_ref(f->shared->fcpl_id, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a property list")
if(H5I_dec_ref(f->shared->fcpl_id) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close property list")
HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close property list")
/* Only truncate the file on an orderly close, with write-access */
if(f->closing && (H5F_ACC_RDWR & H5F_INTENT(f))) {
@ -1874,7 +1874,7 @@ H5F_try_close(H5F_t *f)
while((obj_count = H5F_get_obj_ids(f, H5F_OBJ_LOCAL|H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_ATTR, (int)(sizeof(objs)/sizeof(objs[0])), objs, FALSE)) != 0) {
/* Try to close all the open objects in this file */
for(u = 0; u < obj_count; u++)
if(H5I_dec_ref(objs[u], FALSE, FALSE) < 0)
if(H5I_dec_ref(objs[u]) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object")
} /* end while */
@ -1886,7 +1886,7 @@ H5F_try_close(H5F_t *f)
while((obj_count = H5F_get_obj_ids(f, H5F_OBJ_LOCAL|H5F_OBJ_DATATYPE, (int)(sizeof(objs)/sizeof(objs[0])), objs, FALSE)) != 0) {
/* Try to close all the open objects in this file */
for(u = 0; u < obj_count; u++)
if(H5I_dec_ref(objs[u], FALSE, FALSE) < 0)
if(H5I_dec_ref(objs[u]) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object")
} /* end while */
} /* end if */
@ -1973,7 +1973,7 @@ H5Fclose(hid_t file_id)
* Decrement reference count on atom. When it reaches zero the file will
* be closed.
*/
if(H5I_dec_ref(file_id, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(file_id) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed")
done:

View File

@ -396,29 +396,27 @@ done:
* Programmer: Robb Matzke
* Monday, July 26, 1999
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5FDunregister(hid_t driver_id)
{
herr_t ret_value=SUCCEED; /* Return value */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5FDunregister, FAIL)
H5TRACE1("e", "i", driver_id);
/* Check arguments */
if(NULL==H5I_object_verify(driver_id,H5I_VFL))
if(NULL == H5I_object_verify(driver_id, H5I_VFL))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver")
/* The H5FD_class_t struct will be freed by this function */
if(H5I_dec_ref(driver_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to unregister file driver")
if(H5I_dec_app_ref(driver_id) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "unable to unregister file driver")
done:
FUNC_LEAVE_API(ret_value)
}
} /* end H5FDunregister() */
/*-------------------------------------------------------------------------
@ -660,7 +658,7 @@ H5FD_pl_close(hid_t driver_id, herr_t (*free_func)(void *), void *pl)
H5MM_xfree(pl);
/* Decrement reference count for driver */
if(H5I_dec_ref(driver_id, FALSE, FALSE) < 0)
if(H5I_dec_ref(driver_id) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement reference count for driver")
done:
@ -1187,7 +1185,7 @@ H5FD_close(H5FD_t *file)
/* Prepare to close file by clearing all public fields */
driver = file->cls;
if(H5I_dec_ref(file->driver_id, FALSE, FALSE) < 0)
if(H5I_dec_ref(file->driver_id) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID")
/*

View File

@ -468,11 +468,11 @@ static herr_t
H5FD_family_fapl_free(void *_fa)
{
H5FD_family_fapl_t *fa = (H5FD_family_fapl_t*)_fa;
herr_t ret_value=SUCCEED; /* Return value */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_family_fapl_free, FAIL)
if(H5I_dec_ref(fa->memb_fapl_id, FALSE, FALSE)<0)
if(H5I_dec_ref(fa->memb_fapl_id) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID")
H5MM_xfree(fa);
@ -554,11 +554,11 @@ static herr_t
H5FD_family_dxpl_free(void *_dx)
{
H5FD_family_dxpl_t *dx = (H5FD_family_dxpl_t*)_dx;
herr_t ret_value=SUCCEED; /* Return value */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_family_dxpl_free, FAIL)
if(H5I_dec_ref(dx->memb_dxpl_id, FALSE, FALSE)<0)
if(H5I_dec_ref(dx->memb_dxpl_id) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID")
H5MM_xfree(dx);
@ -855,29 +855,30 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
done:
/* Cleanup and fail */
if (ret_value==NULL && file!=NULL) {
unsigned nerrors=0; /* Number of errors closing member files */
if(ret_value == NULL && file != NULL) {
unsigned nerrors = 0; /* Number of errors closing member files */
unsigned u; /* Local index variable */
/* Close as many members as possible. Use private function here to avoid clearing
* the error stack. We need the error message to indicate wrong member file size. */
for (u=0; u<file->nmembs; u++)
if (file->memb[u])
if (H5FD_close(file->memb[u])<0)
for(u = 0; u < file->nmembs; u++)
if(file->memb[u])
if(H5FD_close(file->memb[u]) < 0)
nerrors++;
if (nerrors)
if(nerrors)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "unable to close member files")
if (file->memb)
if(file->memb)
H5MM_xfree(file->memb);
if(H5I_dec_ref(file->memb_fapl_id, FALSE, FALSE)<0)
if(H5I_dec_ref(file->memb_fapl_id) < 0)
HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close driver ID")
if (file->name)
if(file->name)
H5MM_xfree(file->name);
H5MM_xfree(file);
}
} /* end if */
FUNC_LEAVE_NOAPI(ret_value)
}
} /* end H5FD_family_open() */
/*-------------------------------------------------------------------------
@ -921,7 +922,7 @@ H5FD_family_close(H5FD_t *_file)
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close member files")
/* Clean up other stuff */
if(H5I_dec_ref(file->memb_fapl_id, FALSE, FALSE) < 0)
if(H5I_dec_ref(file->memb_fapl_id) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID")
H5MM_xfree(file->memb);

View File

@ -504,7 +504,8 @@ H5Gget_create_plist(hid_t group_id)
done:
if(ret_value < 0) {
if(new_gcpl_id > 0)
(void)H5I_dec_ref(new_gcpl_id, TRUE, FALSE);
if(H5I_dec_app_ref(new_gcpl_id) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free")
} /* end if */
FUNC_LEAVE_API(ret_value)
@ -714,7 +715,7 @@ H5Gclose(hid_t group_id)
* Decrement the counter on the group atom. It will be freed if the count
* reaches zero.
*/
if(H5I_dec_ref(group_id, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(group_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group")
done:
@ -1536,7 +1537,7 @@ H5G_iterate(hid_t loc_id, const char *group_name,
done:
/* Release the group opened */
if(gid > 0) {
if(H5I_dec_ref(gid, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(gid) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group")
} /* end if */
else if(grp && H5G_close(grp) < 0)
@ -1869,7 +1870,7 @@ done:
/* Release the group opened */
if(gid > 0) {
if(H5I_dec_ref(gid, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(gid) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group")
} /* end if */
else if(grp && H5G_close(grp) < 0)

View File

@ -253,7 +253,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
done:
if(tmp_gcpl > 0 && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT)
if(H5I_dec_ref(tmp_gcpl, FALSE, FALSE) < 0)
if(H5I_dec_ref(tmp_gcpl) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release property list")
if(ret_value < 0)

View File

@ -461,12 +461,12 @@ H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size,
/* Search for name of object */
if((len = H5G_get_name_by_addr(file, lapl_id, dxpl_id, loc->oloc, name, size)) < 0) {
H5I_dec_ref(file, FALSE, FALSE);
H5I_dec_ref(file);
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name")
} /* end if */
/* Close file ID used for search */
if(H5I_dec_ref(file, FALSE, FALSE) < 0)
if(H5I_dec_ref(file) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTCLOSEFILE, FAIL, "can't determine name")
/* Indicate that the name is _not_ cached, if requested */

View File

@ -270,22 +270,20 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk,
/* We have a copy of the location and we're holding the file open.
* Close the open ID the user passed back.
*/
if(H5I_dec_ref(cb_return, FALSE, FALSE) < 0)
if(H5I_dec_ref(cb_return) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback")
cb_return = (-1);
done:
/* Close location given to callback. */
if(cur_grp > 0)
if(H5I_dec_ref(cur_grp, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom for current location")
if(cur_grp > 0 && H5I_dec_ref(cur_grp) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom for current location")
if(ret_value < 0 && cb_return > 0)
if(H5I_dec_ref(cb_return, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback")
if(ret_value < 0 && cb_return > 0 && H5I_dec_ref(cb_return) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback")
/* Close the LAPL, if we copied one */
if(lapl_id > 0 && H5I_dec_ref(lapl_id, FALSE, FALSE) < 0)
if(lapl_id > 0 && H5I_dec_ref(lapl_id) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close copied link access property list")
FUNC_LEAVE_NOAPI(ret_value)

302
src/H5I.c
View File

@ -165,9 +165,7 @@ H5I_init_interface(void)
*
* Failure: Negative.
*
* Programmer:
*
* Modifications:
* Programmer: Unknown
*
*-------------------------------------------------------------------------
*/
@ -217,15 +215,12 @@ H5I_term_interface(void)
* the type.
*
* Return: Success: Type ID of the new type
*
* Failure: H5I_BADID
*
* Programmers: Nathaniel Furrer
* James Laird
* James Laird
* Friday, April 30, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5I_type_t
@ -263,22 +258,9 @@ done:
* Failure: H5I_BADID
*
* Programmers: Nathaniel Furrer
* James Laird
* James Laird
* Friday, April 30, 2004
*
* Modifications: The initialization section of this function was formerly
* H5I_init_type, programmed by Robb Matzke on February 19,
* 1999.
*
* Bill Wendling, 2000-05-05
* Instead of the ugly test of whether hash_size is a power of
* two, I placed it in a macro POWER_OF_TWO which uses the fact
* that a number that is a power of two has only 1 bit set.
*
* Bill Wendling, 2000-05-09
* Changed POWER_OF_TWO macro to allow 1 as a valid power of two.
* Changed test below accordingly.
*
*-------------------------------------------------------------------------
*/
H5I_type_t
@ -376,15 +358,12 @@ done:
* currently registered with the library.
*
* Return: Success: 1 if the type is registered, 0 if it is not
*
* Failure: Negative
*
* Programmer: James Laird
* Nathaniel Furrer
* Tuesday, June 29, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
htri_t
@ -415,19 +394,12 @@ done:
* private interface, which will just return 0.
*
* Return: Success: Zero
*
* Failure: Negative
*
* Programmer: James Laird
* Nathaniel Furrer
* Friday, April 23, 2004
*
* Modifications:
* June 29, 2004
* Nat Furrer and James Laird
* Changed function signature to return the number of members
* by reference.
*
*-------------------------------------------------------------------------
*/
herr_t
@ -477,8 +449,6 @@ done:
* Programmer: Robb Matzke
* Wednesday, March 24, 1999
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
@ -510,14 +480,12 @@ done:
* Public interface to H5I_clear_type.
*
* Return: Success: Non-negative
*
* Failure: negative
*
* Programmer: James Laird
* Nathaniel Furrer
* Nathaniel Furrer
* Friday, April 23, 2004
*
* Modifications:
*-------------------------------------------------------------------------
*/
herr_t
@ -545,7 +513,6 @@ done:
* function for each object regardless of the reference count.
*
* Return: Success: Non-negative
*
* Failure: negative
*
* Programmer: Robb Matzke
@ -699,8 +666,6 @@ done:
* Programmer: Nathaniel Furrer
* James Laird
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
@ -734,8 +699,6 @@ done:
* Programmer: Nathaniel Furrer
* James Laird
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
@ -773,13 +736,10 @@ done:
* Purpose: Public interface to H5I_register.
*
* Return: Success: New object id.
*
* Failure: Negative
*
* Programmer: Nathaniel Furrer
* James Laird
*
* Modifications:
* James Laird
*
*-------------------------------------------------------------------------
*/
@ -813,7 +773,6 @@ done:
* the ID which is returned to the user.
*
* Return: Success: New object id.
*
* Failure: Negative
*
* Programmer: Unknown
@ -969,12 +928,9 @@ done:
*
* Return: Success: Non-null object pointer associated with the
* specified ID.
*
* Failure: NULL
*
* Programmer:
*
* Modifications:
* Programmer: Unknown
*
*-------------------------------------------------------------------------
*/
@ -1007,15 +963,12 @@ done:
*
* Return: Success: Non-null object pointer associated with the
* specified ID.
*
* Failure: NULL
*
* Programmer: Nathaniel Furrer
* James Laird
* Friday, April 23, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void *
@ -1046,14 +999,11 @@ done:
*
* Return: Success: Non-null object pointer associated with the
* specified ID.
*
* Failure: NULL
*
* Programmer: Quincey Koziol
* Wednesday, July 31, 2002
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void *
@ -1087,14 +1037,11 @@ done:
* in the object ID.
*
* Return: Success: A valid type number
*
* Failure: H5I_BADID, a negative value.
*
* Programmer: Robb Matzke
* Friday, February 19, 1999
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
H5I_type_t
@ -1123,15 +1070,10 @@ done:
* encoded as part of the ID.
*
* Return: Success: Type number
*
* Failure: H5I_BADID, a negative value
*
* Programmer:
* Programmer: Unknown
*
* Modifications:
* Robb Matzke, 1999-08-23
* Also fails if the ID has a valid type but no longer exists
* in the ID tables.
*-------------------------------------------------------------------------
*/
H5I_type_t
@ -1162,13 +1104,10 @@ done:
* Return: Success: A pointer to the object that was removed, the
* same pointer which would have been found by
* calling H5I_object().
*
* Failure: NULL
*
* Programmer: James Laird
* Nathaniel Furrer
*
* Modifications:
* Nathaniel Furrer
*
*-------------------------------------------------------------------------
*/
@ -1199,13 +1138,10 @@ done:
* Return: Success: A pointer to the object that was removed, the
* same pointer which would have been found by
* calling H5I_object().
*
* Failure: NULL
*
* Programmer: James Laird
* Nat Furrer
*
* Modifications:
* Nat Furrer
*
*-------------------------------------------------------------------------
*/
@ -1236,12 +1172,9 @@ done:
* Return: Success: A pointer to the object that was removed, the
* same pointer which would have been found by
* calling H5I_object().
*
* Failure: NULL
*
* Programmer:
*
* Modifications:
* Programmer: Unknown
*
*-------------------------------------------------------------------------
*/
@ -1330,7 +1263,7 @@ H5Idec_ref(hid_t id)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID")
/* Do actual decrement operation */
if((ret_value = H5I_dec_ref(id, TRUE, FALSE)) < 0)
if((ret_value = H5I_dec_app_ref(id)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count")
done:
@ -1353,41 +1286,10 @@ done:
*
* Programmer: Unknown
*
* Modifications:
*
* Robb Matzke, 19 Feb 1998
* It is no longer an error when the reference count of an item reaches
* zero and no `free' function has been defined. The object is still
* removed from the list.
*
* Robb Matzke, 30 Dec 1998
* Fixed a bug where the return value was always zero instead of the new
* reference count.
*
* Robb Matzke, 19 Feb 1999
* If the free method is defined and fails then the object is not
* removed from the type and its reference count is not decremented.
* The type number is now passed to the free method.
*
* Raymond Lu, 11 Dec 2001
* If the freeing function fails, return failure instead of reference
* count 1. This feature is needed by file close with H5F_CLOSE_SEMI
* value.
*
* Neil Fortner, 7 Aug 2008
* Added app_ref parameter and support for the app_count field, to
* distiguish between reference count from the library and from the
* application.
*
* Raymond Lu, 7 September 2010
* I added the 3rd parameter to indicate whether H5Dclose is calling
* this function. All other calls should pass in FALSE. Please see
* the comments in the code below.
*
*-------------------------------------------------------------------------
*/
int
H5I_dec_ref(hid_t id, hbool_t app_ref, hbool_t dset_close)
H5I_dec_ref(hid_t id)
{
H5I_type_t type; /*type the object is in*/
H5I_id_type_t *type_ptr; /*ptr to the type */
@ -1408,7 +1310,7 @@ H5I_dec_ref(hid_t id, hbool_t app_ref, hbool_t dset_close)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number")
/* General lookup of the ID */
if(NULL == (id_ptr=H5I_find_id(id)))
if(NULL == (id_ptr = H5I_find_id(id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID")
/*
@ -1421,10 +1323,10 @@ H5I_dec_ref(hid_t id, hbool_t app_ref, hbool_t dset_close)
*
* Beware: the free method may call other H5I functions.
*
* If a dataset is closing, we remove the ID even though the freeing
* might fail. This can happen when a mandatory filter fails to write
* when the dataset is closed and the chunk cache is flushed to the
* file. We have a close the dataset anyway. (SLU - 2010/9/7)
* If an object is closing, we can remove the ID even though the free
* method might fail. This can happen when a mandatory filter fails to
* write when a dataset is closed and the chunk cache is flushed to the
* file. We have to close the dataset anyway. (SLU - 2010/9/7)
*/
if(1 == id_ptr->count) {
/* (Casting away const OK -QAK) */
@ -1432,24 +1334,111 @@ H5I_dec_ref(hid_t id, hbool_t app_ref, hbool_t dset_close)
H5I_remove(id);
ret_value = 0;
} /* end if */
else {
if(dset_close)
H5I_remove(id);
else
ret_value = FAIL;
}
} /* end if */
else {
--(id_ptr->count);
if(app_ref)
--(id_ptr->app_count);
HDassert(id_ptr->count >= id_ptr->app_count);
ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count);
}
ret_value = (int)id_ptr->count;
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_dec_ref() */
/*-------------------------------------------------------------------------
* Function: H5I_dec_app_ref
*
* Purpose: H5I_dec_ref wrapper for case of modifying the application ref.
* count for an ID as well as normal reference count.
*
* Return: Success: New app. reference count.
* Failure: Negative
*
* Programmer: Quincey Koziol
* Sept 16, 2010
*
*-------------------------------------------------------------------------
*/
int
H5I_dec_app_ref(hid_t id)
{
H5I_id_info_t *id_ptr; /*ptr to the new ID */
int ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5I_dec_app_ref, FAIL)
/* Sanity check */
HDassert(id >= 0);
/* Call regular decrement reference count routine */
if((ret_value = H5I_dec_ref(id)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count")
/* Check if the ID still exists */
if(ret_value > 0) {
/* General lookup of the ID */
if(NULL == (id_ptr = H5I_find_id(id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID")
/* Adjust app_ref */
--(id_ptr->app_count);
HDassert(id_ptr->count >= id_ptr->app_count);
/* Set return value */
ret_value = (int)id_ptr->app_count;
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_dec_app_ref() */
/*-------------------------------------------------------------------------
* Function: H5I_dec_app_ref_always_close
*
* Purpose: H5I_dec_app_ref wrapper for case of always closing the ID,
* even when the free routine fails
*
* Return: Success: New app. reference count.
* Failure: Negative
*
* Programmer: Quincey Koziol
* Sept 16, 2010
*
*-------------------------------------------------------------------------
*/
int
H5I_dec_app_ref_always_close(hid_t id)
{
int ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5I_dec_app_ref_always_close, FAIL)
/* Sanity check */
HDassert(id >= 0);
/* Call application decrement reference count routine */
ret_value = H5I_dec_app_ref(id);
/* Check for failure */
if(ret_value < 0) {
/*
* If an object is closing, we can remove the ID even though the free
* method might fail. This can happen when a mandatory filter fails to
* write when a dataset is closed and the chunk cache is flushed to the
* file. We have to close the dataset anyway. (SLU - 2010/9/7)
*/
H5I_remove(id);
HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count")
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_dec_app_ref_always_close() */
/*-------------------------------------------------------------------------
* Function: H5Iinc_ref
@ -1462,8 +1451,6 @@ done:
* Programmer: Quincey Koziol
* Dec 7, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
@ -1493,7 +1480,6 @@ done:
* Purpose: Increment the reference count for an object.
*
* Return: Success: The new reference count.
*
* Failure: Negative
*
* Programmer: Robb Matzke
@ -1557,8 +1543,6 @@ done:
* Programmer: Quincey Koziol
* Dec 7, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
@ -1588,7 +1572,6 @@ done:
* Purpose: Retrieve the reference count for an object.
*
* Return: Success: The reference count.
*
* Failure: Negative
*
* Programmer: Quincey Koziol
@ -1645,11 +1628,9 @@ done:
* Failure: Negative
*
* Programmer: Nat Furrer
* James Laird
* James Laird
* April 30, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
@ -1682,15 +1663,12 @@ done:
* Purpose: Increment the reference count for an ID type.
*
* Return: Success: The new reference count.
*
* Failure: Negative
*
* Programmer: James Laird
* Nat Furrer
* Nat Furrer
* Friday, April 30, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
@ -1735,9 +1713,7 @@ done:
* Return: Number of references to type on success/Negative on failure
*
* Programmer: Nathaniel Furrer
* James Laird
*
* Modifications:
* James Laird
*
*-------------------------------------------------------------------------
*/
@ -1777,11 +1753,6 @@ done:
*
* Programmer: Unknown
*
* Modifications:
*
* Robb Matzke, 25 Feb 1998
* IDs are freed when a type is destroyed.
*
*-------------------------------------------------------------------------
*/
herr_t
@ -1828,11 +1799,9 @@ done:
* Failure: Negative
*
* Programmer: Nat Furrer
* James Laird
* James Laird
* April 30, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
@ -1869,11 +1838,9 @@ done:
* Failure: Negative
*
* Programmer: Nat Furrer
* James Laird
* James Laird
* April 30, 2004
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
@ -1913,12 +1880,6 @@ done:
* Programmer: Neil Fortner
* Friday, October 31, 2008 (boo)
*
* Modifications:
* Raymond Lu
* 1 April 2009 (Believe it or not!)
* Moved the argument check down to H5I_find_id because other
* caller functions may pass in some invalid IDs to H5I_find_id.
* It used to do assertion check.
*-------------------------------------------------------------------------
*/
htri_t
@ -1999,7 +1960,6 @@ done:
* Return: Success: The first object in the type for which FUNC
* returns non-zero. NULL if FUNC returned zero
* for every object in the type.
*
* Failure: NULL
*
* Programmer: Robb Matzke
@ -2062,12 +2022,8 @@ done:
*
* Failure: NULL
*
* Programmer:
* Programmer: Unknown
*
* Modifications:
* Raymond Lu
* 1 April 2009 (Believe it or not!)
* Added argument check, took away assertion check.
*-------------------------------------------------------------------------
*/
static H5I_id_info_t *
@ -2179,8 +2135,6 @@ done:
* Programmer: Raymond Lu
* Oct 27, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
hid_t
@ -2251,21 +2205,15 @@ done:
/*-------------------------------------------------------------------------
* Function: H5I_debug
* Function: H5I_debug
*
* Purpose: Dump the contents of a type to stderr for debugging.
* Purpose: Dump the contents of a type to stderr for debugging.
*
* Return: Success: Non-negative
* Return: Success: Non-negative
* Failure: Negative
*
* Failure: Negative
*
* Programmer: Robb Matzke
* Friday, February 19, 1999
*
* Modifications:
*
* Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
* Added `id to name' support.
* Programmer: Robb Matzke
* Friday, February 19, 1999
*
*-------------------------------------------------------------------------
*/

View File

@ -65,7 +65,9 @@ H5_DLL void *H5I_remove_verify(hid_t id, H5I_type_t id_type);
H5_DLL void *H5I_search(H5I_type_t type, H5I_search_func_t func, void *key, hbool_t app_ref);
H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref);
H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref);
H5_DLL int H5I_dec_ref(hid_t id, hbool_t app_ref, hbool_t dset_close);
H5_DLL int H5I_dec_ref(hid_t id);
H5_DLL int H5I_dec_app_ref(hid_t id);
H5_DLL int H5I_dec_app_ref_always_close(hid_t id);
H5_DLL int H5I_inc_type_ref(H5I_type_t type);
H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type);
H5_DLL int H5I_get_type_ref(H5I_type_t type);

View File

@ -1762,7 +1762,7 @@ H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED
done:
/* Close the location given to the user callback if it was created */
if(grp_id >= 0) {
if(H5I_dec_ref(grp_id, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(grp_id) < 0)
HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback")
} /* end if */
else if(grp != NULL) {
@ -2464,7 +2464,7 @@ H5L_move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
done:
/* Close the location given to the user callback if it was created */
if(grp_id >= 0) {
if(H5I_dec_ref(grp_id, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(grp_id) < 0)
HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback")
} /* end if */
else if(grp != NULL) {

View File

@ -453,7 +453,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group,
done:
/* Release resources */
if(fapl_id > 0 && H5I_dec_ref(fapl_id, FALSE, FALSE) < 0)
if(fapl_id > 0 && H5I_dec_ref(fapl_id) < 0)
HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
if(ext_file && H5F_try_close(ext_file) < 0)
HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, FAIL, "problem closing external file")
@ -465,7 +465,7 @@ done:
if(ret_value < 0) {
/* Close object if it's open and something failed */
if(ext_obj >= 0 && H5I_dec_ref(ext_obj, FALSE, FALSE) < 0)
if(ext_obj >= 0 && H5I_dec_ref(ext_obj) < 0)
HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for external object")
} /* end if */

View File

@ -1058,7 +1058,7 @@ H5Oclose(hid_t object_id)
case H5I_DATASET:
if(H5I_object(object_id) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object")
if(H5I_dec_ref(object_id, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(object_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
break;
@ -3337,7 +3337,7 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
done:
if(obj_id > 0) {
if(H5I_dec_ref(obj_id, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(obj_id) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
} /* end if */
else if(loc_found && H5G_loc_free(&obj_loc) < 0)

View File

@ -525,7 +525,7 @@ H5O_fill_copy(const void *_src, void *_dst)
/* Set up type conversion function */
if(NULL == (tpath = H5T_path_find(src->type, dst->type, NULL, NULL, H5AC_ind_dxpl_id, FALSE)))
HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "unable to convert between src and dst data types")
HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, NULL, "unable to convert between src and dst data types")
/* If necessary, convert fill value datatypes (which copies VL components, etc.) */
if(!H5T_path_noop(tpath)) {
@ -536,33 +536,33 @@ H5O_fill_copy(const void *_src, void *_dst)
/* Wrap copies of types to convert */
dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->type, H5T_COPY_TRANSIENT), FALSE);
if(dst_id < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy/register datatype")
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy/register datatype")
src_id = H5I_register(H5I_DATATYPE, H5T_copy(src->type, H5T_COPY_ALL), FALSE);
if(src_id < 0) {
H5I_dec_ref(dst_id, FALSE, FALSE);
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy/register datatype")
H5I_dec_ref(dst_id);
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy/register datatype")
} /* end if */
/* Allocate a background buffer */
bkg_size = MAX(H5T_get_size(dst->type), H5T_get_size(src->type));
if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) {
H5I_dec_ref(src_id, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
} /* end if */
/* Convert fill value */
if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, dst->buf, bkg_buf, H5AC_ind_dxpl_id) < 0) {
H5I_dec_ref(src_id, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
if(bkg_buf)
bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, NULL, "datatype conversion failed")
HGOTO_ERROR(H5E_OHDR, H5E_CANTCONVERT, NULL, "datatype conversion failed")
} /* end if */
/* Release the background buffer */
H5I_dec_ref(src_id, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
if(bkg_buf)
bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
} /* end if */
@ -695,20 +695,20 @@ H5O_fill_reset_dyn(H5O_fill_t *fill)
/* Copy the fill value datatype and get an ID for it */
if(NULL == (fill_type = H5T_copy(fill->type, H5T_COPY_TRANSIENT)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy fill value datatype")
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy fill value datatype")
if((fill_type_id = H5I_register(H5I_DATATYPE, fill_type, FALSE)) < 0) {
H5T_close(fill_type);
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register fill value datatype")
HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register fill value datatype")
} /* end if */
/* Create a scalar dataspace for the fill value element */
if(NULL == (fill_space = H5S_create(H5S_SCALAR)))
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create scalar dataspace")
HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create scalar dataspace")
/* Reclaim any variable length components of the fill value */
if(H5D_vlen_reclaim(fill_type_id, fill_space, H5P_DATASET_XFER_DEFAULT, fill->buf) < 0) {
H5S_close(fill_space);
HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length fill value data")
HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "unable to reclaim variable-length fill value data")
} /* end if */
/* Release the scalar fill value dataspace */
@ -725,8 +725,9 @@ H5O_fill_reset_dyn(H5O_fill_t *fill)
} /* end if */
done:
if(fill_type_id > 0)
H5I_dec_ref(fill_type_id, FALSE, FALSE);
if(fill_type_id > 0 && H5I_dec_ref(fill_type_id) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_fill_reset_dyn() */
@ -934,13 +935,13 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed, hid_
* Can we convert between source and destination data types?
*/
if(NULL == (tpath = H5T_path_find(fill->type, dset_type, NULL, NULL, dxpl_id, FALSE)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes")
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes")
/* Don't bother doing anything if there will be no actual conversion */
if(!H5T_path_noop(tpath)) {
if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill->type, H5T_COPY_ALL), FALSE)) < 0 ||
(dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dset_type, H5T_COPY_ALL), FALSE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register data type")
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy/register data type")
/*
* Datatype conversions are always done in place, so we need a buffer
@ -961,7 +962,7 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed, hid_
/* Do the conversion */
if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "datatype conversion failed")
/* Update the fill message */
if(buf != fill->buf) {
@ -978,10 +979,10 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed, hid_
} /* end if */
done:
if(src_id >= 0)
H5I_dec_ref(src_id, FALSE, FALSE);
if(dst_id >= 0)
H5I_dec_ref(dst_id, FALSE, FALSE);
if(src_id >= 0 && H5I_dec_ref(src_id) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID")
if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID")
if(buf != fill->buf)
H5MM_xfree(buf);
if(bkg)

View File

@ -629,7 +629,7 @@ H5O_link_delete(H5F_t *f, hid_t dxpl_id, H5O_t UNUSED *open_oh, void *_mesg)
/* Get the link class for this type of link. */
if(NULL == (link_class = H5L_find_class(lnk->type)))
HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "link class not registered")
HGOTO_ERROR(H5E_OHDR, H5E_NOTREGISTERED, FAIL, "link class not registered")
/* Check for delete callback */
if(link_class->del_func) {
@ -641,12 +641,12 @@ H5O_link_delete(H5F_t *f, hid_t dxpl_id, H5O_t UNUSED *open_oh, void *_mesg)
/* Call user-defined link's 'delete' callback */
if((link_class->del_func)(lnk->name, file_id, lnk->u.ud.udata, lnk->u.ud.size) < 0) {
H5I_dec_ref(file_id, FALSE, FALSE);
H5I_dec_ref(file_id);
HGOTO_ERROR(H5E_OHDR, H5E_CALLBACK, FAIL, "link deletion callback returned failure")
} /* end if */
/* Release the file ID */
if(H5I_dec_ref(file_id, FALSE, FALSE) < 0)
if(H5I_dec_ref(file_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file")
} /* end if */
} /* end if */

View File

@ -1379,21 +1379,21 @@ done:
herr_t
H5Pclose(hid_t plist_id)
{
herr_t ret_value=SUCCEED; /* return value */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(H5Pclose, FAIL);
H5TRACE1("e", "i", plist_id);
if(plist_id==H5P_DEFAULT)
HGOTO_DONE(SUCCEED);
/* Allow default property lists to pass through without throwing an error */
if(H5P_DEFAULT != plist_id) {
/* Check arguments. */
if(H5I_GENPROP_LST != H5I_get_type(plist_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
/* Check arguments. */
if(H5I_GENPROP_LST != H5I_get_type(plist_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
/* Close the property list */
if(H5I_dec_ref(plist_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close");
/* Close the property list */
if(H5I_dec_app_ref(plist_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close")
} /* end if */
done:
FUNC_LEAVE_API(ret_value);
@ -1522,13 +1522,13 @@ H5Pclose_class(hid_t cls_id)
/* Check arguments */
if(H5I_GENPROP_CLS != H5I_get_type(cls_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class");
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class")
/* Close the property list class */
if(H5I_dec_ref(cls_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close");
if(H5I_dec_app_ref(cls_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close")
done:
FUNC_LEAVE_API(ret_value);
FUNC_LEAVE_API(ret_value)
} /* H5Pclose_class() */

View File

@ -1543,9 +1543,9 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/,
* Can we convert between the source and destination datatypes?
*/
if(NULL == (tpath = H5T_path_find(fill.type, type, NULL, NULL, dxpl_id, FALSE)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes")
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes")
if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill.type, H5T_COPY_TRANSIENT), FALSE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype")
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy/register datatype")
/*
* Data type conversions are always done in place, so we need a buffer
@ -1555,11 +1555,11 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/,
if(H5T_get_size(type) >= H5T_get_size(fill.type)) {
buf = value;
if(H5T_path_bkg(tpath) && NULL == (bkg = H5MM_malloc(H5T_get_size(type))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion")
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion")
} /* end if */
else {
if(NULL == (buf = H5MM_malloc(H5T_get_size(fill.type))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion")
HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion")
if(H5T_path_bkg(tpath))
bkg = value;
} /* end else */
@ -1567,9 +1567,9 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/,
/* Do the conversion */
if((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(type, H5T_COPY_TRANSIENT), FALSE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype")
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy/register datatype")
if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed")
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "datatype conversion failed")
if(buf != value)
HDmemcpy(value, buf, H5T_get_size(type));
@ -1578,10 +1578,10 @@ done:
H5MM_xfree(buf);
if(bkg != value)
H5MM_xfree(bkg);
if(src_id >= 0)
H5I_dec_ref(src_id, FALSE, FALSE);
if(dst_id >= 0)
H5I_dec_ref(dst_id, FALSE, FALSE);
if(src_id >= 0 && H5I_dec_ref(src_id) < 0)
HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID")
if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0)
HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P_get_fill_value() */

View File

@ -208,8 +208,8 @@ H5P_lacc_elink_fapl_del(hid_t UNUSED prop_id, const char UNUSED *name, size_t UN
l_fapl_id = (*(const hid_t *)value);
if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE, FALSE) < 0))
HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0))
HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
done:
FUNC_LEAVE_NOAPI(ret_value)
@ -282,8 +282,8 @@ H5P_lacc_elink_fapl_close(const char UNUSED *name, size_t UNUSED size, void *val
HDassert(value);
l_fapl_id = (*(const hid_t *)value);
if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE, FALSE) < 0))
HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0))
HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
done:
FUNC_LEAVE_NOAPI(ret_value)
@ -589,15 +589,15 @@ H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl")
/* Close the current file access property list if set */
if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE, FALSE) < 0))
HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0))
HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
if(NULL == (fapl_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access property list");
/* Make a copy of the property list for FAPL_ID */
if((new_fapl_id = H5P_copy_plist(fapl_plist, FALSE)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file access properties")
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file access properties")
/* Set the file access property list for the link access */
if(H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &new_fapl_id) < 0)

View File

@ -891,9 +891,8 @@ H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_ty
done:
/* Close file ID used for search */
if(file_id > 0)
if(H5I_dec_ref(file_id, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEFILE, FAIL, "can't determine name")
if(file_id > 0 && H5I_dec_ref(file_id) < 0)
HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5R_get_name() */

View File

@ -355,7 +355,7 @@ done:
herr_t
H5Sclose(hid_t space_id)
{
herr_t ret_value=SUCCEED; /* Return value */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Sclose, FAIL)
H5TRACE1("e", "i", space_id);
@ -365,12 +365,12 @@ H5Sclose(hid_t space_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
/* When the reference count reaches zero the resources are freed */
if (H5I_dec_ref(space_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id")
if(H5I_dec_app_ref(space_id) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing id")
done:
FUNC_LEAVE_API(ret_value)
}
} /* end H5Sclose() */
/*-------------------------------------------------------------------------

View File

@ -1719,11 +1719,11 @@ H5Tclose(hid_t type_id)
/* Check args */
if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
if(H5T_STATE_IMMUTABLE==dt->shared->state)
if(H5T_STATE_IMMUTABLE == dt->shared->state)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype")
/* When the reference count reaches zero the resources are freed */
if(H5I_dec_ref(type_id, TRUE, FALSE) < 0)
if(H5I_dec_app_ref(type_id) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id")
done:
@ -2341,28 +2341,28 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
old_path->dst->shared->type!=dst->shared->type) {
continue;
}
if ((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL), FALSE))<0 ||
(tmp_did = H5I_register(H5I_DATATYPE, H5T_copy(old_path->dst, H5T_COPY_ALL), FALSE))<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data types for conv query");
if((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL), FALSE)) < 0 ||
(tmp_did = H5I_register(H5I_DATATYPE, H5T_copy(old_path->dst, H5T_COPY_ALL), FALSE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data types for conv query")
HDmemset(&cdata, 0, sizeof cdata);
cdata.command = H5T_CONV_INIT;
if ((func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0,
NULL, NULL, dxpl_id)<0) {
H5I_dec_ref(tmp_sid, FALSE, FALSE);
H5I_dec_ref(tmp_did, FALSE, FALSE);
if((func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0,
NULL, NULL, dxpl_id) < 0) {
H5I_dec_ref(tmp_sid);
H5I_dec_ref(tmp_did);
tmp_sid = tmp_did = -1;
H5E_clear_stack(NULL);
continue;
} /* end if */
/* Create a new conversion path */
if (NULL==(new_path=H5FL_CALLOC(H5T_path_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
if(NULL == (new_path = H5FL_CALLOC(H5T_path_t)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
HDstrncpy(new_path->name, name, (size_t)H5T_NAMELEN);
new_path->name[H5T_NAMELEN-1] = '\0';
if (NULL==(new_path->src=H5T_copy(old_path->src, H5T_COPY_ALL)) ||
NULL==(new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data types");
if(NULL == (new_path->src = H5T_copy(old_path->src, H5T_COPY_ALL)) ||
NULL == (new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data types")
new_path->func = func;
new_path->is_hard = FALSE;
new_path->cdata = cdata;
@ -2389,8 +2389,8 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
old_path = H5FL_FREE(H5T_path_t, old_path);
/* Release temporary atoms */
H5I_dec_ref(tmp_sid, FALSE, FALSE);
H5I_dec_ref(tmp_did, FALSE, FALSE);
H5I_dec_ref(tmp_sid);
H5I_dec_ref(tmp_did);
tmp_sid = tmp_did = -1;
/* We don't care about any failures during the freeing process */
@ -2408,9 +2408,9 @@ done:
new_path = H5FL_FREE(H5T_path_t, new_path);
} /* end if */
if(tmp_sid >= 0)
H5I_dec_ref(tmp_sid, FALSE, FALSE);
H5I_dec_ref(tmp_sid);
if(tmp_did >= 0)
H5I_dec_ref(tmp_did, FALSE, FALSE);
H5I_dec_ref(tmp_did);
} /* end if */
FUNC_LEAVE_NOAPI(ret_value);
@ -4409,9 +4409,9 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
if((func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function")
if(src_id >= 0)
H5I_dec_ref(src_id, FALSE, FALSE);
H5I_dec_ref(src_id);
if(dst_id >= 0)
H5I_dec_ref(dst_id, FALSE, FALSE);
H5I_dec_ref(dst_id);
src_id = dst_id = -1;
path->func = func;
path->is_hard = TRUE;
@ -4441,8 +4441,8 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
path->func = H5T_g.soft[i].func;
path->is_hard = FALSE;
} /* end else */
H5I_dec_ref(src_id, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
H5I_dec_ref(src_id);
H5I_dec_ref(dst_id);
src_id = dst_id = -1;
} /* end for */
if(!path->func)
@ -4529,9 +4529,9 @@ done:
path = H5FL_FREE(H5T_path_t, path);
} /* end if */
if(src_id >= 0)
H5I_dec_ref(src_id, FALSE, FALSE);
H5I_dec_ref(src_id);
if(dst_id >= 0)
H5I_dec_ref(dst_id, FALSE, FALSE);
H5I_dec_ref(dst_id);
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5T_path_find() */

View File

@ -664,7 +664,8 @@ H5Tget_create_plist(hid_t dtype_id)
done:
if(ret_value < 0)
if(new_tcpl_id > 0)
(void)H5I_dec_ref(new_tcpl_id, TRUE, FALSE);
if(H5I_dec_app_ref(new_tcpl_id) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to close temporary object")
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_create_plist() */

View File

@ -1783,9 +1783,9 @@ H5T_conv_struct_free(H5T_conv_struct_t *priv)
for (i=0; i<priv->src_nmembs; i++)
if (src2dst[i] >= 0) {
status = H5I_dec_ref(src_memb_id[i], FALSE, FALSE);
status = H5I_dec_ref(src_memb_id[i]);
HDassert(status >= 0);
status = H5I_dec_ref(dst_memb_id[src2dst[i]], FALSE, FALSE);
status = H5I_dec_ref(dst_memb_id[src2dst[i]]);
HDassert(status >= 0);
}
@ -3173,9 +3173,9 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
/* Release the temporary datatype IDs used */
if(tsrc_id >= 0)
H5I_dec_ref(tsrc_id, FALSE, FALSE);
H5I_dec_ref(tsrc_id);
if(tdst_id >= 0)
H5I_dec_ref(tdst_id, FALSE, FALSE);
H5I_dec_ref(tdst_id);
break;
default: /* Some other command we don't know about yet.*/
@ -3325,9 +3325,9 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
/* Release the temporary datatype IDs used */
if(tsrc_id >= 0)
H5I_dec_ref(tsrc_id, FALSE, FALSE);
H5I_dec_ref(tsrc_id);
if(tdst_id >= 0)
H5I_dec_ref(tdst_id, FALSE, FALSE);
H5I_dec_ref(tdst_id);
break;
default: /* Some other command we don't know about yet.*/

View File

@ -637,7 +637,7 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type
} /* end if */
done:
if(space_id > 0 && H5I_dec_ref(space_id, FALSE, FALSE) < 0)
if(space_id > 0 && H5I_dec_ref(space_id) < 0)
HDONE_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace")
FUNC_LEAVE_NOAPI(ret_value)

View File

@ -361,7 +361,7 @@ static int test_is_valid(void)
CHECK(ret, FAIL, "H5I_inc_ref");
if (ret < 0)
goto out;
ret = H5I_dec_ref(dtype, TRUE, FALSE);
ret = H5I_dec_app_ref(dtype);
CHECK(ret, FAIL, "H5I_dec_ref");
if (ret < 0)
goto out;
@ -377,7 +377,7 @@ static int test_is_valid(void)
CHECK(nmembs1, FAIL, "H5I_nmembers");
if (nmembs1 < 0)
goto out;
ret = H5I_dec_ref(dtype, FALSE, FALSE);
ret = H5I_dec_ref(dtype);
CHECK(ret, FAIL, "H5I_dec_ref");
if (ret < 0)
goto out;