summaryrefslogtreecommitdiffstats
path: root/src/H5I.c
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2015-05-11 19:11:04 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2015-05-11 19:11:04 (GMT)
commit5520ff138ca79bb5aa46146908773c910f767554 (patch)
treec9ea17f4530c1eade235ea077f179d3557042233 /src/H5I.c
parentc3218d9f39ec281506251c2c6ba0b395adfa9013 (diff)
parent67ba6cb57d84dd34c69930d469ae445697b49731 (diff)
downloadhdf5-5520ff138ca79bb5aa46146908773c910f767554.zip
hdf5-5520ff138ca79bb5aa46146908773c910f767554.tar.gz
hdf5-5520ff138ca79bb5aa46146908773c910f767554.tar.bz2
[svn-r27050] merge from trunk.
Diffstat (limited to 'src/H5I.c')
-rw-r--r--src/H5I.c71
1 files changed, 20 insertions, 51 deletions
diff --git a/src/H5I.c b/src/H5I.c
index e3a5d15..74e154b 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -451,7 +451,7 @@ H5Inmembers(H5I_type_t type, hsize_t *num_members)
if((members = H5I_nmembers(type)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTCOUNT, FAIL, "can't compute number of members")
- H5_ASSIGN_OVERFLOW(*num_members, members, int64_t, hsize_t);
+ H5_CHECKED_ASSIGN(*num_members, hsize_t, members, int64_t);
} /* end if */
done:
@@ -478,7 +478,7 @@ int64_t
H5I_nmembers(H5I_type_t type)
{
H5I_id_type_t *type_ptr = NULL;
- int ret_value;
+ int64_t ret_value;
FUNC_ENTER_NOAPI(FAIL)
@@ -488,7 +488,7 @@ H5I_nmembers(H5I_type_t type)
HGOTO_DONE(0);
/* Set return value */
- H5_ASSIGN_OVERFLOW(ret_value, type_ptr->id_count, uint64_t, int64_t);
+ H5_CHECKED_ASSIGN(ret_value, int64_t, type_ptr->id_count, uint64_t);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -611,15 +611,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 */
@@ -1226,8 +1220,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 */
@@ -1236,17 +1228,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
@@ -1264,6 +1248,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 */
@@ -1427,8 +1416,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 */
@@ -1437,16 +1424,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 */
@@ -1512,8 +1491,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 */
@@ -1522,16 +1499,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 */
@@ -2114,20 +2083,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);