diff options
Diffstat (limited to 'src/H5I.c')
-rw-r--r-- | src/H5I.c | 655 |
1 files changed, 300 insertions, 355 deletions
@@ -25,67 +25,64 @@ * variables defined in H5Ipublic.h. */ -#include "H5Imodule.h" /* This source code file is part of the H5I module */ -#define H5T_FRIEND /* Suppress error about including H5Tpkg */ - - -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Ipkg.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5SLprivate.h" /* Skip Lists */ -#include "H5Tpkg.h" /* Datatypes */ - +#include "H5Imodule.h" /* This source code file is part of the H5I module */ +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5SLprivate.h" /* Skip Lists */ +#include "H5Tpkg.h" /* Datatypes */ /* Local Macros */ /* Combine a Type number and an atom index into an atom */ -#define H5I_MAKE(g,i) ((((hid_t)(g) & TYPE_MASK) << ID_BITS) | \ - ((hid_t)(i) & ID_MASK)) +#define H5I_MAKE(g, i) ((((hid_t)(g)&TYPE_MASK) << ID_BITS) | ((hid_t)(i)&ID_MASK)) /* Local typedefs */ /* Atom information structure used */ typedef struct H5I_id_info_t { - hid_t id; /* ID for this info */ - unsigned count; /* ref. count for this atom */ - unsigned app_count; /* ref. count of application visible atoms */ - const void *obj_ptr; /* pointer associated with the atom */ + hid_t id; /* ID for this info */ + unsigned count; /* ref. count for this atom */ + unsigned app_count; /* ref. count of application visible atoms */ + const void *obj_ptr; /* pointer associated with the atom */ } H5I_id_info_t; /* ID type structure used */ typedef struct { - const H5I_class_t *cls; /* Pointer to ID class */ - unsigned init_count; /* # of times this type has been initialized */ - uint64_t id_count; /* Current number of IDs held */ - uint64_t nextid; /* ID to use for the next atom */ - H5SL_t *ids; /* Pointer to skip list that stores IDs */ + const H5I_class_t *cls; /* Pointer to ID class */ + unsigned init_count; /* # of times this type has been initialized */ + uint64_t id_count; /* Current number of IDs held */ + uint64_t nextid; /* ID to use for the next atom */ + H5SL_t * ids; /* Pointer to skip list that stores IDs */ } H5I_id_type_t; typedef struct { - H5I_search_func_t app_cb; /* Application's callback routine */ - void *app_key; /* Application's "key" (user data) */ - void *ret_obj; /* Object to return */ + H5I_search_func_t app_cb; /* Application's callback routine */ + void * app_key; /* Application's "key" (user data) */ + void * ret_obj; /* Object to return */ } H5I_search_ud_t; /* User data for iterator callback for ID iteration */ typedef struct { - H5I_search_func_t user_func; /* 'User' function to invoke */ - void *user_udata; /* User data to pass to 'user' function */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ + H5I_search_func_t user_func; /* 'User' function to invoke */ + void * user_udata; /* User data to pass to 'user' function */ + hbool_t app_ref; /* Whether this is an appl. ref. call */ } H5I_iterate_ud_t; /* User data for H5I__clear_type_cb */ typedef struct { - H5I_id_type_t *type_ptr; /* Pointer to the type being cleard */ - hbool_t force; /* Whether to always remove the id */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ + H5I_id_type_t *type_ptr; /* Pointer to the type being cleard */ + hbool_t force; /* Whether to always remove the id */ + hbool_t app_ref; /* Whether this is an appl. ref. call */ } H5I_clear_type_ud_t; /* Package initialization variable */ @@ -114,18 +111,17 @@ H5FL_DEFINE_STATIC(H5I_id_type_t); H5FL_DEFINE_STATIC(H5I_class_t); /*--------------------- Local function prototypes ---------------------------*/ -static htri_t H5I__clear_type_cb(void *_id, void *key, void *udata); -static int H5I__destroy_type(H5I_type_t type); -static void *H5I__remove_verify(hid_t id, H5I_type_t id_type); -static void *H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id); -static int H5I__inc_type_ref(H5I_type_t type); -static int H5I__get_type_ref(H5I_type_t type); -static int H5I__search_cb(void *obj, hid_t id, void *_udata); +static htri_t H5I__clear_type_cb(void *_id, void *key, void *udata); +static int H5I__destroy_type(H5I_type_t type); +static void * H5I__remove_verify(hid_t id, H5I_type_t id_type); +static void * H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id); +static int H5I__inc_type_ref(H5I_type_t type); +static int H5I__get_type_ref(H5I_type_t type); +static int H5I__search_cb(void *obj, hid_t id, void *_udata); static H5I_id_info_t *H5I__find_id(hid_t id); -static int H5I__debug_cb(void *_item, void *_key, void *_udata); -static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); +static int H5I__debug_cb(void *_item, void *_key, void *_udata); +static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); - /*------------------------------------------------------------------------- * Function: H5I_term_package * @@ -143,41 +139,40 @@ static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); int H5I_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR - if(H5_PKG_INIT_VAR) { - H5I_id_type_t *type_ptr; /* Pointer to ID type */ - int type; /* Type of ID */ + if (H5_PKG_INIT_VAR) { + H5I_id_type_t *type_ptr; /* Pointer to ID type */ + int type; /* Type of ID */ /* How many types are still being used? */ - for(type = 0; type < H5I_next_type; type++) - if((type_ptr = H5I_id_type_list_g[type]) && type_ptr->ids) + for (type = 0; type < H5I_next_type; type++) + if ((type_ptr = H5I_id_type_list_g[type]) && type_ptr->ids) n++; /* If no types are used then clean up */ - if(0 == n) { - for(type = 0; type < H5I_next_type; type++) { + if (0 == n) { + for (type = 0; type < H5I_next_type; type++) { type_ptr = H5I_id_type_list_g[type]; - if(type_ptr) { + if (type_ptr) { HDassert(NULL == type_ptr->ids); - type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); + type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); H5I_id_type_list_g[type] = NULL; n++; } /* end if */ - } /* end for */ + } /* end for */ /* Mark interface closed */ - if(0 == n) + if (0 == n) H5_PKG_INIT_VAR = FALSE; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5I_term_package() */ - /*------------------------------------------------------------------------- * Function: H5Iregister_type * @@ -196,12 +191,11 @@ H5I_term_package(void) *------------------------------------------------------------------------- */ H5I_type_t -H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, - H5I_free_t free_func) +H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, H5I_free_t free_func) { H5I_class_t *cls = NULL; /* New ID class */ - H5I_type_t new_type; /* New ID type value */ - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_type_t new_type; /* New ID type value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_API(H5I_BADID) H5TRACE3("It", "zIux", hash_size, reserved, free_func); @@ -209,41 +203,41 @@ H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, /* Generate a new H5I_type_t value */ /* Increment the number of types */ - if(H5I_next_type < H5I_MAX_NUM_TYPES) { + if (H5I_next_type < H5I_MAX_NUM_TYPES) { new_type = (H5I_type_t)H5I_next_type; H5I_next_type++; } /* end if */ else { - hbool_t done; /* Indicate that search was successful */ - int i; /* Local index variable */ + hbool_t done; /* Indicate that search was successful */ + int i; /* Local index variable */ /* Look for a free type to give out */ done = FALSE; - for(i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == FALSE; i++) { - if(NULL == H5I_id_type_list_g[i]) { + for (i = H5I_NTYPES; i < H5I_MAX_NUM_TYPES && done == FALSE; i++) { + if (NULL == H5I_id_type_list_g[i]) { /* Found a free type ID */ new_type = (H5I_type_t)i; - done = TRUE; + done = TRUE; } /* end if */ - } /* end for */ + } /* end for */ /* Verify that we found a type to give out */ - if(done == FALSE) + if (done == FALSE) HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_BADID, "Maximum number of ID types exceeded") } /* end else */ /* Allocate new ID class */ - if(NULL == (cls = H5FL_CALLOC(H5I_class_t))) + if (NULL == (cls = H5FL_CALLOC(H5I_class_t))) HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed") /* Initialize class fields */ - cls->type_id = new_type; - cls->flags = H5I_CLASS_IS_APPLICATION; - cls->reserved = reserved; + cls->type_id = new_type; + cls->flags = H5I_CLASS_IS_APPLICATION; + cls->reserved = reserved; cls->free_func = free_func; /* Register the new ID class */ - if(H5I_register_type(cls) < 0) + if (H5I_register_type(cls) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, H5I_BADID, "can't initialize ID class") /* Set return value */ @@ -251,14 +245,13 @@ H5Iregister_type(size_t H5_ATTR_DEBUG_API_USED hash_size, unsigned reserved, done: /* Clean up on error */ - if(ret_value < 0) - if(cls) + if (ret_value < 0) + if (cls) cls = H5FL_FREE(H5I_class_t, cls); FUNC_LEAVE_API(ret_value) } /* end H5Iregister_type() */ - /*------------------------------------------------------------------------- * Function: H5I_register_type * @@ -273,8 +266,8 @@ done: herr_t H5I_register_type(const H5I_class_t *cls) { - H5I_id_type_t *type_ptr = NULL; /* Ptr to the atomic type*/ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_id_type_t *type_ptr = NULL; /* Ptr to the atomic type*/ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -283,9 +276,9 @@ H5I_register_type(const H5I_class_t *cls) HDassert(cls->type_id > 0 && (int)cls->type_id < H5I_MAX_NUM_TYPES); /* Initialize the type */ - if(NULL == H5I_id_type_list_g[cls->type_id]) { + if (NULL == H5I_id_type_list_g[cls->type_id]) { /* Allocate the type information for new type */ - if(NULL == (type_ptr = (H5I_id_type_t *)H5FL_CALLOC(H5I_id_type_t))) + if (NULL == (type_ptr = (H5I_id_type_t *)H5FL_CALLOC(H5I_id_type_t))) HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, FAIL, "ID type allocation failed") H5I_id_type_list_g[cls->type_id] = type_ptr; } /* end if */ @@ -295,11 +288,11 @@ H5I_register_type(const H5I_class_t *cls) } /* end else */ /* Initialize the ID type structure for new types */ - if(type_ptr->init_count == 0) { - type_ptr->cls = cls; + if (type_ptr->init_count == 0) { + type_ptr->cls = cls; type_ptr->id_count = 0; - type_ptr->nextid = cls->reserved; - if(NULL == (type_ptr->ids = H5SL_create(H5SL_TYPE_HID, NULL))) + type_ptr->nextid = cls->reserved; + if (NULL == (type_ptr->ids = H5SL_create(H5SL_TYPE_HID, NULL))) HGOTO_ERROR(H5E_ATOM, H5E_CANTCREATE, FAIL, "skip list creation failed") } /* end if */ @@ -307,18 +300,17 @@ H5I_register_type(const H5I_class_t *cls) type_ptr->init_count++; done: - if(ret_value < 0) { /* Clean up on error */ - if(type_ptr) { - if(type_ptr->ids) + if (ret_value < 0) { /* Clean up on error */ + if (type_ptr) { + if (type_ptr->ids) H5SL_close(type_ptr->ids); (void)H5FL_FREE(H5I_id_type_t, type_ptr); } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_register_type() */ - /*------------------------------------------------------------------------- * Function: H5Itype_exists * @@ -332,25 +324,24 @@ done: htri_t H5Itype_exists(H5I_type_t type) { - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "It", type); /* Validate parameter */ - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if(NULL == H5I_id_type_list_g[type]) + if (NULL == H5I_id_type_list_g[type]) ret_value = FALSE; done: FUNC_LEAVE_API(ret_value) } /* end H5Itype_exists() */ - /*------------------------------------------------------------------------- * Function: H5Inmembers * @@ -370,27 +361,27 @@ done: herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members) { - int ret_value = SUCCEED; /* Return value */ + int ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "It*h", type, num_members); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") /* Validate parameters. This needs to be done here, instead of letting * the private interface handle it, because the public interface throws * an error when the supplied type does not exist. */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if(NULL == H5I_id_type_list_g[type]) + if (NULL == H5I_id_type_list_g[type]) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "supplied type does not exist") - if(num_members) { + if (num_members) { int64_t members; - if((members = H5I_nmembers(type)) < 0) + if ((members = H5I_nmembers(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTCOUNT, FAIL, "can't compute number of members") H5_CHECKED_ASSIGN(*num_members, hsize_t, members, int64_t); @@ -400,7 +391,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Inmembers() */ - /*------------------------------------------------------------------------- * Function: H5I_nmembers * @@ -419,15 +409,15 @@ done: int64_t H5I_nmembers(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - int64_t ret_value = 0; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the ID type */ + int64_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Validate parameter */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if(NULL == (type_ptr = H5I_id_type_list_g[type]) || type_ptr->init_count <= 0) + if (NULL == (type_ptr = H5I_id_type_list_g[type]) || type_ptr->init_count <= 0) HGOTO_DONE(0); /* Set return value */ @@ -437,7 +427,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_nmembers() */ - /*------------------------------------------------------------------------- * Function: H5Iclear_type * @@ -456,12 +445,12 @@ done: herr_t H5Iclear_type(H5I_type_t type, hbool_t force) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "Itb", type, force); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") ret_value = H5I_clear_type(type, force, TRUE); @@ -470,7 +459,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iclear_type() */ - /*------------------------------------------------------------------------- * Function: H5I_clear_type * @@ -487,32 +475,31 @@ done: herr_t H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) { - H5I_clear_type_ud_t udata; /* udata struct for callback */ - int ret_value = SUCCEED; /* Return value */ + H5I_clear_type_ud_t udata; /* udata struct for callback */ + int ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Validate parameters */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") udata.type_ptr = H5I_id_type_list_g[type]; - if(udata.type_ptr == NULL || udata.type_ptr->init_count <= 0) + if (udata.type_ptr == NULL || udata.type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* Finish constructing udata */ - udata.force = force; + udata.force = force; udata.app_ref = app_ref; /* Attempt to free all ids in the type */ - if(H5SL_try_free_safe(udata.type_ptr->ids, H5I__clear_type_cb, &udata) < 0) + if (H5SL_try_free_safe(udata.type_ptr->ids, H5I__clear_type_cb, &udata) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't free ids in type") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_clear_type() */ - /*------------------------------------------------------------------------- * Function: H5I__clear_type_cb * @@ -529,9 +516,9 @@ done: static htri_t H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) { - H5I_id_info_t *id = (H5I_id_info_t *)_id; /* Current ID being worked with */ - H5I_clear_type_ud_t *udata = (H5I_clear_type_ud_t *)_udata; /* udata struct */ - htri_t ret_value = FALSE; /* Return value */ + H5I_id_info_t * id = (H5I_id_info_t *)_id; /* Current ID being worked with */ + H5I_clear_type_ud_t *udata = (H5I_clear_type_ud_t *)_udata; /* udata struct */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -543,42 +530,42 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) /* Do nothing to the object if the reference count is larger than * one and forcing is off. */ - if(udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { + if (udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { /* Check for a 'free' function and call it, if it exists */ - if(udata->type_ptr->cls->free_func && (udata->type_ptr->cls->free_func)((void *)id->obj_ptr) < 0) { /* (Casting away const OK -QAK) */ - if(udata->force) { + if (udata->type_ptr->cls->free_func && + (udata->type_ptr->cls->free_func)((void *)id->obj_ptr) < 0) { /* (Casting away const OK -QAK) */ + if (udata->force) { #ifdef H5I_DEBUG - if(H5DEBUG(I)) { - HDfprintf(H5DEBUG(I), "H5I: free type=%d obj=0x%08lx " - "failure ignored\n", - (int)udata->type_ptr->cls->type_id, - (unsigned long)(id->obj_ptr)); + if (H5DEBUG(I)) { + HDfprintf(H5DEBUG(I), + "H5I: free type=%d obj=0x%08lx " + "failure ignored\n", + (int)udata->type_ptr->cls->type_id, (unsigned long)(id->obj_ptr)); } /* end if */ -#endif /*H5I_DEBUG*/ +#endif /*H5I_DEBUG*/ /* Indicate node should be removed from list */ ret_value = TRUE; } /* end if */ - } /* end if */ + } /* end if */ else { /* Indicate node should be removed from list */ ret_value = TRUE; } /* end else */ /* Remove ID if requested */ - if(ret_value) { + if (ret_value) { /* Free ID info */ id = H5FL_FREE(H5I_id_info_t, id); /* Decrement the number of IDs in the type */ udata->type_ptr->id_count--; } /* end if */ - } /* end if */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__clear_type_cb() */ - /*------------------------------------------------------------------------- * Function: H5Idestroy_type * @@ -598,12 +585,12 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) herr_t H5Idestroy_type(H5I_type_t type) { - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "It", type); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") ret_value = H5I__destroy_type(type); @@ -612,7 +599,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Idestroy_type() */ - /*------------------------------------------------------------------------- * Function: H5I__destroy_type * @@ -631,40 +617,38 @@ done: static herr_t H5I__destroy_type(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* ptr to the atomic type */ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_id_type_t *type_ptr; /* ptr to the atomic type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Validate parameter */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->init_count <= 0) + if (type_ptr == NULL || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* Close/clear/destroy all IDs for this type */ - H5E_BEGIN_TRY { - H5I_clear_type(type, TRUE, FALSE); - } H5E_END_TRY /*don't care about errors*/ + H5E_BEGIN_TRY { H5I_clear_type(type, TRUE, FALSE); } + H5E_END_TRY /*don't care about errors*/ - /* Check if we should release the ID class */ - if(type_ptr->cls->flags & H5I_CLASS_IS_APPLICATION) - type_ptr->cls = H5FL_FREE(H5I_class_t, (void *)type_ptr->cls); + /* Check if we should release the ID class */ + if (type_ptr->cls->flags & H5I_CLASS_IS_APPLICATION) + type_ptr->cls = H5FL_FREE(H5I_class_t, (void *)type_ptr->cls); - if(H5SL_close(type_ptr->ids) < 0) + if (H5SL_close(type_ptr->ids) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEOBJ, FAIL, "can't close skip list") type_ptr->ids = NULL; - type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); + type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); H5I_id_type_list_g[type] = NULL; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__destroy_type() */ - /*------------------------------------------------------------------------- * Function: H5Iregister * @@ -678,12 +662,12 @@ done: hid_t H5Iregister(H5I_type_t type, const void *object) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "It*x", type, object); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") ret_value = H5I_register(type, object, TRUE); @@ -692,7 +676,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iregister() */ - /*------------------------------------------------------------------------- * Function: H5I_register * @@ -712,10 +695,10 @@ done: hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) { - H5I_id_type_t *type_ptr = NULL; /* ptr to the type */ - H5I_id_info_t *id_ptr = NULL; /* ptr to the new ID information */ - hid_t new_id = -1; /* new ID */ - hid_t ret_value = H5I_INVALID_HID; /* return value */ + H5I_id_type_t *type_ptr = NULL; /* ptr to the type */ + H5I_id_info_t *id_ptr = NULL; /* ptr to the new ID information */ + hid_t new_id = -1; /* new ID */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -729,11 +712,11 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") /* Create the struct & its ID */ - new_id = H5I_MAKE(type, type_ptr->nextid); - id_ptr->id = new_id; - id_ptr->count = 1; /* initial reference count */ - id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; + new_id = H5I_MAKE(type, type_ptr->nextid); + id_ptr->id = new_id; + id_ptr->count = 1; /* initial reference count */ + id_ptr->app_count = !!app_ref; + id_ptr->obj_ptr = object; /* Insert into the type */ if (H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) @@ -751,7 +734,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_register() */ - /*------------------------------------------------------------------------- * Function: H5I_register_using_existing_id * @@ -773,9 +755,9 @@ done: herr_t H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, hid_t existing_id) { - H5I_id_type_t *type_ptr; /* ptr to the type */ - H5I_id_info_t *id_ptr; /* ptr to the new ID information */ - herr_t ret_value = SUCCEED; /* return value */ + H5I_id_type_t *type_ptr; /* ptr to the type */ + H5I_id_info_t *id_ptr; /* ptr to the new ID information */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -783,35 +765,35 @@ H5I_register_using_existing_id(H5I_type_t type, void *object, hbool_t app_ref, h HDassert(object); /* Make sure ID is not already in use */ - if(NULL != (id_ptr = H5I__find_id(existing_id))) + if (NULL != (id_ptr = H5I__find_id(existing_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use") /* Make sure type number is valid */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") /* Get type pointer from list of types */ type_ptr = H5I_id_type_list_g[type]; - if(NULL == type_ptr || type_ptr->init_count <= 0) + if (NULL == type_ptr || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* Make sure requested ID belongs to object's type */ - if(H5I_TYPE(existing_id) != type) + if (H5I_TYPE(existing_id) != type) HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "invalid type for provided ID") /* Allocate new structure to house this ID */ - if(NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) + if (NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed") /* Create the struct & insert requested ID */ - id_ptr->id = existing_id; - id_ptr->count = 1; /* initial reference count*/ - id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; + id_ptr->id = existing_id; + id_ptr->count = 1; /* initial reference count*/ + id_ptr->app_count = !!app_ref; + id_ptr->obj_ptr = object; /* Insert into the type */ - if(H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) + if (H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, FAIL, "can't insert ID node into skip list") type_ptr->id_count++; @@ -819,7 +801,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_register_using_existing_id() */ - /*------------------------------------------------------------------------- * Function: H5I_subst * @@ -837,17 +818,17 @@ done: void * H5I_subst(hid_t id, const void *new_object) { - H5I_id_info_t *id_ptr; /* Pointer to the atom */ - void *ret_value = NULL; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the atom */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) + if (NULL == (id_ptr = H5I__find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_NOTFOUND, NULL, "can't get ID ref count") /* Get the old object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ /* Set the new object pointer for the ID */ id_ptr->obj_ptr = new_object; @@ -856,7 +837,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_subst() */ - /*------------------------------------------------------------------------- * Function: H5I_object * @@ -872,21 +852,20 @@ done: void * H5I_object(hid_t id) { - H5I_id_info_t *id_ptr; /* Pointer to the new atom */ - void *ret_value = NULL; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the new atom */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOERR /* General lookup of the ID */ - if(NULL != (id_ptr = H5I__find_id(id))) { + if (NULL != (id_ptr = H5I__find_id(id))) { /* Get the object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ } FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_object() */ - /*------------------------------------------------------------------------- * Function: H5Iobject_verify * @@ -903,15 +882,15 @@ H5I_object(hid_t id) void * H5Iobject_verify(hid_t id, H5I_type_t id_type) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE2("*x", "iIt", id, id_type); /* Validate parameters */ - if(H5I_IS_LIB_TYPE(id_type)) + if (H5I_IS_LIB_TYPE(id_type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") - if(id_type < 1 || (int)id_type >= H5I_next_type) + if (id_type < 1 || (int)id_type >= H5I_next_type) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "identifier has invalid type") ret_value = H5I_object_verify(id, id_type); @@ -920,7 +899,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iobject_verify() */ - /*------------------------------------------------------------------------- * Function: H5I_object_verify * @@ -939,23 +917,22 @@ done: void * H5I_object_verify(hid_t id, H5I_type_t id_type) { - H5I_id_info_t *id_ptr = NULL; /* Pointer to the new atom */ - void *ret_value = NULL; /* Return value */ + H5I_id_info_t *id_ptr = NULL; /* Pointer to the new atom */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOERR HDassert(id_type >= 1 && (int)id_type < H5I_next_type); /* Verify that the type of the ID is correct & lookup the ID */ - if(id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I__find_id(id))) { + if (id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I__find_id(id))) { /* Get the object pointer to return */ - ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ } FUNC_LEAVE_NOAPI(ret_value) } /* H5I_object_verify() */ - /*------------------------------------------------------------------------- * Function: H5I_get_type * @@ -977,11 +954,11 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) H5I_type_t H5I_get_type(hid_t id) { - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_NOAPI_NOERR - if(id > 0) + if (id > 0) ret_value = H5I_TYPE(id); HDassert(ret_value >= H5I_BADID && (int)ret_value < H5I_next_type); @@ -989,7 +966,6 @@ H5I_get_type(hid_t id) FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_get_type() */ - /*------------------------------------------------------------------------- * Function: H5Iget_type * @@ -1008,21 +984,20 @@ H5I_get_type(hid_t id) H5I_type_t H5Iget_type(hid_t id) { - H5I_type_t ret_value = H5I_BADID; /* Return value */ + H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_API(H5I_BADID) H5TRACE1("It", "i", id); ret_value = H5I_get_type(id); - if(ret_value <= H5I_BADID || (int)ret_value >= H5I_next_type || NULL == H5I_object(id)) + if (ret_value <= H5I_BADID || (int)ret_value >= H5I_next_type || NULL == H5I_object(id)) HGOTO_DONE(H5I_BADID); done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_type() */ - /*------------------------------------------------------------------------- * Function: H5Iremove_verify * @@ -1043,12 +1018,12 @@ done: void * H5Iremove_verify(hid_t id, H5I_type_t id_type) { - void *ret_value = NULL; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE2("*x", "iIt", id, id_type); - if(H5I_IS_LIB_TYPE(id_type)) + if (H5I_IS_LIB_TYPE(id_type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") /* Remove the id */ @@ -1058,7 +1033,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iremove_verify() */ - /*------------------------------------------------------------------------- * Function: H5I__remove_verify * @@ -1078,20 +1052,19 @@ done: static void * H5I__remove_verify(hid_t id, H5I_type_t id_type) { - void * ret_value = NULL; /*return value */ + void *ret_value = NULL; /*return value */ FUNC_ENTER_STATIC_NOERR /* Argument checking will be performed by H5I_remove() */ /* Verify that the type of the ID is correct */ - if(id_type == H5I_TYPE(id)) + if (id_type == H5I_TYPE(id)) ret_value = H5I_remove(id); FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__remove_verify() */ - /*------------------------------------------------------------------------- * Function: H5I__remove_common * @@ -1110,8 +1083,8 @@ H5I__remove_verify(hid_t id, H5I_type_t id_type) static void * H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id) { - H5I_id_info_t *curr_id; /* Pointer to the current atom */ - void *ret_value = NULL; /* Return value */ + H5I_id_info_t *curr_id; /* Pointer to the current atom */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -1119,11 +1092,11 @@ H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id) HDassert(type_ptr); /* Get the ID node for the ID */ - if(NULL == (curr_id = (H5I_id_info_t *)H5SL_remove(type_ptr->ids, &id))) + if (NULL == (curr_id = (H5I_id_info_t *)H5SL_remove(type_ptr->ids, &id))) HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node from skip list") - ret_value = (void *)curr_id->obj_ptr; /* (Casting away const OK -QAK) */ - curr_id = H5FL_FREE(H5I_id_info_t, curr_id); + ret_value = (void *)curr_id->obj_ptr; /* (Casting away const OK -QAK) */ + curr_id = H5FL_FREE(H5I_id_info_t, curr_id); /* Decrement the number of IDs in the type */ (type_ptr->id_count)--; @@ -1132,7 +1105,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__remove_common() */ - /*------------------------------------------------------------------------- * Function: H5I_remove * @@ -1148,29 +1120,28 @@ done: void * H5I_remove(hid_t id) { - H5I_id_type_t *type_ptr; /* Pointer to the atomic type */ - H5I_type_t type; /* Atom's atomic type */ - void * ret_value = NULL; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the atomic type */ + H5I_type_t type; /* Atom's atomic type */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Check arguments */ type = H5I_TYPE(id); - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->init_count <= 0) + if (type_ptr == NULL || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type") /* Remove the node from the type */ - if(NULL == (ret_value = H5I__remove_common(type_ptr, id))) + if (NULL == (ret_value = H5I__remove_common(type_ptr, id))) HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, NULL, "can't remove ID node") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_remove() */ - /*------------------------------------------------------------------------- * Function: H5Idec_ref * @@ -1189,24 +1160,23 @@ done: int H5Idec_ref(hid_t id) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ - if(id < 0) + if (id < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual decrement operation */ - if((ret_value = H5I_dec_app_ref(id)) < 0) + if ((ret_value = H5I_dec_app_ref(id)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") done: FUNC_LEAVE_API(ret_value) } /* end H5Idec_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_dec_ref * @@ -1225,8 +1195,8 @@ done: int H5I_dec_ref(hid_t id) { - H5I_id_info_t *id_ptr; /* Pointer to the new ID */ - int ret_value = 0; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the new ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -1234,7 +1204,7 @@ H5I_dec_ref(hid_t id) HDassert(id >= 0); /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) + if (NULL == (id_ptr = H5I__find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* If this is the last reference to the object then invoke the type's @@ -1251,16 +1221,16 @@ H5I_dec_ref(hid_t id) * write when a dataset is closed and the chunk cache is flushed to the * file. We have to close the dataset anyway. (SLU - 2010/9/7) */ - if(1 == id_ptr->count) { - H5I_id_type_t *type_ptr; /*ptr to the type */ + if (1 == id_ptr->count) { + H5I_id_type_t *type_ptr; /*ptr to the type */ /* Get the ID's type */ type_ptr = H5I_id_type_list_g[H5I_TYPE(id)]; /* (Casting away const OK -QAK) */ - if(!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) { + if (!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) { /* Remove the node from the type */ - if(NULL == H5I__remove_common(type_ptr, id)) + if (NULL == H5I__remove_common(type_ptr, id)) HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, (-1), "can't remove ID node") ret_value = 0; } /* end if */ @@ -1276,7 +1246,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_dec_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_dec_app_ref * @@ -1294,8 +1263,8 @@ done: int H5I_dec_app_ref(hid_t id) { - H5I_id_info_t *id_ptr; /* Pointer to the new ID */ - int ret_value = 0; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the new ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -1303,13 +1272,13 @@ H5I_dec_app_ref(hid_t id) HDassert(id >= 0); /* Call regular decrement reference count routine */ - if((ret_value = H5I_dec_ref(id)) < 0) + if ((ret_value = H5I_dec_ref(id)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") /* Check if the ID still exists */ - if(ret_value > 0) { + if (ret_value > 0) { /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) + if (NULL == (id_ptr = H5I__find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Adjust app_ref */ @@ -1324,7 +1293,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_dec_app_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_dec_app_ref_always_close * @@ -1339,7 +1307,7 @@ done: int H5I_dec_app_ref_always_close(hid_t id) { - int ret_value = 0; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -1366,7 +1334,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_dec_app_ref_always_close() */ - /*------------------------------------------------------------------------- * Function: H5Iinc_ref * @@ -1380,7 +1347,7 @@ done: int H5Iinc_ref(hid_t id) { - int ret_value; /* Return value */ + int ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); @@ -1397,7 +1364,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iinc_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_inc_ref * @@ -1411,8 +1377,8 @@ done: int H5I_inc_ref(hid_t id, hbool_t app_ref) { - H5I_id_info_t *id_ptr; /* Pointer to the ID */ - int ret_value = 0; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -1435,7 +1401,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_inc_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iget_ref * @@ -1449,7 +1414,7 @@ done: int H5Iget_ref(hid_t id) { - int ret_value; /* Return value */ + int ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); @@ -1466,7 +1431,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_get_ref * @@ -1480,8 +1444,8 @@ done: int H5I_get_ref(hid_t id, hbool_t app_ref) { - H5I_id_info_t *id_ptr; /* Pointer to the ID */ - int ret_value = 0; /* Return value */ + H5I_id_info_t *id_ptr; /* Pointer to the ID */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) @@ -1499,7 +1463,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_get_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iinc_type_ref * @@ -1513,26 +1476,25 @@ done: int H5Iinc_type_ref(H5I_type_t type) { - int ret_value; /* Return value */ + int ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ - if(type <= 0 || (int)type >= H5I_next_type) + if (type <= 0 || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual increment operation */ - if((ret_value = H5I__inc_type_ref(type)) < 0) + if ((ret_value = H5I__inc_type_ref(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, (-1), "can't increment ID type ref count") done: FUNC_LEAVE_API(ret_value) } /* end H5Iinc_ref() */ - /*------------------------------------------------------------------------- * Function: H5I__inc_type_ref * @@ -1546,8 +1508,8 @@ done: static int H5I__inc_type_ref(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* Pointer to the type */ - int ret_value = -1; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the type */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -1556,7 +1518,7 @@ H5I__inc_type_ref(H5I_type_t type) /* Check arguments */ type_ptr = H5I_id_type_list_g[type]; - if(NULL == type_ptr) + if (NULL == type_ptr) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") /* Set return value */ @@ -1566,7 +1528,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__inc_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5Idec_type_ref * @@ -1594,7 +1555,7 @@ done: herr_t H5Idec_type_ref(H5I_type_t type) { - herr_t ret_value = 0; /* Return value */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("e", "It", type); @@ -1608,7 +1569,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Idec_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5I_dec_type_ref * @@ -1631,16 +1591,16 @@ done: int H5I_dec_type_ref(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - herr_t ret_value = 0; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the ID type */ + herr_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI((-1)) - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "invalid type number") type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->init_count <= 0) + if (type_ptr == NULL || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") /* Decrement the number of users of the atomic type. If this is the @@ -1648,7 +1608,7 @@ H5I_dec_type_ref(H5I_type_t type) * free all memory it used. The free function is invoked for each atom * being freed. */ - if(1 == type_ptr->init_count) { + if (1 == type_ptr->init_count) { H5I__destroy_type(type); ret_value = 0; } @@ -1661,7 +1621,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_dec_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iget_type_ref * @@ -1675,26 +1634,25 @@ done: int H5Iget_type_ref(H5I_type_t type) { - int ret_value; /* Return value */ + int ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ - if(type <= 0 || (int)type >= H5I_next_type) + if (type <= 0 || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual retrieve operation */ - if((ret_value = H5I__get_type_ref(type)) < 0) + if ((ret_value = H5I__get_type_ref(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get ID type ref count") done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_ref() */ - /*------------------------------------------------------------------------- * Function: H5I__get_type_ref * @@ -1709,8 +1667,8 @@ done: static int H5I__get_type_ref(H5I_type_t type) { - H5I_id_type_t *type_ptr; /* Pointer to the type */ - int ret_value = -1; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the type */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -1729,7 +1687,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__get_type_ref() */ - /*------------------------------------------------------------------------- * Function: H5Iis_valid * @@ -1743,8 +1700,8 @@ done: htri_t H5Iis_valid(hid_t id) { - H5I_id_info_t *id_ptr; /* ptr to the ID */ - htri_t ret_value = TRUE; /* Return value */ + H5I_id_info_t *id_ptr; /* ptr to the ID */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", id); @@ -1759,7 +1716,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iis_valid() */ - /*------------------------------------------------------------------------- * Function: H5I__search_cb * @@ -1775,26 +1731,25 @@ done: static int H5I__search_cb(void *obj, hid_t id, void *_udata) { - H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ - herr_t cb_ret_val; /* User callback return value */ - int ret_value = H5_ITER_ERROR; /* Callback return value */ + H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ + herr_t cb_ret_val; /* User callback return value */ + int ret_value = H5_ITER_ERROR; /* Callback return value */ FUNC_ENTER_STATIC_NOERR cb_ret_val = (*udata->app_cb)(obj, id, udata->app_key); /* Set the return value based on the callback's return value */ - if(cb_ret_val > 0) { - ret_value = H5_ITER_STOP; /* terminate iteration early */ - udata->ret_obj = obj; /* also set out parameter */ + if (cb_ret_val > 0) { + ret_value = H5_ITER_STOP; /* terminate iteration early */ + udata->ret_obj = obj; /* also set out parameter */ } - else if(cb_ret_val < 0) - ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ + else if (cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__search_cb() */ - /*------------------------------------------------------------------------- * Function: H5Isearch * @@ -1818,8 +1773,8 @@ H5I__search_cb(void *obj, hid_t id, void *_udata) void * H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) { - H5I_search_ud_t udata; /* Context for iteration */ - void *ret_value; /* Return value */ + H5I_search_ud_t udata; /* Context for iteration */ + void * ret_value; /* Return value */ FUNC_ENTER_API(NULL) H5TRACE3("*x", "Itx*x", type, func, key); @@ -1829,7 +1784,7 @@ H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") /* Set up udata struct */ - udata.app_cb = func; + udata.app_cb = func; udata.app_key = key; udata.ret_obj = NULL; @@ -1845,7 +1800,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Isearch() */ - /*------------------------------------------------------------------------- * Function: H5I__iterate_cb * @@ -1861,32 +1815,32 @@ done: static int H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_iterate_ud_t *udata = (H5I_iterate_ud_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Callback return value */ + H5I_id_info_t * item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_iterate_ud_t *udata = (H5I_iterate_ud_t *)_udata; /* User data for callback */ + int ret_value = H5_ITER_CONT; /* Callback return value */ FUNC_ENTER_STATIC_NOERR /* Only invoke the callback function if this ID is visible externally and * its reference count is positive. */ - if((!udata->app_ref) || (item->app_count > 0)) { - herr_t cb_ret_val; + if ((!udata->app_ref) || (item->app_count > 0)) { + herr_t cb_ret_val; /* Invoke callback function */ - cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); /* (Casting away const OK) */ + cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, + udata->user_udata); /* (Casting away const OK) */ /* Set the return value based on the callback's return value */ - if(cb_ret_val > 0) - ret_value = H5_ITER_STOP; /* terminate iteration early */ - else if(cb_ret_val < 0) - ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ + if (cb_ret_val > 0) + ret_value = H5_ITER_STOP; /* terminate iteration early */ + else if (cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ } FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__iterate_cb() */ - /*------------------------------------------------------------------------- * Function: H5I_iterate * @@ -1915,28 +1869,28 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref) { - H5I_id_type_t *type_ptr; /* Pointer to the type */ - herr_t ret_value = SUCCEED; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the type */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; /* Only iterate through ID list if it is initialized and there are IDs in type */ - if(type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) { - H5I_iterate_ud_t iter_udata; /* User data for iteration callback */ - herr_t iter_status; /* Iteration status */ + if (type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) { + H5I_iterate_ud_t iter_udata; /* User data for iteration callback */ + herr_t iter_status; /* Iteration status */ /* Set up iterator user data */ - iter_udata.user_func = func; - iter_udata.user_udata = udata; - iter_udata.app_ref = app_ref; + iter_udata.user_func = func; + iter_udata.user_udata = udata; + iter_udata.app_ref = app_ref; /* Iterate over IDs */ - if((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) + if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") } @@ -1944,7 +1898,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_iterate() */ - /*------------------------------------------------------------------------- * Function: H5I__find_id * @@ -1960,18 +1913,18 @@ done: static H5I_id_info_t * H5I__find_id(hid_t id) { - H5I_type_t type; /*ID's type */ - H5I_id_type_t *type_ptr; /*ptr to the type */ - H5I_id_info_t *ret_value = NULL; /* Return value */ + H5I_type_t type; /*ID's type */ + H5I_id_type_t *type_ptr; /*ptr to the type */ + H5I_id_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments */ type = H5I_TYPE(id); - if(type <= H5I_BADID || (int)type >= H5I_next_type) + if (type <= H5I_BADID || (int)type >= H5I_next_type) HGOTO_DONE(NULL) type_ptr = H5I_id_type_list_g[type]; - if(!type_ptr || type_ptr->init_count <= 0) + if (!type_ptr || type_ptr->init_count <= 0) HGOTO_DONE(NULL) /* Locate the ID node for the ID */ @@ -1981,7 +1934,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__find_id() */ - /*------------------------------------------------------------------------- * Function: H5Iget_name * @@ -2004,27 +1956,26 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Iget_name(hid_t id, char *name/*out*/, size_t size) +H5Iget_name(hid_t id, char *name /*out*/, size_t size) { - H5G_loc_t loc; /* Object location */ - ssize_t ret_value; /* Return value */ + H5G_loc_t loc; /* Object location */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", id, name, size); /* Get object location */ - if(H5G_loc(id, &loc) < 0) + if (H5G_loc(id, &loc) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") /* Retrieve object's name */ - if((ret_value = H5G_get_name(&loc, name, size, NULL)) < 0) + if ((ret_value = H5G_get_name(&loc, name, size, NULL)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_name() */ - /*------------------------------------------------------------------------- * Function: H5Iget_file_id * @@ -2040,8 +1991,8 @@ done: hid_t H5Iget_file_id(hid_t obj_id) { - H5I_type_t type; /* ID type */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5I_type_t type; /* ID type */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", obj_id); @@ -2050,8 +2001,9 @@ H5Iget_file_id(hid_t obj_id) type = H5I_TYPE(obj_id); /* Call internal function */ - if(H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { - if((ret_value = H5I_get_file_id(obj_id, type)) < 0) + if (H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || + H5I_ATTR == type) { + if ((ret_value = H5I_get_file_id(obj_id, type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") } else @@ -2061,7 +2013,6 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_file_id() */ - /*------------------------------------------------------------------------- * Function: H5I_get_file_id * @@ -2076,28 +2027,28 @@ done: hid_t H5I_get_file_id(hid_t obj_id, H5I_type_t type) { - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Process based on object type */ if (type == H5I_FILE) { /* Increment reference count on file ID */ - if(H5I_inc_ref(obj_id, TRUE) < 0) + if (H5I_inc_ref(obj_id, TRUE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") /* Set return value */ ret_value = obj_id; } else { - H5G_loc_t loc; /* Location of object */ + H5G_loc_t loc; /* Location of object */ /* Get the object location information */ - if(H5G_loc(obj_id, &loc) < 0) + if (H5G_loc(obj_id, &loc) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") /* Get the file ID for the object */ - if((ret_value = H5F_get_id(loc.oloc->file, TRUE)) < 0) + if ((ret_value = H5F_get_id(loc.oloc->file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID") } @@ -2105,7 +2056,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_get_file_id() */ - /*------------------------------------------------------------------------- * Function: H5I__id_dump_cb * @@ -2118,9 +2068,9 @@ done: static int H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ - H5G_name_t *path = NULL; /* Path to file object */ + H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ + H5G_name_t * path = NULL; /* Path to file object */ FUNC_ENTER_STATIC_NOERR @@ -2130,18 +2080,15 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) /* Get the group location, so we get get the name */ switch (type) { - case H5I_GROUP: - { + case H5I_GROUP: { path = H5G_nameof((const H5G_t *)item->obj_ptr); break; } - case H5I_DATASET: - { + case H5I_DATASET: { path = H5D_nameof((const H5D_t *)item->obj_ptr); break; } - case H5I_DATATYPE: - { + case H5I_DATATYPE: { path = H5T_nameof((const H5T_t *)item->obj_ptr); break; } @@ -2159,7 +2106,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) case H5I_ERROR_STACK: case H5I_NTYPES: default: - break; /* Other types of IDs are not stored in files */ + break; /* Other types of IDs are not stored in files */ } if (path) { @@ -2172,7 +2119,6 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* end H5I__id_dump_cb() */ - /*------------------------------------------------------------------------- * Function: H5I_dump_ids_for_type * @@ -2185,14 +2131,14 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) herr_t H5I_dump_ids_for_type(H5I_type_t type) { - H5I_id_type_t *type_ptr = NULL; + H5I_id_type_t *type_ptr = NULL; FUNC_ENTER_NOAPI_NOERR HDfprintf(stderr, "Dumping ID type %d\n", (int)type); type_ptr = H5I_id_type_list_g[type]; - if(type_ptr) { + if (type_ptr) { /* Header */ HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); @@ -2201,7 +2147,7 @@ H5I_dump_ids_for_type(H5I_type_t type) HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid); /* List */ - if(type_ptr->id_count > 0) { + if (type_ptr->id_count > 0) { HDfprintf(stderr, " List:\n"); H5SL_iterate(type_ptr->ids, H5I__id_dump_cb, &type); } @@ -2211,4 +2157,3 @@ H5I_dump_ids_for_type(H5I_type_t type) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5I_dump_ids_for_type() */ - |