/* Create the new named datatype and link it to its parent group */
if(H5L_link_object(loc, name, &ocrt_info, lcpl_id, tapl_id, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create and link to named datatype")
HDassert(ocrt_info.new_obj);
/* If the datatype was committed but something failed after that, we need
* to return it to the state it was in before it was committed.
if(ret_value < 0 && ocrt_info.new_obj) {
if(ret_value < 0 && (NULL != ocrt_info.new_obj)) {
if(dt->shared->state == H5T_STATE_OPEN && dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) {
/* Remove the datatype from the list of opened objects in the file */
if(H5FO_top_decr(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
if(H5FO_delete(dt->sh_loc.file, dxpl_id, dt->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects")
/* Close the datatype object */
if(H5O_close(&(dt->oloc)) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header")