diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2018-03-15 21:54:30 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2018-03-15 21:54:30 (GMT) |
commit | 4a17aff4085ad6ee265b95730aca3f493056dec8 (patch) | |
tree | 8bfb665c6d95a2e3520fa1bb0ff54d95aff3923f /src/H5A.c | |
parent | 853ae26333592faf69cd8c454ef92ffea8549df5 (diff) | |
download | hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.zip hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.gz hdf5-4a17aff4085ad6ee265b95730aca3f493056dec8.tar.bz2 |
Add API context interface and use it throughout the library.
Diffstat (limited to 'src/H5A.c')
-rw-r--r-- | src/H5A.c | 467 |
1 files changed, 254 insertions, 213 deletions
@@ -24,6 +24,7 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Apkg.h" /* Attributes */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ @@ -91,7 +92,7 @@ static const H5I_class_t H5I_ATTR_CLS[1] = {{ H5I_ATTR, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - (H5I_free_t)H5A_close /* Callback routine for closing objects of this class */ + (H5I_free_t)H5A__close_cb /* Callback routine for closing objects of this class */ }}; /* Flag indicating "top" of interface has been initialized */ @@ -250,7 +251,7 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, H5G_loc_t loc; /* Object location */ H5T_t *type; /* Datatype to use for attribute */ H5S_t *space; /* Dataspace to use for attribute */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -270,12 +271,16 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id, loc_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Go do the real work for attaching the attribute to the object */ - if(NULL == (attr = H5A_create(&loc, attr_name, type, space, acpl_id, dxpl_id))) + if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") /* Register the new attribute and get an ID for it */ @@ -284,8 +289,10 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, done: /* Cleanup on failure */ - if(ret_value < 0 && attr && H5A_close(attr) < 0) + if(ret_value < 0 && attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Acreate2() */ @@ -328,13 +335,9 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, { H5A_t *attr = NULL; /* Attribute created */ H5G_loc_t loc; /* Object location */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ H5T_t *type; /* Datatype to use for attribute */ H5S_t *space; /* Dataspace to use for attribute */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -357,33 +360,34 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id, loc_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") - - /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; + if(H5P_DEFAULT != lapl_id) { + if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + H5CX_set_lapl(lapl_id); + } /* end if */ - /* Go do the real work for attaching the attribute to the dataset */ - if(NULL == (attr = H5A_create(&obj_loc, attr_name, type, space, acpl_id, dxpl_id))) + /* Create the attribute on the object */ + if(NULL == (attr = H5A__create_by_name(&loc, obj_name, attr_name, type, space, acpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") /* Register the new attribute and get an ID for it */ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + done: - /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - if(ret_value < 0 && attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + /* Cleanup on failure */ + if(ret_value < 0 && attr && H5A__close(attr) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Acreate_by_name() */ @@ -413,7 +417,7 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute opened */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -427,17 +431,17 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") /* Read in attribute from object header */ - if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header for attribute: '%s'", attr_name) - - /* Finish initializing attribute */ - if(H5A__open_common(&loc, attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize attribute") + if(NULL == (attr = H5A__open(&loc, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to load attribute info from object header for attribute: '%s'", attr_name) /* Register the attribute and get an ID for it */ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) @@ -446,8 +450,10 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) done: /* Cleanup on failure */ if(ret_value < 0) - if(attr && H5A_close(attr) < 0) + if(attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Aopen() */ @@ -480,7 +486,7 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute opened */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -495,18 +501,23 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else + +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") + + if(H5P_DEFAULT != lapl_id) { if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + H5CX_set_lapl(lapl_id); + } /* end if */ /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, dxpl_id))) + if(NULL == (attr = H5A__open_by_name(&loc, obj_name, attr_name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Register the attribute and get an ID for it */ @@ -516,8 +527,10 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, done: /* Cleanup on failure */ if(ret_value < 0) - if(attr && H5A_close(attr) < 0) + if(attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Aopen_by_name() */ @@ -553,7 +566,7 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, { H5A_t *attr = NULL; /* Attribute opened */ H5G_loc_t loc; /* Object location */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -571,18 +584,23 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else + +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") + + if(H5P_DEFAULT != lapl_id) { if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + H5CX_set_lapl(lapl_id); + } /* end if */ /* Open the attribute in the object header */ - if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, dxpl_id))) + if(NULL == (attr = H5A__open_by_idx(&loc, obj_name, idx_type, order, n))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") /* Register the attribute and get an ID for it */ @@ -592,8 +610,10 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, done: /* Cleanup on failure */ if(ret_value < 0) - if(attr && H5A_close(attr) < 0) + if(attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Aopen_by_idx() */ @@ -620,8 +640,7 @@ H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) { H5A_t *attr; /* Attribute object for ID */ H5T_t *mem_type; /* Memory datatype */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ - hid_t aapl_id = H5P_DEFAULT; /* temp access plist */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -635,15 +654,21 @@ H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id, attr_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Set up collective metadata if appropriate */ +if(H5CX_set_loc(attr_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") /* Go write the actual data to the attribute */ - if((ret_value = H5A__write(attr, mem_type, buf, dxpl_id)) < 0) + if((ret_value = H5A__write(attr, mem_type, buf)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Awrite() */ @@ -669,8 +694,7 @@ H5Aread(hid_t attr_id, hid_t dtype_id, void *buf) { H5A_t *attr; /* Attribute object for ID */ H5T_t *mem_type; /* Memory datatype */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ - hid_t aapl_id = H5P_DEFAULT; /* temp access plist */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -684,15 +708,18 @@ H5Aread(hid_t attr_id, hid_t dtype_id, void *buf) if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id, attr_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; /* Go write the actual data to the attribute */ - if((ret_value = H5A__read(attr, mem_type, buf, dxpl_id)) < 0) + if((ret_value = H5A__read(attr, mem_type, buf)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Aread() */ @@ -752,8 +779,9 @@ done: hid_t H5Aget_type(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ - hid_t ret_value; /* Return value */ + H5A_t *attr; /* Attribute object for ID */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", attr_id); @@ -762,9 +790,17 @@ H5Aget_type(hid_t attr_id) if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if((ret_value = H5A_get_type(attr)) < 0) +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set API context") +api_ctx_pushed = TRUE; + + if((ret_value = H5A__get_type(attr)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") + done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, H5I_INVALID_HID, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Aget_type() */ @@ -803,7 +839,7 @@ H5Aget_create_plist(hid_t attr_id) if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if((ret_value = H5A_get_create_plist(attr)) < 0) + if((ret_value = H5A__get_create_plist(attr)) < 0) HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") done: @@ -880,7 +916,7 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute object for name */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -899,12 +935,16 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, dxpl_id))) + if(NULL == (attr = H5A__open_by_idx(&loc, obj_name, idx_type, order, n))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Get the length of the name */ @@ -919,8 +959,10 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, done: /* Release resources */ - if(attr && H5A_close(attr) < 0) + if(attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* end H5Aget_name_by_idx() */ @@ -1018,7 +1060,7 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute object for name */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1036,12 +1078,16 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(NULL == ainfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid info pointer") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, dxpl_id))) + if(NULL == (attr = H5A__open_by_name(&loc, obj_name, attr_name))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Get the attribute information */ @@ -1049,9 +1095,11 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: - /* Cleanup on failure */ - if(attr && H5A_close(attr) < 0) + /* Release resources */ + if(attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_name() */ @@ -1077,7 +1125,7 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute object for name */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1098,12 +1146,16 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(NULL == ainfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid info pointer") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, dxpl_id))) + if(NULL == (attr = H5A__open_by_idx(&loc, obj_name, idx_type, order, n))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Get the attribute information */ @@ -1112,8 +1164,10 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, done: /* Release resources */ - if(attr && H5A_close(attr) < 0) + if(attr && H5A__close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_idx() */ @@ -1135,6 +1189,7 @@ done: herr_t H5Arename(hid_t loc_id, const char *old_name, const char *new_name) { +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1153,12 +1208,22 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Set up collective metadata if appropriate */ +if(H5CX_set_loc(loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") + /* Call private attribute rename routine */ - if(H5O_attr_rename(loc.oloc, H5AC_ind_read_dxpl_id, old_name, new_name) < 0) + if(H5A__rename(&loc, old_name, new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Arename() */ @@ -1180,6 +1245,7 @@ herr_t H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, const char *new_attr_name, hid_t lapl_id) { +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1199,21 +1265,26 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, /* Avoid thrashing things if the names are the same */ if(HDstrcmp(old_attr_name, new_attr_name)) { H5G_loc_t loc; /* Object location */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by the library */ - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Call private attribute rename routine */ - if(H5A_rename_by_name(loc, obj_name, old_attr_name, new_attr_name, lapl_id, dxpl_id) < 0) + if(H5A__rename_by_name(loc, obj_name, old_attr_name, new_attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Arename_by_name() */ @@ -1263,9 +1334,7 @@ herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data) { - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hsize_t start_idx; /* Index of attribute to start iterating at */ - hsize_t last_attr; /* Index of last attribute examined */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1279,20 +1348,18 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP2; - attr_op.u.app_op2 = op; +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; /* Call attribute iteration routine */ - last_attr = start_idx = (idx ? *idx : 0); - if((ret_value = H5O_attr_iterate(loc_id, H5AC_ind_read_dxpl_id, idx_type, order, start_idx, &last_attr, &attr_op, op_data)) < 0) + if((ret_value = H5A__iterate(loc_id, idx_type, order, idx, op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); - /* Set the last attribute information */ - if(idx) - *idx = last_attr; - done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Aiterate2() */ @@ -1346,15 +1413,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, hid_t lapl_id) { H5G_loc_t loc; /* Object location */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - hid_t obj_loc_id = (-1); /* ID for object located */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hsize_t start_idx; /* Index of attribute to start iterating at */ - hsize_t last_attr; /* Index of last attribute examined */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1373,46 +1432,21 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; - - /* Open the object */ - if((obj_loc_id = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object") - - /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP2; - attr_op.u.app_op2 = op; +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - /* Call attribute iteration routine */ - last_attr = start_idx = (idx ? *idx : 0); - if((ret_value = H5O_attr_iterate(obj_loc_id, dxpl_id, idx_type, order, start_idx, &last_attr, &attr_op, op_data)) < 0) + /* Call attribute iteration by name routine */ + if((ret_value = H5A__iterate_by_name(&loc, obj_name, idx_type, order, idx, op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); - /* Set the last attribute information */ - if(idx) - *idx = last_attr; - done: - /* Release resources */ - if(obj_loc_id > 0) { - if(H5I_dec_app_ref(obj_loc_id) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - } /* end if */ - else if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Aiterate_by_name() */ @@ -1435,6 +1469,7 @@ herr_t H5Adelete(hid_t loc_id, const char *name) { H5G_loc_t loc; /* Object location */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1448,11 +1483,21 @@ H5Adelete(hid_t loc_id, const char *name) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Set up collective metadata if appropriate */ +if(H5CX_set_loc(loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") + /* Delete the attribute from the location */ - if(H5O_attr_remove(loc.oloc, name, H5AC_ind_read_dxpl_id) < 0) + if(H5A__delete(&loc, name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Adelete() */ @@ -1478,11 +1523,7 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { H5G_loc_t loc; /* Object location */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1498,29 +1539,21 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") /* Delete the attribute from the location */ - if(H5O_attr_remove(obj_loc.oloc, attr_name, dxpl_id) < 0) + if(H5A__delete_by_name(&loc, obj_name, attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: - /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Adelete_by_name() */ @@ -1554,11 +1587,7 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { H5G_loc_t loc; /* Object location */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1576,29 +1605,21 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") /* Delete the attribute from the location */ - if(H5O_attr_remove_by_idx(obj_loc.oloc, idx_type, order, n, dxpl_id) < 0) + if(H5A__delete_by_idx(&loc, obj_name, idx_type, order, n) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: - /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Adelete_by_idx() */ @@ -1621,6 +1642,7 @@ done: herr_t H5Aclose(hid_t attr_id) { +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1629,12 +1651,17 @@ H5Aclose(hid_t attr_id) /* check arguments */ if(NULL == H5I_object_verify(attr_id, H5I_ATTR)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; /* Decrement references to that atom (and close it) */ if(H5I_dec_app_ref(attr_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't close attribute") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Aclose() */ @@ -1657,6 +1684,7 @@ htri_t H5Aexists(hid_t obj_id, const char *attr_name) { H5G_loc_t loc; /* Object location */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1670,11 +1698,18 @@ H5Aexists(hid_t obj_id, const char *attr_name) if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; + /* Check if the attribute exists */ - if((ret_value = H5O_attr_exists(loc.oloc, attr_name, H5AC_ind_read_dxpl_id)) < 0) + if((ret_value = H5A__exists(&loc, attr_name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Aexists() */ @@ -1697,7 +1732,7 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { H5G_loc_t loc; /* Object location */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ +hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1713,14 +1748,20 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if (!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - /* Verify access property list and get correct dxpl */ - if (H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") +/* Set API context */ +if(H5CX_push() < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set API context") +api_ctx_pushed = TRUE; +/* Verify access property list and set up collective metadata if appropriate */ +if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - if ((ret_value = H5A_exists_by_name(loc, obj_name, attr_name, lapl_id, dxpl_id)) < 0) + if ((ret_value = H5A__exists_by_name(loc, obj_name, attr_name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: +if(api_ctx_pushed && H5CX_pop() < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRESET, FAIL, "can't reset API context") FUNC_LEAVE_API(ret_value) } /* H5Aexists_by_name() */ |