diff options
Diffstat (limited to 'src/H5Oattr.c')
-rw-r--r-- | src/H5Oattr.c | 70 |
1 files changed, 33 insertions, 37 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 59a684e..bc2b81f 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -650,8 +650,6 @@ herr_t H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link) { const H5A_t *attr = (const H5A_t *) _mesg; - htri_t tri_ret; - H5O_shared_t sh_mesg; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_attr_delete) @@ -660,33 +658,37 @@ H5O_attr_delete(H5F_t *f, hid_t dxpl_id, const void *_mesg, hbool_t adj_link) HDassert(f); HDassert(attr); - /* Remove both the datatype and dataspace from the SOHM heap if they're - * shared there. - */ - if((tri_ret = H5O_msg_is_shared(H5O_DTYPE_ID, attr->dt)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't tell if datatype is shared") - if(tri_ret > 0) - { - if(H5O_msg_get_share(H5O_DTYPE_ID, attr->dt, &sh_mesg) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message from datatype") - if(H5SM_try_delete(f, H5AC_dxpl_id, H5O_DTYPE_ID, &sh_mesg) < 0) - HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "can't remove datatype from SOHM heap") - } /* end if */ - - if((tri_ret = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't tell if dataspace is shared") - if(tri_ret > 0) - { - if(H5O_msg_get_share(H5O_SDSPACE_ID, attr->ds, &sh_mesg) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message from dataspace") - if(H5SM_try_delete(f, H5AC_dxpl_id, H5O_SDSPACE_ID, &sh_mesg) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_SOHM, FAIL, "can't remove dataspace from SOHM heap") - } /* end if */ - - /* Check whether datatype is shared */ - if(H5T_committed(attr->dt)) { - /* Decrement the reference count on the shared datatype, if requested */ - if(adj_link) + /* Check if we are adjusting link count on components in the file */ + if(adj_link) { + htri_t tri_ret; + H5O_shared_t sh_mesg; + + /* Remove both the datatype and dataspace from the SOHM heap if they're + * shared there. + */ + if((tri_ret = H5O_msg_is_shared(H5O_DTYPE_ID, attr->dt)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't tell if datatype is shared") + if(tri_ret > 0) + { + if(H5O_msg_get_share(H5O_DTYPE_ID, attr->dt, &sh_mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message from datatype") + if(H5SM_try_delete(f, H5AC_dxpl_id, H5O_DTYPE_ID, &sh_mesg) < 0) + HGOTO_ERROR(H5E_SOHM, H5E_CANTREMOVE, FAIL, "can't remove datatype from SOHM heap") + } /* end if */ + + if((tri_ret = H5O_msg_is_shared(H5O_SDSPACE_ID, attr->ds)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't tell if dataspace is shared") + if(tri_ret > 0) + { + if(H5O_msg_get_share(H5O_SDSPACE_ID, attr->ds, &sh_mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't get shared message from dataspace") + if(H5SM_try_delete(f, H5AC_dxpl_id, H5O_SDSPACE_ID, &sh_mesg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_SOHM, FAIL, "can't remove dataspace from SOHM heap") + } /* end if */ + + /* Check whether datatype is shared */ + if(H5T_committed(attr->dt)) + /* Decrement the reference count on the shared datatype */ if(H5T_link(attr->dt, -1, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count") } /* end if */ @@ -1117,7 +1119,6 @@ static htri_t H5O_attr_is_shared(const void *_mesg) { const H5A_t *mesg = (const H5A_t *)_mesg; - htri_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_attr_is_shared) @@ -1127,13 +1128,8 @@ H5O_attr_is_shared(const void *_mesg) * library read a "committed attribute" if we ever create one in * the future. */ - if(mesg->sh_loc.flags & (H5O_COMMITTED_FLAG | H5O_SHARED_IN_HEAP_FLAG)) - ret_value = TRUE; - else - ret_value = FALSE; - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_attr_is_shared */ + FUNC_LEAVE_NOAPI(H5O_IS_SHARED(mesg->sh_loc.flags)) +} /* end H5O_attr_is_shared() */ /*-------------------------------------------------------------------------- |