H5A__free() was renamed to H5A__shared_free() and now requires

attr->shared to not be NULL.
This commit is contained in:
Dana Robinson 2019-06-11 14:14:13 -07:00
parent 3fd4f270fd
commit 0cf52525d5
4 changed files with 20 additions and 18 deletions

View File

@ -327,8 +327,9 @@ H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr)
H5A_t *old_attr = *user_attr;
/* Free any dynamically allocated items */
if(H5A__free(old_attr) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info")
if(old_attr->shared)
if(H5A__shared_free(old_attr) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info")
old_attr = H5FL_FREE(H5A_t, old_attr);
} /* end if */

View File

@ -1092,29 +1092,29 @@ done:
/*-------------------------------------------------------------------------
* Function: H5A__free
* Function: H5A__shared_free
*
* Purpose: Frees all memory associated with an attribute, but does not
* free the H5A_t structure (which should be done in H5T_close).
* Purpose: Cleans up the shared attribute data. This will free
* the attribute's shared structure as well.
*
* attr and attr->shared must not be NULL
*
* Return: SUCCEED/FAIL
*
* Programmer: Quincey Koziol
* Monday, November 15, 2004
* Programmer: Quincey Koziol
* Monday, November 15, 2004
*
*-------------------------------------------------------------------------
*/
herr_t
H5A__free(H5A_t *attr)
H5A__shared_free(H5A_t *attr)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
HDassert(attr);
if(!attr->shared)
HGOTO_DONE(SUCCEED)
HDassert(attr->shared);
/* Free dynamically allocated items.
* When possible, keep trying to shut things down (via HDONE_ERROR).
@ -1139,9 +1139,8 @@ H5A__free(H5A_t *attr)
/* Destroy shared attribute struct */
attr->shared = H5FL_FREE(H5A_shared_t, attr->shared);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5A__free() */
} /* end H5A__shared_free() */
/*-------------------------------------------------------------------------
@ -1205,8 +1204,9 @@ H5A__close(H5A_t *attr)
/* Reference count can be 0. It only happens when H5A__create fails. */
if(attr->shared->nrefs <= 1) {
/* Free dynamically allocated items */
if(H5A__free(attr) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info")
if(attr->shared)
if(H5A__shared_free(attr) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info")
} /* end if */
else {
/* There are other references to the shared part of the attribute.

View File

@ -196,7 +196,7 @@ H5_DLL H5A_t *H5A__copy(H5A_t *new_attr, const H5A_t *old_attr);
H5_DLL hid_t H5A__get_type(H5A_t *attr);
H5_DLL herr_t H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo);
H5_DLL hid_t H5A__get_create_plist(H5A_t* attr);
H5_DLL herr_t H5A__free(H5A_t *attr);
H5_DLL herr_t H5A__shared_free(H5A_t *attr);
H5_DLL herr_t H5A__close(H5A_t *attr);
H5_DLL herr_t H5A__close_cb(H5VL_object_t *attr_vol_obj);
H5_DLL htri_t H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo);

View File

@ -254,8 +254,9 @@ done:
if(NULL == ret_value)
if(attr) {
/* Free any dynamically allocated items */
if(H5A__free(attr) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info")
if(attr->shared)
if(H5A__shared_free(attr) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't release attribute info")
attr = H5FL_FREE(H5A_t, attr);
} /* end if */