summaryrefslogtreecommitdiffstats
path: root/src/H5I.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5I.c')
-rw-r--r--src/H5I.c102
1 files changed, 12 insertions, 90 deletions
diff --git a/src/H5I.c b/src/H5I.c
index e4958aa..46fd076 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -64,8 +64,8 @@
/* 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 */
@@ -81,9 +81,8 @@ typedef struct H5I_id_info_t {
typedef struct {
const H5I_class_t *cls; /* Pointer to ID class */
unsigned init_count; /* # of times this type has been initialized*/
- hbool_t wrapped; /* Whether the id count has wrapped around */
- unsigned id_count; /* Current number of IDs held */
- unsigned nextid; /* ID to use for the next atom */
+ 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;
@@ -93,11 +92,6 @@ typedef struct {
void *ret_obj; /* Object to return */
} H5I_search_ud_t;
-/* User data for iterator callback when IDs have wrapped */
-typedef struct {
- unsigned nextid; /* Next ID to expect */
-} H5I_wrap_ud_t;
-
/* User data for iterator callback for ID iteration */
typedef struct {
H5I_search_func_t user_func; /* 'User' function to invoke */
@@ -340,7 +334,6 @@ H5I_register_type(const H5I_class_t *cls)
/* Initialize the ID type structure for new types */
if(type_ptr->init_count == 0) {
type_ptr->cls = cls;
- type_ptr->wrapped = FALSE;
type_ptr->id_count = 0;
type_ptr->nextid = cls->reserved;
if(NULL == (type_ptr->ids = H5SL_create(H5SL_TYPE_HID, NULL)))
@@ -435,12 +428,12 @@ H5Inmembers(H5I_type_t type, hsize_t *num_members)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "supplied type does not exist")
if(num_members) {
- int members;
+ int64_t members;
if((members = H5I_nmembers(type)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTCOUNT, FAIL, "can't compute number of members")
- *num_members = (hsize_t)members;
+ H5_ASSIGN_OVERFLOW(*num_members, members, int64_t, hsize_t);
} /* end if */
done:
@@ -463,7 +456,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-int
+int64_t
H5I_nmembers(H5I_type_t type)
{
H5I_id_type_t *type_ptr = NULL;
@@ -477,7 +470,7 @@ H5I_nmembers(H5I_type_t type)
HGOTO_DONE(0);
/* Set return value */
- H5_ASSIGN_OVERFLOW(ret_value, type_ptr->id_count, unsigned, int);
+ H5_ASSIGN_OVERFLOW(ret_value, type_ptr->id_count, uint64_t, int64_t);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -734,47 +727,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5I__wrapped_cb
- *
- * Purpose: Callback for searching for next free ID, when IDs have wrapped
- *
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * Thursday, October 3, 2013
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5I__wrapped_cb(void *_item, void UNUSED *_key, void *_udata)
-{
- H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */
- H5I_wrap_ud_t *udata = (H5I_wrap_ud_t *)_udata; /* Pointer to user data */
- int ret_value = H5_ITER_CONT; /* Return value */
-
- FUNC_ENTER_STATIC_NOERR
-
- /* Sanity check */
- HDassert(item);
- HDassert(udata);
-
- /* Break out if we see a free ID */
- if(udata->nextid != item->id) {
- /* Sanity check */
- HDassert(item->id > udata->nextid);
-
- ret_value = H5_ITER_STOP;
- } /* end if */
- else
- /* Increment to expect the next ID */
- udata->nextid++;
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5I__wrapped_cb() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5I_register
*
* Purpose: Registers an OBJECT in a TYPE and returns an ID for it.
@@ -825,38 +777,9 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref)
type_ptr->nextid++;
/*
- * This next section of code checks for the 'nextid' getting too large and
- * wrapping around, thus necessitating checking for duplicate IDs being
- * handed out.
+ * Sanity check for the 'nextid' getting too large and wrapping around.
*/
- if(type_ptr->nextid > (unsigned)ID_MASK)
- type_ptr->wrapped = TRUE;
-
- /*
- * If we've wrapped around then we need to check for duplicate id's being
- * handed out.
- */
- if(type_ptr->wrapped) {
- H5I_wrap_ud_t udata; /* User data for iteration */
- herr_t iter_status; /* Iteration status */
-
- /* Set up user data for iteration */
- udata.nextid = type_ptr->cls->reserved;
-
- /* Iterate over all the ID nodes, looking for a gap in the ID sequence */
- if((iter_status = H5SL_iterate(type_ptr->ids, H5I__wrapped_cb, &udata)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "ID iteration failed")
-
- /* If we didn't break out of the iteration and we're at the max. ID, we've used all the IDs */
- if(0 == iter_status && udata.nextid >= ID_MASK)
- HGOTO_ERROR(H5E_ATOM, H5E_NOIDS, FAIL, "no IDs available in type")
-
- /* Sanity check */
- HDassert(udata.nextid < ID_MASK);
-
- /* Retain the next ID for the class */
- type_ptr->nextid = udata.nextid;
- } /* end if */
+ HDassert(type_ptr->nextid <= ID_MASK);
/* Set return value */
ret_value = new_id;
@@ -2394,9 +2317,8 @@ H5I__debug(H5I_type_t type)
/* Header */
fprintf(stderr, " init_count = %u\n", type_ptr->init_count);
fprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved);
- fprintf(stderr, " wrapped = %u\n", type_ptr->wrapped);
- fprintf(stderr, " id_count = %u\n", type_ptr->id_count);
- fprintf(stderr, " nextid = %u\n", type_ptr->nextid);
+ fprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count);
+ fprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid);
/* List */
fprintf(stderr, " List:\n");