summaryrefslogtreecommitdiffstats
path: root/src/H5T.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5T.c')
-rw-r--r--src/H5T.c63
1 files changed, 59 insertions, 4 deletions
diff --git a/src/H5T.c b/src/H5T.c
index 59f0224..33a75c9 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -1479,6 +1479,8 @@ done:
if (copied_dtype)
(void)H5T_close_real(dt);
else {
+ if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close owned VOL object")
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
dt = H5FL_FREE(H5T_t, dt);
} /* end else */
@@ -3447,6 +3449,8 @@ H5T__create(H5T_class_t type, size_t size)
done:
if (NULL == ret_value) {
if (dt) {
+ if (dt->shared->owned_vol_obj && H5VL_free_object(dt->shared->owned_vol_obj) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object")
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
dt = H5FL_FREE(H5T_t, dt);
}
@@ -3489,9 +3493,12 @@ H5T__initiate_copy(const H5T_t *old_dt)
/* Copy shared information */
*(new_dt->shared) = *(old_dt->shared);
- /* Reset VOL fields */
+ /* Increment ref count on owned VOL object */
+ if (new_dt->shared->owned_vol_obj)
+ (void)H5VL_object_inc_rc(new_dt->shared->owned_vol_obj);
+
+ /* Reset vol_obj field */
new_dt->vol_obj = NULL;
- new_dt->shared->owned_vol_obj = NULL;
/* Set return value */
ret_value = new_dt;
@@ -3499,8 +3506,11 @@ H5T__initiate_copy(const H5T_t *old_dt)
done:
if (ret_value == NULL)
if (new_dt) {
- if (new_dt->shared)
+ if (new_dt->shared) {
+ if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object")
new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared);
+ } /* end if */
new_dt = H5FL_FREE(H5T_t, new_dt);
} /* end if */
@@ -3829,6 +3839,8 @@ done:
if (ret_value == NULL)
if (new_dt) {
HDassert(new_dt->shared);
+ if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object")
new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared);
new_dt = H5FL_FREE(H5T_t, new_dt);
} /* end if */
@@ -3896,6 +3908,8 @@ H5T_copy_reopen(H5T_t *old_dt)
/* The object is already open. Free the H5T_shared_t struct
* we had been using and use the one that already exists.
* Not terribly efficient. */
+ if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object")
new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared);
new_dt->shared = reopened_fo;
@@ -3932,6 +3946,8 @@ done:
if (ret_value == NULL)
if (new_dt) {
HDassert(new_dt->shared);
+ if (new_dt->shared->owned_vol_obj && H5VL_free_object(new_dt->shared->owned_vol_obj) < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close owned VOL object")
new_dt->shared = H5FL_FREE(H5T_shared_t, new_dt->shared);
new_dt = H5FL_FREE(H5T_t, new_dt);
} /* end if */
@@ -4026,8 +4042,10 @@ H5T__alloc(void)
done:
if (ret_value == NULL)
if (dt) {
- if (dt->shared)
+ if (dt->shared) {
+ HDassert(!dt->shared->owned_vol_obj);
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
+ } /* end if */
dt = H5FL_FREE(H5T_t, dt);
} /* end if */
@@ -4148,6 +4166,7 @@ H5T_close_real(H5T_t *dt)
if (H5T__free(dt) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype");
+ HDassert(!dt->shared->owned_vol_obj);
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
} /* end if */
else
@@ -4282,6 +4301,7 @@ H5T__set_size(H5T_t *dt, size_t size)
/* Check args */
HDassert(dt);
+ HDassert(dt->shared);
HDassert(size != 0);
HDassert(H5T_REFERENCE != dt->shared->type);
HDassert(!(H5T_ENUM == dt->shared->type && 0 == dt->shared->u.enumer.nmembs));
@@ -4469,11 +4489,38 @@ H5T_get_size(const H5T_t *dt)
/* check args */
HDassert(dt);
+ HDassert(dt->shared);
FUNC_LEAVE_NOAPI(dt->shared->size)
} /* end H5T_get_size() */
/*-------------------------------------------------------------------------
+ * Function: H5T_get_force_conv
+ *
+ * Purpose: Determines if the type has forced conversion. This will be
+ * true if and only if the type keeps a pointer to a file VOL
+ * object internally.
+ *
+ * Return: TRUE/FALSE (never fails)
+ *
+ * Programmer: Neil Fortner
+ * Thursday, January 21, 2021
+ *-------------------------------------------------------------------------
+ */
+hbool_t
+H5T_get_force_conv(const H5T_t *dt)
+{
+ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ /* check args */
+ HDassert(dt);
+ HDassert(dt->shared);
+
+ FUNC_LEAVE_NOAPI(dt->shared->force_conv)
+} /* end H5T_get_force_conv() */
+
+/*-------------------------------------------------------------------------
* Function: H5T_cmp
*
* Purpose: Compares two data types.
@@ -4509,6 +4556,9 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
if (dt1 == dt2)
HGOTO_DONE(0);
+ HDassert(dt1->shared);
+ HDassert(dt2->shared);
+
/* compare */
if (dt1->shared->type < dt2->shared->type)
HGOTO_DONE(-1);
@@ -4914,6 +4964,10 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset)
HGOTO_DONE(-1);
if (dt1->shared->u.atomic.u.r.loc > dt2->shared->u.atomic.u.r.loc)
HGOTO_DONE(1);
+ if (dt1->shared->u.atomic.u.r.file < dt2->shared->u.atomic.u.r.file)
+ HGOTO_DONE(-1);
+ if (dt1->shared->u.atomic.u.r.file > dt2->shared->u.atomic.u.r.file)
+ HGOTO_DONE(1);
break;
case H5T_NO_CLASS:
@@ -6295,6 +6349,7 @@ H5T_own_vol_obj(H5T_t *dt, H5VL_object_t *vol_obj)
/* Take ownership */
dt->shared->owned_vol_obj = vol_obj;
+ (void)H5VL_object_inc_rc(vol_obj);
done:
FUNC_LEAVE_NOAPI(ret_value)