summaryrefslogtreecommitdiffstats
path: root/src/H5Tcompound.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-03-15 21:54:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-03-15 21:54:30 (GMT)
commit4a17aff4085ad6ee265b95730aca3f493056dec8 (patch)
tree8bfb665c6d95a2e3520fa1bb0ff54d95aff3923f /src/H5Tcompound.c
parent853ae26333592faf69cd8c454ef92ffea8549df5 (diff)
downloadhdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.zip
hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.gz
hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.bz2
Add API context interface and use it throughout the library.
Diffstat (limited to 'src/H5Tcompound.c')
-rw-r--r--src/H5Tcompound.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/H5Tcompound.c b/src/H5Tcompound.c
index 169c146..3daf365 100644
--- a/src/H5Tcompound.c
+++ b/src/H5Tcompound.c
@@ -27,6 +27,7 @@
/* Headers */
/***********/
#include "H5private.h" /*generic functions */
+#include "H5CXprivate.h" /*API Contexts */
#include "H5Eprivate.h" /*error handling */
#include "H5Iprivate.h" /*ID functions */
#include "H5MMprivate.h" /*memory management */
@@ -213,25 +214,37 @@ H5Tget_member_type(hid_t type_id, unsigned membno)
{
H5T_t *dt; /* Datatype to query */
H5T_t *memb_dt = NULL; /* Member datatype */
+hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */
hid_t ret_value; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE2("i", "iIu", type_id, membno);
/* Check args */
if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)) || H5T_COMPOUND != dt->shared->type)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound datatype")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a compound datatype")
if(membno >= dt->shared->u.compnd.nmembs)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid member number")
+
+/* Set API context */
+if(H5CX_push() < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, H5I_INVALID_HID, "can't set API context")
+api_ctx_pushed = TRUE;
+
+ /* Retrieve the datatype for the member */
if(NULL == (memb_dt = H5T_get_member_type(dt, membno, H5T_COPY_REOPEN)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to retrieve member type")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to retrieve member type")
+
+ /* Get an ID for the datatype */
if((ret_value = H5I_register(H5I_DATATYPE, memb_dt, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable register datatype atom")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable register datatype atom")
done:
if(ret_value < 0)
if(memb_dt && H5T_close(memb_dt) < 0)
- HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "can't close datatype")
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, H5I_INVALID_HID, "can't close datatype")
+if(api_ctx_pushed && H5CX_pop() < 0)
+ HDONE_ERROR(H5E_DATATYPE, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context")
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_member_type() */