diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2015-08-12 20:47:00 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2015-08-12 20:47:00 (GMT) |
commit | bca9b8f33193f30d2b5e38d60d1404c9959d1928 (patch) | |
tree | 927b1382c8af535f2e562a3c45eebb957ad00009 | |
parent | e24071fd408b235953a5dd363312c897c07c8b23 (diff) | |
download | hdf5-bca9b8f33193f30d2b5e38d60d1404c9959d1928.zip hdf5-bca9b8f33193f30d2b5e38d60d1404c9959d1928.tar.gz hdf5-bca9b8f33193f30d2b5e38d60d1404c9959d1928.tar.bz2 |
[svn-r27502] Port r26961 from trunk to 1.8 branch.
Tested: jam, koala, ostrich (h5committest)
Log from r26961:
Description:
Clean up H5I code, to eliminate duplicated sections of code.
Tested on:
Mac OSX/64 10.10.3 (amazon) w/serial & parallel
(Too minor to require h5committest)
-rw-r--r-- | src/H5I.c | 65 |
1 files changed, 17 insertions, 48 deletions
@@ -643,15 +643,9 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) /* Check if we should delete this node or not */ if(delete_node) { - /* Decrement the number of IDs in the type */ - (type_ptr->id_count)--; - - /* Remove the node from the list */ - if(NULL == H5SL_remove(type_ptr->ids, &cur->id)) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't remove ID node from skip list") - - /* Free the node */ - cur = H5FL_FREE(H5I_id_info_t, cur); + /* Remove the node from the type */ + if(NULL == H5I__remove_common(type_ptr, cur->id)) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't remove ID node") } /* end if */ } /* end for */ @@ -1389,8 +1383,6 @@ done: int H5I_dec_ref(hid_t id) { - H5I_type_t type; /*type the object is in*/ - H5I_id_type_t *type_ptr; /*ptr to the type */ H5I_id_info_t *id_ptr; /*ptr to the new ID */ int ret_value; /* Return value */ @@ -1399,17 +1391,9 @@ H5I_dec_ref(hid_t id) /* Sanity check */ HDassert(id >= 0); - /* Check arguments */ - type = H5I_TYPE(id); - if(type <= H5I_BADID || type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - type_ptr = H5I_id_type_list_g[type]; - if(NULL == type_ptr || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - /* General lookup of the ID */ - if(NULL == (id_ptr = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + if(NULL == (id_ptr = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") /* * If this is the last reference to the object then invoke the type's @@ -1427,6 +1411,11 @@ H5I_dec_ref(hid_t id) * 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 */ + + /* 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) { /* Remove the node from the type */ @@ -1590,8 +1579,6 @@ done: int H5I_inc_ref(hid_t id, hbool_t app_ref) { - H5I_type_t type; /*type the object is in*/ - H5I_id_type_t *type_ptr; /*ptr to the type */ H5I_id_info_t *id_ptr; /*ptr to the ID */ int ret_value; /* Return value */ @@ -1600,16 +1587,8 @@ H5I_inc_ref(hid_t id, hbool_t app_ref) /* Sanity check */ HDassert(id >= 0); - /* Check arguments */ - type = H5I_TYPE(id); - if(type <= H5I_BADID || 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 || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - /* General lookup of the ID */ - if(NULL == (id_ptr = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id))) + if(NULL == (id_ptr = H5I__find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") /* Adjust reference counts */ @@ -1675,8 +1654,6 @@ done: int H5I_get_ref(hid_t id, hbool_t app_ref) { - H5I_type_t type; /*type the object is in*/ - H5I_id_type_t *type_ptr; /*ptr to the type */ H5I_id_info_t *id_ptr; /*ptr to the ID */ int ret_value; /* Return value */ @@ -1685,16 +1662,8 @@ H5I_get_ref(hid_t id, hbool_t app_ref) /* Sanity check */ HDassert(id >= 0); - /* Check arguments */ - type = H5I_TYPE(id); - if(type <= H5I_BADID || 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 || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - /* General lookup of the ID */ - if(NULL == (id_ptr = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id))) + if(NULL == (id_ptr = H5I__find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") /* Set return value */ @@ -2197,20 +2166,20 @@ done: static H5I_id_info_t * H5I__find_id(hid_t id) { - H5I_id_type_t *type_ptr; /*ptr to the type */ H5I_type_t type; /*ID's type */ + H5I_id_type_t *type_ptr; /*ptr to the type */ H5I_id_info_t *ret_value; /*return value */ FUNC_ENTER_STATIC_NOERR /* Check arguments */ type = H5I_TYPE(id); - if (type <= H5I_BADID || type >= H5I_next_type) - HGOTO_DONE(NULL); + if(type <= H5I_BADID || type >= H5I_next_type) + HGOTO_DONE(NULL) type_ptr = H5I_id_type_list_g[type]; - if (!type_ptr || type_ptr->init_count <= 0) - HGOTO_DONE(NULL); + if(!type_ptr || type_ptr->init_count <= 0) + HGOTO_DONE(NULL) /* Locate the ID node for the ID */ ret_value = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id); |