diff options
Diffstat (limited to 'src/H5Tcompound.c')
-rw-r--r-- | src/H5Tcompound.c | 83 |
1 files changed, 61 insertions, 22 deletions
diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c index d4f1008..711fdfc 100644 --- a/src/H5Tcompound.c +++ b/src/H5Tcompound.c @@ -51,8 +51,9 @@ /********************/ /* Local Prototypes */ /********************/ -static herr_t H5T_pack(const H5T_t *dt); -static htri_t H5T_is_packed(const H5T_t *dt); +static herr_t H5T__pack(const H5T_t *dt); +static htri_t H5T__is_packed(const H5T_t *dt); +static H5T_t *H5T__reopen_member_type(const H5T_t *dt, unsigned membno); /*********************/ @@ -226,7 +227,7 @@ H5Tget_member_type(hid_t type_id, unsigned membno) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid member number") /* Retrieve the datatype for the member */ - if(NULL == (memb_dt = H5T_get_member_type(dt, membno, H5T_COPY_REOPEN))) + if(NULL == (memb_dt = H5T__reopen_member_type(dt, membno))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to retrieve member type") /* Get an ID for the datatype */ @@ -245,8 +246,7 @@ done: /*------------------------------------------------------------------------- * Function: H5T_get_member_type * - * Purpose: Private function for H5Tget_member_type. Returns the data - * type of the specified member. + * Purpose: Returns a copy of the datatype of the specified memeber. * * Return: Success: A copy of the member datatype; * modifying the returned datatype does not @@ -260,23 +260,62 @@ done: *------------------------------------------------------------------------- */ H5T_t * -H5T_get_member_type(const H5T_t *dt, unsigned membno, H5T_copy_t method) +H5T_get_member_type(const H5T_t *dt, unsigned membno) { H5T_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) + /* Sanity checks */ HDassert(dt); HDassert(membno < dt->shared->u.compnd.nmembs); - /* Copy datatype into an atom */ - if(NULL == (ret_value = H5T_copy(dt->shared->u.compnd.memb[membno].type, method))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy member datatype") + /* Copy datatype */ + if(NULL == (ret_value = H5T_copy(dt->shared->u.compnd.memb[membno].type, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to copy member datatype") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_member_type() */ + +/*------------------------------------------------------------------------- + * Function: H5T__reopen_member_type + * + * Purpose: Private function for H5Tget_member_type. Returns a re-opened + * copy of the data type of the specified member. + * + * Return: Success: A copy of the member datatype; + * modifying the returned datatype does not + * modify the member type. + * + * Failure: NULL + * + * Programmer: David Young + * January 18, 2020 + * + *------------------------------------------------------------------------- + */ +static H5T_t * +H5T__reopen_member_type(const H5T_t *dt, unsigned membno) +{ + H5T_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(dt); + HDassert(membno < dt->shared->u.compnd.nmembs); + + /* Copy datatype, possibly re-opening it */ + if(NULL == (ret_value = H5T_copy_reopen(dt->shared->u.compnd.memb[membno].type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "unable to reopen member datatype") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T__reopen_member_type() */ + + /*------------------------------------------------------------------------- * Function: H5T__get_member_size @@ -387,7 +426,7 @@ H5Tpack(hid_t type_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype") /* Pack */ - if(H5T_pack(dt) < 0) + if(H5T__pack(dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound datatype") done: @@ -493,7 +532,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5T_pack + * Function: H5T__pack * * Purpose: Recursively packs a compound datatype by removing padding * bytes. This is done in place (that is, destructively). @@ -506,17 +545,17 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5T_pack(const H5T_t *dt) +H5T__pack(const H5T_t *dt) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(dt); if(H5T_detect_class(dt, H5T_COMPOUND, FALSE) > 0) { /* If datatype has been packed, skip packing it and indicate success */ - if(TRUE == H5T_is_packed(dt)) + if(TRUE == H5T__is_packed(dt)) HGOTO_DONE(SUCCEED) /* Check for packing unmodifiable datatype */ @@ -524,7 +563,7 @@ H5T_pack(const H5T_t *dt) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is read-only") if(dt->shared->parent) { - if (H5T_pack(dt->shared->parent) < 0) + if (H5T__pack(dt->shared->parent) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack parent of datatype") /* Adjust size of datatype appropriately */ @@ -539,7 +578,7 @@ H5T_pack(const H5T_t *dt) /* Recursively pack the members */ for(i = 0; i < dt->shared->u.compnd.nmembs; i++) { - if(H5T_pack(dt->shared->u.compnd.memb[i].type) < 0) + if(H5T__pack(dt->shared->u.compnd.memb[i].type) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack part of a compound datatype") /* Update the member size */ @@ -564,11 +603,11 @@ H5T_pack(const H5T_t *dt) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_pack() */ +} /* end H5T__pack() */ /*------------------------------------------------------------------------- - * Function: H5T_is_packed + * Function: H5T__is_packed * * Purpose: Checks whether a datatype which is compound (or has compound * components) is packed. @@ -583,11 +622,11 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5T_is_packed(const H5T_t *dt) +H5T__is_packed(const H5T_t *dt) { htri_t ret_value = TRUE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(dt); @@ -601,7 +640,7 @@ H5T_is_packed(const H5T_t *dt) } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_is_packed() */ +} /* end H5T__is_packed() */ /*------------------------------------------------------------------------- @@ -638,7 +677,7 @@ H5T__update_packed(const H5T_t *dt) /* Now check if all members are packed */ for(i = 0; i < dt->shared->u.compnd.nmembs; i++) - if(!H5T_is_packed(dt->shared->u.compnd.memb[i].type)) { + if(!H5T__is_packed(dt->shared->u.compnd.memb[i].type)) { dt->shared->u.compnd.packed = FALSE; break; } /* end if */ |