diff options
author | Vailin Choi <vchoi@hdfgroup.org> | 2013-10-21 21:48:48 (GMT) |
---|---|---|
committer | Vailin Choi <vchoi@hdfgroup.org> | 2013-10-21 21:48:48 (GMT) |
commit | f09d3e86b3753ea6c6b2c855248481b0b3581ac4 (patch) | |
tree | 72581aae0e194e991e8281bf315afdf7ae401122 /src | |
parent | 2b18e934c6812fd1b487ebfebf9240b009c3e4ae (diff) | |
download | hdf5-f09d3e86b3753ea6c6b2c855248481b0b3581ac4.zip hdf5-f09d3e86b3753ea6c6b2c855248481b0b3581ac4.tar.gz hdf5-f09d3e86b3753ea6c6b2c855248481b0b3581ac4.tar.bz2 |
[svn-r24337] Bring revisions #24200 - #24333 from trunk.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5.c | 2 | ||||
-rw-r--r-- | src/H5A.c | 1 | ||||
-rw-r--r-- | src/H5ACprivate.h | 3 | ||||
-rw-r--r-- | src/H5B2cache.c | 6 | ||||
-rw-r--r-- | src/H5Dint.c | 1 | ||||
-rw-r--r-- | src/H5E.c | 3 | ||||
-rw-r--r-- | src/H5F.c | 22 | ||||
-rw-r--r-- | src/H5FD.c | 1 | ||||
-rw-r--r-- | src/H5FS.c | 6 | ||||
-rw-r--r-- | src/H5FSdbg.c | 2 | ||||
-rw-r--r-- | src/H5FSpkg.h | 6 | ||||
-rw-r--r-- | src/H5FSprivate.h | 6 | ||||
-rw-r--r-- | src/H5FSsection.c | 2 | ||||
-rw-r--r-- | src/H5G.c | 1 | ||||
-rw-r--r-- | src/H5Gint.c | 2 | ||||
-rw-r--r-- | src/H5Gname.c | 4 | ||||
-rw-r--r-- | src/H5HFpkg.h | 2 | ||||
-rw-r--r-- | src/H5HFspace.c | 2 | ||||
-rw-r--r-- | src/H5HGcache.c | 2 | ||||
-rw-r--r-- | src/H5I.c | 775 | ||||
-rw-r--r-- | src/H5Iprivate.h | 5 | ||||
-rw-r--r-- | src/H5Pfapl.c | 2 | ||||
-rw-r--r-- | src/H5Pint.c | 2 | ||||
-rw-r--r-- | src/H5R.c | 1 | ||||
-rw-r--r-- | src/H5S.c | 1 | ||||
-rw-r--r-- | src/H5SL.c | 43 | ||||
-rw-r--r-- | src/H5SLprivate.h | 1 | ||||
-rw-r--r-- | src/H5T.c | 1 | ||||
-rw-r--r-- | src/H5detect.c | 4 | ||||
-rw-r--r-- | src/H5private.h | 3 | ||||
-rw-r--r-- | src/H5public.h | 6 | ||||
-rw-r--r-- | src/H5system.c | 4 | ||||
-rw-r--r-- | src/H5win32defs.h | 2 | ||||
-rw-r--r-- | src/Makefile.in | 2 |
34 files changed, 450 insertions, 476 deletions
@@ -722,7 +722,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) HDsnprintf(lib_str, sizeof(lib_str), "HDF5 library version: %d.%d.%d", H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); if(*substr) { - HDstrncat(lib_str, "-", 1); + HDstrncat(lib_str, "-", (size_t)1); HDstrncat(lib_str, substr, (sizeof(lib_str) - HDstrlen(lib_str)) - 1); } /* end if */ if (HDstrcmp(lib_str, H5_lib_vers_info_g)){ @@ -95,7 +95,6 @@ H5FL_BLK_DEFINE(attr_buf); static const H5I_class_t H5I_ATTR_CLS[1] = {{ H5I_ATTR, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ (H5I_free_t)H5A_close /* Callback routine for closing objects of this class */ }}; diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 2f26094..5238b92 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -358,8 +358,7 @@ H5_DLL herr_t H5AC_insert_entry(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *typ H5_DLL herr_t H5AC_pin_protected_entry(void *thing); H5_DLL herr_t H5AC_create_flush_dependency(void *parent_thing, void *child_thing); H5_DLL void * H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, - haddr_t addr, void *udata, - H5AC_protect_t rw); + haddr_t addr, void *udata, H5AC_protect_t rw); H5_DLL herr_t H5AC_resize_entry(void *thing, size_t new_size); H5_DLL herr_t H5AC_unpin_entry(void *thing); H5_DLL herr_t H5AC_destroy_flush_dependency(void *parent_thing, void *child_thing); diff --git a/src/H5B2cache.c b/src/H5B2cache.c index d06d9c0..eb69e01 100644 --- a/src/H5B2cache.c +++ b/src/H5B2cache.c @@ -196,12 +196,12 @@ H5B2__cache_hdr_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Magic number */ if(HDmemcmp(p, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree header signature") + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree header signature") p += H5_SIZEOF_MAGIC; /* Version */ if(*p++ != H5B2_HDR_VERSION) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree header version") + HGOTO_ERROR(H5E_BTREE, H5E_BADRANGE, NULL, "wrong B-tree header version") /* B-tree class */ id = (H5B2_subid_t)*p++; @@ -613,7 +613,7 @@ H5B2__cache_internal_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata) /* Magic number */ if(HDmemcmp(p, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree internal node signature") + HGOTO_ERROR(H5E_BTREE, H5E_BADVALUE, NULL, "wrong B-tree internal node signature") p += H5_SIZEOF_MAGIC; /* Version */ diff --git a/src/H5Dint.c b/src/H5Dint.c index ccb6707..cbab788 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -112,7 +112,6 @@ static H5D_shared_t H5D_def_dset; static const H5I_class_t H5I_DATASET_CLS[1] = {{ H5I_DATASET, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ (H5I_free_t)H5D_close /* Callback routine for closing objects of this class */ }}; @@ -123,7 +123,6 @@ H5FL_DEFINE_STATIC(H5E_msg_t); static const H5I_class_t H5I_ERRCLS_CLS[1] = {{ H5I_ERROR_CLASS, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ (H5I_free_t)H5E_unregister_class /* Callback routine for closing objects of this class */ }}; @@ -132,7 +131,6 @@ static const H5I_class_t H5I_ERRCLS_CLS[1] = {{ static const H5I_class_t H5I_ERRMSG_CLS[1] = {{ H5I_ERROR_MSG, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ (H5I_free_t)H5E_close_msg /* Callback routine for closing objects of this class */ }}; @@ -141,7 +139,6 @@ static const H5I_class_t H5I_ERRMSG_CLS[1] = {{ static const H5I_class_t H5I_ERRSTK_CLS[1] = {{ H5I_ERROR_STACK, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ (H5I_free_t)H5E_close_stack /* Callback routine for closing objects of this class */ }}; @@ -109,7 +109,6 @@ H5FL_DEFINE(H5F_file_t); static const H5I_class_t H5I_FILE_CLS[1] = {{ H5I_FILE, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ (H5I_free_t)H5F_close /* Callback routine for closing objects of this class */ }}; @@ -667,6 +666,13 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) HDassert(obj_ptr); HDassert(olist); + /* Check if we've filled up the array. Return TRUE only if + * we have filled up the array. Otherwise return FALSE(RET_VALUE is + * preset to FALSE) because H5I_iterate needs the return value of + * FALSE to continue the iteration. */ + if(olist->max_index>0 && olist->list_index>=olist->max_index) + HGOTO_DONE(TRUE) /* Indicate that the iterator should stop */ + /* Count file IDs */ if(olist->obj_type == H5I_FILE) { if((olist->file_info.local && @@ -682,13 +688,6 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) /* Increment the number of open objects */ if(olist->obj_id_count) (*olist->obj_id_count)++; - - /* Check if we've filled up the array. Return TRUE only if - * we have filled up the array. Otherwise return FALSE(RET_VALUE is - * preset to FALSE) because H5I_iterate needs the return value of - * FALSE to continue the iteration. */ - if(olist->max_index>0 && olist->list_index>=olist->max_index) - HGOTO_DONE(TRUE) /* Indicate that the iterator should stop */ } } /* end if */ else { /* either count opened object IDs or put the IDs on the list */ @@ -747,13 +746,6 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) /* Increment the number of open objects */ if(olist->obj_id_count) (*olist->obj_id_count)++; - - /* Check if we've filled up the array. Return TRUE only if - * we have filled up the array. Otherwise return FALSE(RET_VALUE is - * preset to FALSE) because H5I_iterate needs the return value of - * FALSE to continue iterating. */ - if(olist->max_index>0 && olist->list_index>=olist->max_index) - HGOTO_DONE(TRUE) /* Indicate that the iterator should stop */ } /* end if */ } /* end else */ @@ -106,7 +106,6 @@ static unsigned long H5FD_file_serial_no_g; static const H5I_class_t H5I_VFL_CLS[1] = {{ H5I_VFL, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ (H5I_free_t)H5FD_free_cls /* Callback routine for closing objects of this class */ }}; @@ -99,7 +99,7 @@ H5FL_DEFINE(H5FS_t); */ H5FS_t * H5FS_create(H5F_t *f, hid_t dxpl_id, haddr_t *fs_addr, const H5FS_create_t *fs_create, - size_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold) + uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold) { H5FS_t *fspace = NULL; /* New free space structure */ H5FS_t *ret_value; /* Return value */ @@ -181,7 +181,7 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d\n", FUNC, ret_value); *------------------------------------------------------------------------- */ H5FS_t * -H5FS_open(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, size_t nclasses, +H5FS_open(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold) { H5FS_t *fspace = NULL; /* New free space structure */ @@ -572,7 +572,7 @@ HDfprintf(stderr, "%s: Leaving, ret_value = %d, fspace->rc = %u\n", FUNC, ret_va *------------------------------------------------------------------------- */ H5FS_t * -H5FS_new(const H5F_t *f, size_t nclasses, const H5FS_section_class_t *classes[], +H5FS_new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata) { H5FS_t *fspace = NULL; /* Free space manager */ diff --git a/src/H5FSdbg.c b/src/H5FSdbg.c index c1c8c29..44b4ac0 100644 --- a/src/H5FSdbg.c +++ b/src/H5FSdbg.c @@ -143,7 +143,7 @@ H5FS_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fspace->ghost_sect_count); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Number of free space section classes:", - fspace->nclasses); + (unsigned)fspace->nclasses); HDfprintf(stream, "%*s%-*s %u%%\n", indent, "", fwidth, "Shrink percent:", fspace->shrink_percent); diff --git a/src/H5FSpkg.h b/src/H5FSpkg.h index d914e8e..93fa485 100644 --- a/src/H5FSpkg.h +++ b/src/H5FSpkg.h @@ -96,7 +96,7 @@ /* Callback info for loading a free space header into the cache */ typedef struct H5FS_hdr_cache_ud_t { H5F_t *f; /* File that free space header is within */ - size_t nclasses; /* Number of section classes */ + uint16_t nclasses; /* Number of section classes */ const H5FS_section_class_t **classes; /* Array of section class info */ void *cls_init_udata; /* Pointer to class init user data */ haddr_t addr; /* Address of header */ @@ -163,7 +163,7 @@ struct H5FS_t { /* Creation parameters */ H5FS_client_t client; /* Type of user of this free space manager */ - unsigned nclasses; /* Number of section classes handled */ + uint16_t nclasses; /* Number of section classes handled */ unsigned shrink_percent; /* Percent of "normal" serialized size to shrink serialized space at */ unsigned expand_percent; /* Percent of "normal" serialized size to expand serialized space at */ unsigned max_sect_addr; /* Size of address space free sections are within (log2 of actual value) */ @@ -228,7 +228,7 @@ H5_DLL herr_t H5FS__destroy_flush_depend(H5AC_info_t *parent_entry, H5AC_info_t *child_entry); /* Free space manager header routines */ -H5_DLL H5FS_t *H5FS_new(const H5F_t *f, size_t nclasses, +H5_DLL H5FS_t *H5FS_new(const H5F_t *f, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata); H5_DLL herr_t H5FS_incr(H5FS_t *fspace); H5_DLL herr_t H5FS_decr(H5FS_t *fspace); diff --git a/src/H5FSprivate.h b/src/H5FSprivate.h index 48fb6d0..2dacce6 100644 --- a/src/H5FSprivate.h +++ b/src/H5FSprivate.h @@ -174,10 +174,10 @@ H5FL_SEQ_EXTERN(H5FS_section_class_t); /* Free space manager routines */ H5_DLL H5FS_t *H5FS_create(H5F_t *f, hid_t dxpl_id, haddr_t *fs_addr, - const H5FS_create_t *fs_create, size_t nclasses, + const H5FS_create_t *fs_create, uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold); H5_DLL H5FS_t *H5FS_open(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr, - size_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold); + uint16_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata, hsize_t alignment, hsize_t threshold); H5_DLL herr_t H5FS_size(const H5F_t *f, const H5FS_t *fspace, hsize_t *meta_size); H5_DLL herr_t H5FS_delete(H5F_t *f, hid_t dxpl_id, haddr_t fs_addr); H5_DLL herr_t H5FS_close(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace); @@ -202,7 +202,7 @@ H5_DLL herr_t H5FS_sect_iterate(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, H5FS_op H5_DLL herr_t H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects); H5_DLL herr_t H5FS_sect_change_class(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, - H5FS_section_info_t *sect, unsigned new_class); + H5FS_section_info_t *sect, uint16_t new_class); H5_DLL htri_t H5FS_sect_try_shrink_eoa(const H5F_t *f, hid_t dxpl_id, const H5FS_t *fspace, void *op_data); H5_DLL herr_t H5FS_sect_query_last_sect(const H5FS_t *fspace, haddr_t *sect_addr, hsize_t *sect_size); diff --git a/src/H5FSsection.c b/src/H5FSsection.c index faa2b2a..baf7403 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -2023,7 +2023,7 @@ H5FS_sect_stats(const H5FS_t *fspace, hsize_t *tot_space, hsize_t *nsects) */ herr_t H5FS_sect_change_class(H5F_t *f, hid_t dxpl_id, H5FS_t *fspace, - H5FS_section_info_t *sect, unsigned new_class) + H5FS_section_info_t *sect, uint16_t new_class) { const H5FS_section_class_t *old_cls; /* Old class of section */ const H5FS_section_class_t *new_cls; /* New class of section */ @@ -134,7 +134,6 @@ static const H5I_class_t H5I_GROUP_CLS[1] = {{ H5I_GROUP, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ (H5I_free_t)H5G_close /* Callback routine for closing objects of this class */ }}; diff --git a/src/H5Gint.c b/src/H5Gint.c index fe8b995..6f42cc2 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -992,7 +992,7 @@ H5G_visit_cb(const H5O_link_t *lnk, void *_udata) /* Add the path separator to the current path */ HDassert(udata->path[udata->curr_path_len] == '\0'); - HDstrncpy(&(udata->path[udata->curr_path_len]), "/", 2); + HDstrncpy(&(udata->path[udata->curr_path_len]), "/", (size_t)2); udata->curr_path_len++; /* Attempt to get the link info for this group */ diff --git a/src/H5Gname.c b/src/H5Gname.c index 1d2644b..bbeddb6 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -325,7 +325,7 @@ H5G_build_fullpath(const char *prefix, const char *name) /* Build full path */ HDstrncpy(full_path, prefix, orig_path_len + 1); if(need_sep) - HDstrncat(full_path, "/", 1); + HDstrncat(full_path, "/", (size_t)1); HDstrncat(full_path, name, name_len); /* Create reference counted string for path */ @@ -1331,7 +1331,7 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t * /* If there's a buffer provided, copy into it, up to the limit of its size */ if(name) { /* Copy the initial path separator */ - HDstrncpy(name, "/", 2); + HDstrncpy(name, "/", (size_t)2); /* Append the rest of the path */ /* (less one character, for the initial path separator) */ diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 1252b9c..99571f5 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -761,7 +761,7 @@ H5_DLL herr_t H5HF_space_remove(H5HF_hdr_t *hdr, hid_t dxpl_id, H5_DLL herr_t H5HF_space_close(H5HF_hdr_t *hdr, hid_t dxpl_id); H5_DLL herr_t H5HF_space_delete(H5HF_hdr_t *hdr, hid_t dxpl_id); H5_DLL herr_t H5HF_space_sect_change_class(H5HF_hdr_t *hdr, hid_t dxpl_id, - H5HF_free_section_t *sect, unsigned new_class); + H5HF_free_section_t *sect, uint16_t new_class); /* Free space section routines */ H5_DLL H5HF_free_section_t *H5HF_sect_single_new(hsize_t sect_off, diff --git a/src/H5HFspace.c b/src/H5HFspace.c index 01330d3..577d3b8 100644 --- a/src/H5HFspace.c +++ b/src/H5HFspace.c @@ -613,7 +613,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HF_space_sect_change_class(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sect, unsigned new_class) +H5HF_space_sect_change_class(H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_free_section_t *sect, uint16_t new_class) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5HGcache.c b/src/H5HGcache.c index afb2a75..4e3f568 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -184,7 +184,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata) * assume that it's free space. */ HDassert(NULL == heap->obj[0].begin); - heap->obj[0].size = ((const uint8_t *)heap->chunk + heap->size) - p; + heap->obj[0].size = (size_t)(((const uint8_t *)heap->chunk + heap->size) - p); heap->obj[0].begin = p; p += heap->obj[0].size; } /* end if */ @@ -48,6 +48,7 @@ #include "H5Ipkg.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ +#include "H5SLprivate.h" /* Skip Lists */ /* Define this to compile in support for dumping ID information */ /* #define H5I_DEBUG_OUTPUT */ @@ -62,25 +63,6 @@ /* Local Macros */ -/* - * Define the following macro for fast hash calculations (but limited - * hash sizes) - */ -#define HASH_SIZE_POWER_2 - -#ifdef HASH_SIZE_POWER_2 -/* - * Map an ID to a hash location (assumes s is a power of 2 and smaller - * than the ID_MASK constant). - */ -# define H5I_LOC(a,s) ((hid_t)((size_t)(a)&((s)-1))) -#else -/* - * Map an ID to a hash location. - */ -# define H5I_LOC(a,s) (((hid_t)(a)&ID_MASK)%(s)) -#endif - /* 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)) @@ -93,17 +75,16 @@ typedef struct H5I_id_info_t { 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 */ - struct H5I_id_info_t *next; /* link to next atom (in case of hash-clash)*/ } H5I_id_info_t; /* ID type structure used */ typedef struct { const H5I_class_t *cls; /* Pointer to ID class */ - unsigned count; /* # of times this type has been initialized*/ - unsigned wrapped; /* Whether the id count has wrapped around */ - unsigned ids; /* Current number of IDs held */ + 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 */ - H5I_id_info_t **id_list; /* Pointer to an array of ptrs to IDs */ + H5SL_t *ids; /* Pointer to skip list that stores IDs */ } H5I_id_type_t; typedef struct { @@ -112,6 +93,18 @@ 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 */ + 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; + /*-------------------- Locally scoped variables -----------------------------*/ /* Array of pointers to atomic types */ @@ -135,10 +128,14 @@ H5FL_DEFINE_STATIC(H5I_id_type_t); H5FL_DEFINE_STATIC(H5I_class_t); /*--------------------- Local function prototypes ---------------------------*/ -static H5I_id_info_t *H5I_find_id(hid_t id); -static int H5I_search_cb(void *obj, hid_t id, 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 H5I_id_info_t *H5I__find_id(hid_t id); #ifdef H5I_DEBUG_OUTPUT -static herr_t H5I_debug(H5I_type_t type); +static herr_t H5I__debug(H5I_type_t type); #endif /* H5I_DEBUG_OUTPUT */ @@ -191,7 +188,7 @@ H5I_term_interface(void) if(H5_interface_initialize_g) { /* How many types are still being used? */ for(type = (H5I_type_t)0; type < H5I_next_type; H5_INC_ENUM(H5I_type_t, type)) { - if((type_ptr = H5I_id_type_list_g[type]) && type_ptr->id_list) + if((type_ptr = H5I_id_type_list_g[type]) && type_ptr->ids) n++; } /* end for */ @@ -200,7 +197,7 @@ H5I_term_interface(void) for(type = (H5I_type_t)0; type < H5I_next_type; H5_INC_ENUM(H5I_type_t,type)) { type_ptr = H5I_id_type_list_g[type]; if(type_ptr) { - HDassert(NULL == type_ptr->id_list); + HDassert(NULL == type_ptr->ids); type_ptr = H5FL_FREE(H5I_id_type_t, type_ptr); H5I_id_type_list_g[type] = NULL; } /* end if */ @@ -279,7 +276,6 @@ H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func) /* Initialize class fields */ cls->type_id = new_type; cls->flags = H5I_CLASS_IS_APPLICATION; - cls->hash_size = hash_size; cls->reserved = reserved; cls->free_func = free_func; @@ -330,13 +326,6 @@ H5I_register_type(const H5I_class_t *cls) HDassert(cls->type_id > 0 && cls->type_id < H5I_MAX_NUM_TYPES); /* Initialize the type */ - - /* Check arguments */ -#ifdef HASH_SIZE_POWER_2 - if(!POWER_OF_TWO(cls->hash_size) || cls->hash_size == 1) - HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "invalid hash size") -#endif /* HASH_SIZE_POWER_2 */ - 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))) @@ -349,24 +338,23 @@ H5I_register_type(const H5I_class_t *cls) } /* end else */ /* Initialize the ID type structure for new types */ - if(type_ptr->count == 0) { + if(type_ptr->init_count == 0) { type_ptr->cls = cls; - type_ptr->wrapped = 0; - type_ptr->ids = 0; + type_ptr->wrapped = FALSE; + type_ptr->id_count = 0; type_ptr->nextid = cls->reserved; - type_ptr->id_list = (H5I_id_info_t **)H5MM_calloc(cls->hash_size * sizeof(H5I_id_info_t *)); - if(NULL == type_ptr->id_list) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_BADID, "memory allocation failed") + if(NULL == (type_ptr->ids = H5SL_create(H5SL_TYPE_HID, NULL))) + HGOTO_ERROR(H5E_ATOM, H5E_CANTCREATE, FAIL, "skip list creation failed") } /* end if */ /* Increment the count of the times this type has been initialized */ - type_ptr->count++; + type_ptr->init_count++; done: if(ret_value < 0) { /* Clean up on error */ if(type_ptr) { - if(type_ptr->id_list) - H5MM_xfree(type_ptr->id_list); + if(type_ptr->ids) + H5SL_close(type_ptr->ids); (void)H5FL_FREE(H5I_id_type_t, type_ptr); } /* end if */ } /* end if */ @@ -485,11 +473,11 @@ H5I_nmembers(H5I_type_t type) if(type <= H5I_BADID || 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->count <= 0) + if(NULL == (type_ptr = H5I_id_type_list_g[type]) || type_ptr->init_count <= 0) HGOTO_DONE(0); /* Set return value */ - H5_ASSIGN_OVERFLOW(ret_value, type_ptr->ids, unsigned, int); + H5_ASSIGN_OVERFLOW(ret_value, type_ptr->id_count, unsigned, int); done: FUNC_LEAVE_NOAPI(ret_value) @@ -542,32 +530,14 @@ done: * Programmer: Robb Matzke * Wednesday, March 24, 1999 * - * Modifications: - * Robb Matzke, 1999-04-27 - * If FORCE is zero then any item for which the free callback - * failed is not removed. This function returns failure if - * items could not be removed. - * - * Robb Matzke, 1999-08-17 - * If the object reference count is larger than one then it must - * be because the library is using the object internally. This - * happens for instance for file driver ID's which are stored in - * things like property lists, files, etc. Objects that have a - * reference count larger than one are not affected unless FORCE - * is non-zero. - * - * Neil Fortner, 2008-08-08 - * Added app_ref parameter. If app_ref is FALSE, then the - * application reference count is ignored (i.e. subtracted from - * the total reference count) when determining which id's to - * close. *------------------------------------------------------------------------- */ herr_t H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) { H5I_id_type_t *type_ptr; /* ptr to the atomic type */ - unsigned i; /* Local index variable */ + H5SL_node_t *curr_node; /* Current skip list node ptr */ + H5SL_node_t *next_node; /* Next skip list node ptr */ int ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -576,7 +546,7 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->count <= 0) + if(type_ptr == NULL || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* @@ -584,22 +554,21 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) * counts. Ignore the return value from from the free method and remove * object from type regardless if FORCE is non-zero. */ - for(i = 0; i < type_ptr->cls->hash_size; i++) { - H5I_id_info_t *cur; /* Current node being worked with */ - H5I_id_info_t *next; /* Next node in list */ - - for(cur = type_ptr->id_list[i]; cur; cur = next) { - hbool_t delete_node; /* Flag to indicate node should be removed from linked list */ - - /* - * Do nothing to the object if the reference count is larger than - * one and forcing is off. - */ - if(!force && (cur->count - (!app_ref * cur->app_count)) > 1) { - next = cur->next; - continue; - } /* end if */ + for(curr_node = H5SL_first(type_ptr->ids); curr_node; curr_node = next_node) { + H5I_id_info_t *cur; /* Current ID being worked with */ + hbool_t delete_node; /* Flag to indicate node should be removed from linked list */ + /* Get ID for this node */ + if(NULL == (cur = (H5I_id_info_t *)H5SL_item(curr_node))) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID info for node") + + /* + * Do nothing to the object if the reference count is larger than + * one and forcing is off. + */ + if(!force && (cur->count - (!app_ref * cur->app_count)) > 1) + delete_node = FALSE; + else { /* Check for a 'free' function and call it, if it exists */ /* (Casting away const OK -QAK) */ if(type_ptr->cls->free_func && (type_ptr->cls->free_func)((void *)cur->obj_ptr) < 0) { @@ -624,51 +593,23 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) /* Indicate node should be removed from list */ delete_node = TRUE; } /* end else */ + } /* end else */ - /* Check if we should delete this node or not */ - if(delete_node) { - H5I_id_info_t *last; /* Last node seen */ - H5I_id_info_t *tmp; /* Temporary node ptr */ - - /* Decrement the number of IDs in the type */ - (type_ptr->ids)--; - - /* Advance to next node */ - next = cur->next; - - /* Re-scan the list of nodes and remove the node from the list */ - /* (can't maintain static pointers to the previous node in the */ - /* list, because the node's 'free' callback could have */ - /* make an H5I call, which could potentially change the */ - /* order of the nodes on the list - QAK) */ - last = NULL; - tmp = type_ptr->id_list[i]; - while(tmp != cur) { - HDassert(tmp != NULL); - last = tmp; - tmp = tmp->next; - } /* end while */ - - /* Delete the node from the list */ - if(NULL == last) { - /* Node at head of list, just advance the list head to next node */ - HDassert(type_ptr->id_list[i] == cur); - type_ptr->id_list[i] = next; - } /* end if */ - else { - /* Node in middle of list, jump over it */ - HDassert(last->next == cur); - last->next = next; - } /* end else */ + /* Get the next node in the list */ + next_node = H5SL_next(curr_node); - /* Free the node */ - cur = H5FL_FREE(H5I_id_info_t, cur); - } /* end if */ - else { - /* Advance to next node */ - next = cur->next; - } /* end else */ - } /* end for */ + /* 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); + } /* end if */ } /* end for */ done: @@ -683,7 +624,7 @@ done: * regardless of their reference counts. Destroying IDs * involves calling the free-func for each ID's object and * then adding the ID struct to the ID free list. Public - * interface to H5I_destroy_type. + * interface to H5I__destroy_type. * * Return: Zero on success/Negative on failure * @@ -703,7 +644,7 @@ H5Idestroy_type(H5I_type_t 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); + ret_value = H5I__destroy_type(type); done: FUNC_LEAVE_API(ret_value) @@ -711,7 +652,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_destroy_type + * Function: H5I__destroy_type * * Purpose: Destroys a type along with all atoms in that type * regardless of their reference counts. Destroying IDs @@ -725,19 +666,19 @@ done: * *------------------------------------------------------------------------- */ -herr_t -H5I_destroy_type(H5I_type_t type) +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 */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC 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 == NULL || type_ptr->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 */ @@ -749,14 +690,16 @@ H5I_destroy_type(H5I_type_t type) if(type_ptr->cls->flags & H5I_CLASS_IS_APPLICATION) type_ptr->cls = H5FL_FREE(H5I_class_t, (void *)type_ptr->cls); - type_ptr->id_list = H5MM_xfree(type_ptr->id_list); + 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); H5I_id_type_list_g[type] = NULL; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_destroy_type() */ +} /* end H5I__destroy_type() */ /*------------------------------------------------------------------------- @@ -791,6 +734,47 @@ 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. @@ -806,13 +790,6 @@ done: * * Programmer: Unknown * - * Modifications: - * - * Neil Fortner, 7 Aug 2008 - * Added app_ref parameter and support for the app_count field, to - * distiguish between reference count from the library and from the - * application. - * *------------------------------------------------------------------------- */ hid_t @@ -821,10 +798,6 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) H5I_id_type_t *type_ptr; /*ptr to the type */ H5I_id_info_t *id_ptr; /*ptr to the new ID information */ hid_t new_id; /*new ID */ - unsigned hash_loc; /*new item's hash table location*/ - hid_t next_id; /*next ID to check */ - H5I_id_info_t *curr_id; /*ptr to the current atom */ - unsigned i; /*counter */ hid_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI(FAIL) @@ -833,7 +806,7 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) 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->count <= 0) + if(NULL == type_ptr || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") if(NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed") @@ -844,16 +817,11 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) id_ptr->count = 1; /*initial reference count*/ id_ptr->app_count = !!app_ref; id_ptr->obj_ptr = object; - id_ptr->next = NULL; - - /* hash bucket already full, prepend to front of chain */ - hash_loc = type_ptr->nextid % (unsigned)type_ptr->cls->hash_size; - if(type_ptr->id_list[hash_loc] != NULL) - id_ptr->next = type_ptr->id_list[hash_loc]; /* Insert into the type */ - type_ptr->id_list[hash_loc] = id_ptr; - type_ptr->ids++; + 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++; type_ptr->nextid++; /* @@ -861,47 +829,33 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) * wrapping around, thus necessitating checking for duplicate IDs being * handed out. */ - if(type_ptr->nextid > (unsigned)ID_MASK) { - type_ptr->wrapped = 1; - type_ptr->nextid = type_ptr->cls->reserved; - } /* end if */ + 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) { - /* - * Make sure we check all available ID's. If we're about at the end - * of the range then wrap around and check the beginning values. If - * we check all possible values and didn't find any free ones *then* - * we can fail. - */ - for(i = type_ptr->cls->reserved; i < ID_MASK; i++) { - /* Handle end of range by wrapping to beginning */ - if(type_ptr->nextid > (unsigned)ID_MASK) - type_ptr->nextid = type_ptr->cls->reserved; - - /* new ID to check for */ - next_id = H5I_MAKE(type, type_ptr->nextid); - hash_loc = (unsigned)H5I_LOC(type_ptr->nextid, type_ptr->cls->hash_size); - curr_id = type_ptr->id_list[hash_loc]; - if(curr_id == NULL) - break; /* Ha! this is not likely... */ - - while(curr_id) { - if(curr_id->id == next_id) - break; - curr_id = curr_id->next; - } /* end while */ - if(!curr_id) - break; /* must not have found a match */ - type_ptr->nextid++; - } /* end for */ - - if(i >= (unsigned)ID_MASK) - /* All the IDs are gone! */ + 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 */ /* Set return value */ @@ -937,7 +891,6 @@ H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t { H5I_id_type_t *type_ptr; /*ptr to the type */ H5I_id_info_t *id_ptr; /*ptr to the new ID information */ - unsigned hash_loc; /*new item's hash table location*/ hid_t ret_value = SUCCEED; /*return value */ FUNC_ENTER_NOAPI(FAIL) @@ -945,7 +898,7 @@ H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t /* Check arguments */ /* Make sure ID is not already in use */ - if(NULL != (id_ptr = H5I_find_id(id))) + if(NULL != (id_ptr = H5I__find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use?!") /* Make sure type number is valid */ @@ -955,7 +908,7 @@ H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t /* Get type pointer from list of types */ type_ptr = H5I_id_type_list_g[type]; - if(NULL == type_ptr || type_ptr->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 */ @@ -971,18 +924,11 @@ H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t id_ptr->count = 1; /*initial reference count*/ id_ptr->app_count = !!app_ref; id_ptr->obj_ptr = object; - id_ptr->next = NULL; - - /* determine hash bucket location to store id */ - hash_loc = id % (unsigned)type_ptr->cls->hash_size; - - /* hash bucket already full, prepend to front of chain */ - if(type_ptr->id_list[hash_loc] != NULL) - id_ptr->next = type_ptr->id_list[hash_loc]; /* Insert into the type */ - type_ptr->id_list[hash_loc] = id_ptr; - type_ptr->ids++; + 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++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1012,7 +958,7 @@ H5I_subst(hid_t id, const void *new_object) 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 */ @@ -1049,7 +995,7 @@ H5I_object(hid_t id) 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))) { /* Get the object pointer to return */ /* (Casting away const OK -QAK) */ ret_value = (void *)id_ptr->obj_ptr; @@ -1123,7 +1069,7 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) HDassert(id_type >= 1 && 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 */ /* (Casting away const OK -QAK) */ ret_value = (void *)id_ptr->obj_ptr; @@ -1205,7 +1151,7 @@ done: * * Purpose: Removes the specified ID from its type, first checking that the * type of the ID and the type type are the same. Public interface to - * H5I_remove_verify. + * H5I__remove_verify. * * Return: Success: A pointer to the object that was removed, the * same pointer which would have been found by @@ -1228,7 +1174,7 @@ H5Iremove_verify(hid_t id, H5I_type_t id_type) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") /* Remove the id */ - ret_value = H5I_remove_verify(id, id_type); + ret_value = H5I__remove_verify(id, id_type); done: FUNC_LEAVE_API(ret_value) @@ -1236,7 +1182,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_remove_verify + * Function: H5I__remove_verify * * Purpose: Removes the specified ID from its type, first checking that * the ID's type is the same as the ID type supplied as an argument @@ -1252,11 +1198,11 @@ done: *------------------------------------------------------------------------- */ void * -H5I_remove_verify(hid_t id, H5I_type_t id_type) +H5I__remove_verify(hid_t id, H5I_type_t id_type) { void * ret_value = NULL; /*return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_STATIC_NOERR /* Argument checking will be performed by H5I_remove() */ @@ -1264,10 +1210,50 @@ H5I_remove_verify(hid_t id, H5I_type_t id_type) if(id_type == H5I_TYPE(id)) ret_value = H5I_remove(id); -done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_remove_verify() */ +} /* end H5I__remove_verify() */ + + +/*------------------------------------------------------------------------- + * Function: H5I__remove_common + * + * Purpose: Common code to remove a specified ID from its type. + * + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL + * + * Programmer: Quincey Koziol + * October 3, 2013 + * + *------------------------------------------------------------------------- + */ +static void * +H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id) +{ + H5I_id_info_t *curr_id; /*ptr to the current atom */ + void * ret_value; /*return value */ + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(type_ptr); + + /* Get the ID node for the 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") + + /* (Casting away const OK -QAK) */ + ret_value = (void *)curr_id->obj_ptr; + curr_id = H5FL_FREE(H5I_id_info_t, curr_id); + + /* Decrement the number of IDs in the type */ + (type_ptr->id_count)--; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__remove_common() */ /*------------------------------------------------------------------------- @@ -1288,11 +1274,8 @@ void * H5I_remove(hid_t id) { H5I_id_type_t *type_ptr; /*ptr to the atomic type */ - H5I_id_info_t *curr_id; /*ptr to the current atom */ - H5I_id_info_t *last_id; /*ptr to the last atom */ H5I_type_t type; /*atom's atomic type */ - unsigned hash_loc; /*atom's hash table location */ - void * ret_value = NULL; /*return value */ + void * ret_value; /*return value */ FUNC_ENTER_NOAPI(NULL) @@ -1301,40 +1284,12 @@ H5I_remove(hid_t id) if(type <= H5I_BADID || 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->count <= 0) + if(type_ptr == NULL || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type") - /* Get the bucket in which the ID is located */ - hash_loc = (unsigned)H5I_LOC(id, type_ptr->cls->hash_size); - curr_id = type_ptr->id_list[hash_loc]; - if(NULL == curr_id) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "invalid ID") - - last_id = NULL; - while(curr_id != NULL) { - if(curr_id->id == id) - break; - last_id = curr_id; - curr_id = curr_id->next; - } /* end while */ - - if(curr_id != NULL) { - if(last_id == NULL) { - /* ID is the first in the chain */ - type_ptr->id_list[hash_loc] = curr_id->next; - } else { - last_id->next = curr_id->next; - } - /* (Casting away const OK -QAK) */ - ret_value = (void *)curr_id->obj_ptr; - curr_id = H5FL_FREE(H5I_id_info_t, curr_id); - } else { - /* couldn't find the ID in the proper place */ - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "invalid ID") - } - - /* Decrement the number of IDs in the type */ - (type_ptr->ids)--; + /* Remove the node from the type */ + 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) @@ -1412,11 +1367,11 @@ H5I_dec_ref(hid_t 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->count <= 0) + 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_find_id(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") /* @@ -1437,7 +1392,9 @@ H5I_dec_ref(hid_t id) if(1 == id_ptr->count) { /* (Casting away const OK -QAK) */ if(!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) { - H5I_remove(id); + /* Remove the node from the type */ + if(NULL == H5I__remove_common(type_ptr, id)) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't remove ID node") ret_value = 0; } /* end if */ else @@ -1485,7 +1442,7 @@ H5I_dec_app_ref(hid_t id) /* Check if the ID still exists */ 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, FAIL, "can't locate ID") /* Adjust app_ref */ @@ -1591,13 +1548,6 @@ done: * Programmer: Robb Matzke * Thursday, July 29, 1999 * - * Modifications: - * - * Neil Fortner, 7 Aug 2008 - * Added app_ref parameter and support for the app_count field, to - * distiguish between reference count from the library and from the - * application. - * *------------------------------------------------------------------------- */ int @@ -1618,11 +1568,11 @@ H5I_inc_ref(hid_t id, hbool_t app_ref) 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->count <= 0) + 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_find_id(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") /* Adjust reference counts */ @@ -1683,13 +1633,6 @@ done: * Programmer: Quincey Koziol * Saturday, Decemeber 6, 2003 * - * Modifications: - * - * Neil Fortner, 7 Aug 2008 - * Added app_ref parameter and support for the app_count field, to - * distiguish between reference count from the library and from the - * application. - * *------------------------------------------------------------------------- */ int @@ -1710,11 +1653,11 @@ H5I_get_ref(hid_t id, hbool_t app_ref) 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->count <= 0) + 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_find_id(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") /* Set return value */ @@ -1755,7 +1698,7 @@ H5Iinc_type_ref(H5I_type_t type) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "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, FAIL, "can't increment ID type ref count") done: @@ -1764,7 +1707,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_inc_type_ref + * Function: H5I__inc_type_ref * * Purpose: Increment the reference count for an ID type. * @@ -1777,13 +1720,13 @@ done: * *------------------------------------------------------------------------- */ -int -H5I_inc_type_ref(H5I_type_t type) +static int +H5I__inc_type_ref(H5I_type_t type) { H5I_id_type_t *type_ptr; /* ptr to the type */ int ret_value; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity check */ HDassert(type > 0 && type < H5I_next_type); @@ -1794,11 +1737,11 @@ H5I_inc_type_ref(H5I_type_t type) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* Set return value */ - ret_value = (int)(++(type_ptr->count)); + ret_value = (int)(++(type_ptr->init_count)); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_inc_type_ref() */ +} /* end H5I__inc_type_ref() */ /*------------------------------------------------------------------------- @@ -1873,7 +1816,7 @@ H5I_dec_type_ref(H5I_type_t 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->count <= 0) + if(type_ptr == NULL || type_ptr->init_count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* @@ -1882,13 +1825,13 @@ 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->count) { - H5I_destroy_type(type); + if(1 == type_ptr->init_count) { + H5I__destroy_type(type); ret_value = 0; } /* end if */ else { - --(type_ptr->count); - ret_value = (herr_t)type_ptr->count; + --(type_ptr->init_count); + ret_value = (herr_t)type_ptr->init_count; } /* end else */ done: @@ -1926,7 +1869,7 @@ H5Iget_type_ref(H5I_type_t type) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "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, FAIL, "can't get ID type ref count") done: @@ -1935,7 +1878,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_get_type_ref + * Function: H5I__get_type_ref * * Purpose: Retrieve the reference count for an ID type. * @@ -1949,13 +1892,13 @@ done: * *------------------------------------------------------------------------- */ -int -H5I_get_type_ref(H5I_type_t type) +static int +H5I__get_type_ref(H5I_type_t type) { H5I_id_type_t *type_ptr; /*ptr to the type */ int ret_value; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC /* Sanity check */ HDassert(type >= 0); @@ -1966,11 +1909,11 @@ H5I_get_type_ref(H5I_type_t type) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* Set return value */ - ret_value = (int)type_ptr->count; + ret_value = (int)type_ptr->init_count; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_get_type_ref() */ +} /* end H5I__get_type_ref() */ /*------------------------------------------------------------------------- @@ -1998,7 +1941,7 @@ H5Iis_valid(hid_t id) H5TRACE1("t", "i", id); /* Find the ID */ - if (NULL == (id_ptr = H5I_find_id(id))) + if (NULL == (id_ptr = H5I__find_id(id))) ret_value = FALSE; /* Check if the found id is an internal id */ @@ -2011,7 +1954,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_search_cb + * Function: H5I__search_cb * * Purpose: Callback routine for H5Isearch, when it calls H5I_iterate. * Calls "user" callback search function, and then sets return @@ -2028,19 +1971,19 @@ done: *------------------------------------------------------------------------- */ static int -H5I_search_cb(void *obj, hid_t id, void *_udata) +H5I__search_cb(void *obj, hid_t id, void *_udata) { H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ int ret_value; /* Callback return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR ret_value = (*udata->app_cb)(obj, id, udata->app_key); if(ret_value > 0) udata->ret_obj = obj; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_search_cb() */ +} /* end H5I__search_cb() */ /*------------------------------------------------------------------------- @@ -2087,7 +2030,7 @@ H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) /* Note that H5I_iterate returns an error code. We ignore it * here, as we can't do anything with it without revising the API. */ - H5I_iterate(type, H5I_search_cb, &udata, TRUE); + (void)H5I_iterate(type, H5I__search_cb, &udata, TRUE); /* Set return value */ ret_value = udata.ret_obj; @@ -2098,6 +2041,46 @@ done: /*------------------------------------------------------------------------- + * Function: H5I__iterate_cb + * + * Purpose: Callback routine for H5I_iterate, invokes "user" callback + * function, and then sets return value, based on the result of + * that callback. + * + * Return: Success: Non-negative on success + * Failure: Negative + * + * Programmer: Quincey Koziol + * Thursday, October 3, 2013 + * + *------------------------------------------------------------------------- + */ +static int +H5I__iterate_cb(void *_item, void 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 */ + + FUNC_ENTER_STATIC_NOERR + + /* Don't make callback if app_ref is set and the appl. ref count is 0 */ + if((!udata->app_ref) || (item->app_count > 0)) { + herr_t cb_ret_val; + + /* (Casting away const OK) */ + cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); + 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) */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__iterate_cb() */ + + +/*------------------------------------------------------------------------- * Function: H5I_iterate * * Purpose: Apply function FUNC to each member of type TYPE (with @@ -2139,33 +2122,19 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; - /* Only iterate through hash table if it is initialized and there are IDs in group */ - if(type_ptr && type_ptr->count > 0 && type_ptr->ids > 0) { - unsigned u; /* Counter */ - - /* Start at the beginning of the array */ - for(u = 0; u < type_ptr->cls->hash_size; u++) { - H5I_id_info_t *id_ptr; /* Ptr to the new ID */ - - id_ptr = type_ptr->id_list[u]; - while(id_ptr) { - H5I_id_info_t *next_id; /* Ptr to the next ID */ - - /* Protect against ID being deleted in callback */ - next_id = id_ptr->next; - if((!app_ref) || (id_ptr->app_count > 0)) { - herr_t cb_ret_val; /* Callback return value */ - - /* (Casting away const OK) */ - cb_ret_val = (*func)((void *)id_ptr->obj_ptr, id_ptr->id, udata); - if(cb_ret_val > 0) - HGOTO_DONE(SUCCEED) /* terminate iteration early */ - else if(cb_ret_val < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "func failed") - } /* end if */ - id_ptr = next_id; - } /* end while */ - } /* end for */ + /* 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 */ + + /* Set up iterator user data */ + 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) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") } /* end if */ done: @@ -2174,7 +2143,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_find_id + * Function: H5I__find_id * * Purpose: Given an object ID find the info struct that describes the * object. @@ -2188,16 +2157,13 @@ done: *------------------------------------------------------------------------- */ static H5I_id_info_t * -H5I_find_id(hid_t id) +H5I__find_id(hid_t id) { H5I_id_type_t *type_ptr; /*ptr to the type */ - H5I_id_info_t *last_id; /*ptr to the last ID */ - H5I_id_info_t *id_ptr; /*ptr to the new ID */ H5I_type_t type; /*ID's type */ - unsigned hash_loc; /*bucket pointer */ H5I_id_info_t *ret_value; /*return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check arguments */ type = H5I_TYPE(id); @@ -2205,35 +2171,15 @@ H5I_find_id(hid_t id) HGOTO_DONE(NULL); type_ptr = H5I_id_type_list_g[type]; - if (!type_ptr || type_ptr->count <= 0) + if (!type_ptr || type_ptr->init_count <= 0) HGOTO_DONE(NULL); - /* Get the bucket in which the ID is located */ - hash_loc = (unsigned)H5I_LOC(id, type_ptr->cls->hash_size); - id_ptr = type_ptr->id_list[hash_loc]; - - /* Scan the bucket's linked list for a match */ - last_id = NULL; - while(id_ptr) { - if(id_ptr->id == id) { - /* If we found an object, move it to the front of the list, if it isn't there already */ - if(last_id != NULL) { - last_id->next = id_ptr->next; - id_ptr->next = type_ptr->id_list[hash_loc]; - type_ptr->id_list[hash_loc] = id_ptr; - } /* end if */ - break; - } /* end if */ - last_id = id_ptr; - id_ptr = id_ptr->next; - } /* end while */ - - /* Set the return value */ - ret_value = id_ptr; + /* Locate the ID node for the ID */ + ret_value = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I_find_id() */ +} /* end H5I__find_id() */ /*------------------------------------------------------------------------- @@ -2364,9 +2310,66 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_get_file_id() */ +#ifdef H5I_DEBUG_OUTPUT /*------------------------------------------------------------------------- - * Function: H5I_debug + * Function: H5I__debug_cb + * + * Purpose: Dump the contents of an ID to stderr for debugging. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Robb Matzke + * Friday, February 19, 1999 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5I__debug_cb(void *_item, void 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; + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + fprintf(stderr, " id = %lu\n", (unsigned long)(item->id)); + fprintf(stderr, " count = %u\n", item->count); + fprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(item->obj_ptr)); + + /* Get the group location, so we get get the name */ + switch(type) { + case H5I_GROUP: + path = H5G_nameof((H5G_t*)item->obj_ptr); + break; + + case H5I_DATASET: + path = H5D_nameof((H5D_t*)item->obj_ptr); + break; + + case H5I_DATATYPE: + path = H5T_nameof((H5T_t*)item->obj_ptr); + break; + + default: + break; /* Other types of IDs are not stored in files */ + } /* end switch*/ + + if(path) { + if(path->user_path_r) + fprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r)); + if(path->full_path_r) + fprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); + } /* end if */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5I__debug_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5I__debug * * Purpose: Dump the contents of a type to stderr for debugging. * @@ -2378,74 +2381,28 @@ done: * *------------------------------------------------------------------------- */ -#ifdef H5I_DEBUG_OUTPUT static herr_t -H5I_debug(H5I_type_t type) +H5I__debug(H5I_type_t type) { H5I_id_type_t *type_ptr; - H5I_id_info_t *cur; - H5G_name_t *path; - int is, js; - unsigned int iu; - herr_t ret_value; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC_NOERR fprintf(stderr, "Dumping ID type %d\n", (int)type); type_ptr = H5I_id_type_list_g[type]; /* Header */ - fprintf(stderr, " count = %u\n", type_ptr->count); - fprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); - fprintf(stderr, " wrapped = %u\n", type_ptr->wrapped); - fprintf(stderr, " hash_size = %lu\n", (unsigned long)type_ptr->cls->hash_size); - fprintf(stderr, " ids = %u\n", type_ptr->ids); - fprintf(stderr, " nextid = %u\n", type_ptr->nextid); - - /* Cache */ - fprintf(stderr, " Cache:\n"); - for (is=0; is<ID_CACHE_SIZE; is++) { - if (H5I_cache_g[is] && H5I_TYPE(H5I_cache_g[is]->id)==type) { - fprintf(stderr, " Entry-%d, ID=%lu\n", - is, (unsigned long)(H5I_cache_g[is]->id)); - } - } + 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); /* List */ fprintf(stderr, " List:\n"); - for (iu=0; iu<type_ptr->hash_size; iu++) { - for (js=0, cur=type_ptr->id_list[iu]; cur; cur=cur->next, js++) { - fprintf(stderr, " #%u.%d\n", iu, js); - fprintf(stderr, " id = %lu\n", (unsigned long)(cur->id)); - fprintf(stderr, " count = %u\n", cur->count); - fprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(cur->obj_ptr)); - - /* Get the group location, so we get get the name */ - switch(type) { - case H5I_GROUP: - path = H5G_nameof((H5G_t*)cur->obj_ptr); - break; - case H5I_DATASET: - path = H5D_nameof((H5D_t*)cur->obj_ptr); - break; - case H5I_DATATYPE: - path = H5T_nameof((H5T_t*)cur->obj_ptr); - break; - default: - continue; /* Other types of IDs are not stored in files */ - } /* end switch*/ - - if(path) { - if(path->user_path_r) - fprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r)); - if(ent->canon_path_r) - fprintf(stderr, " canon_path = %s\n", H5RS_get_str(path->canon_path_r)); - } /* end if */ - } /* end for */ - } /* end for */ + H5SL_iterate(type_ptr->ids, H5I__debug_cb, &type); -done: FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5I_debug() */ +} /* end H5I__debug() */ #endif /* H5I_DEBUG_OUTPUT */ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 125c3f6..af8b6ca 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -46,7 +46,6 @@ typedef struct H5I_class_t { H5I_type_t type_id; /* Class ID for the type */ unsigned flags; /* Class behavior flags */ - size_t hash_size; /* Minimum hash table size for the type */ unsigned reserved; /* Number of reserved IDs for this type */ /* [A specific number of type entries may be * reserved to enable "constant" values to be @@ -69,7 +68,6 @@ typedef struct H5I_class_t { H5_DLL herr_t H5I_register_type(const H5I_class_t *cls); H5_DLL int H5I_nmembers(H5I_type_t type); H5_DLL herr_t H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref); -H5_DLL int H5I_destroy_type(H5I_type_t type); H5_DLL hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref); H5_DLL herr_t H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t id); H5_DLL void *H5I_subst(hid_t id, const void *new_object); @@ -78,16 +76,13 @@ H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); H5_DLL H5I_type_t H5I_get_type(hid_t id); H5_DLL hid_t H5I_get_file_id(hid_t obj_id, hbool_t app_ref); H5_DLL void *H5I_remove(hid_t id); -H5_DLL void *H5I_remove_verify(hid_t id, H5I_type_t id_type); H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref); H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref); H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref); H5_DLL int H5I_dec_ref(hid_t id); H5_DLL int H5I_dec_app_ref(hid_t id); H5_DLL int H5I_dec_app_ref_always_close(hid_t id); -H5_DLL int H5I_inc_type_ref(H5I_type_t type); H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type); -H5_DLL int H5I_get_type_ref(H5I_type_t type); #endif /* _H5Iprivate_H */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index a416b00..6955a60 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -2472,7 +2472,7 @@ H5P__facc_cache_config_cmp(const void *_config1, const void *_config2, size_t UN if(config1->close_trace_file > config2->close_trace_file) HGOTO_DONE(1); if((ret_value = HDstrncmp(config1->trace_file_name, config2->trace_file_name, - H5AC__MAX_TRACE_FILE_NAME_LEN + 1)) != 0) + (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + 1))) != 0) HGOTO_DONE(ret_value); if(config1->evictions_enabled < config2->evictions_enabled) HGOTO_DONE(-1); diff --git a/src/H5Pint.c b/src/H5Pint.c index 40d0a9c..c2a17ba 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -269,7 +269,6 @@ H5FL_DEFINE_STATIC(H5P_genplist_t); static const H5I_class_t H5I_GENPROPCLS_CLS[1] = {{ H5I_GENPROP_CLS, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ (H5I_free_t)H5P_close_class /* Callback routine for closing objects of this class */ }}; @@ -278,7 +277,6 @@ static const H5I_class_t H5I_GENPROPCLS_CLS[1] = {{ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ H5I_GENPROP_LST, /* ID class value */ 0, /* Class flags */ - 128, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ (H5I_free_t)H5P_close /* Callback routine for closing objects of this class */ }}; @@ -77,7 +77,6 @@ static ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id, static const H5I_class_t H5I_REFERENCE_CLS[1] = {{ H5I_REFERENCE, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 0, /* # of reserved IDs for class */ NULL /* Callback routine for closing objects of this class */ }}; @@ -90,7 +90,6 @@ H5FL_ARR_DEFINE(hsize_t,H5S_MAX_RANK); static const H5I_class_t H5I_DATASPACE_CLS[1] = {{ H5I_DATASPACE, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 2, /* # of reserved IDs for class */ (H5I_free_t)H5S_close /* Callback routine for closing objects of this class */ }}; @@ -549,10 +549,12 @@ H5SL_init_interface(void) /* Allocate space for array of factories */ H5SL_fac_g = (H5FL_fac_head_t **)H5MM_malloc(sizeof(H5FL_fac_head_t *)); + HDassert(H5SL_fac_g); H5SL_fac_nalloc_g = 1; /* Initialize first factory */ H5SL_fac_g[0] = H5FL_fac_init(sizeof(H5SL_node_t *)); + HDassert(H5SL_fac_g[0]); H5SL_fac_nused_g = 1; FUNC_LEAVE_NOAPI(SUCCEED) @@ -681,6 +683,10 @@ H5SL_insert_common(H5SL_t *slist, void *item, const void *key) H5SL_INSERT(OBJ, slist, prev, const H5_obj_t, key, -) break; + case H5SL_TYPE_HID: + H5SL_INSERT(SCALAR, slist, prev, const hid_t, key, -) + break; + case H5SL_TYPE_GENERIC: H5SL_INSERT(GENERIC, slist, prev, const void, key, -) break; @@ -1110,6 +1116,10 @@ H5SL_remove(H5SL_t *slist, const void *key) H5SL_REMOVE(OBJ, slist, x, const H5_obj_t, key, -) break; + case H5SL_TYPE_HID: + H5SL_REMOVE(SCALAR, slist, x, const hid_t, key, -) + break; + case H5SL_TYPE_GENERIC: H5SL_REMOVE(GENERIC, slist, x, const void, key, -) break; @@ -1293,6 +1303,10 @@ H5SL_search(H5SL_t *slist, const void *key) H5SL_SEARCH(OBJ, slist, x, const H5_obj_t, key, -) break; + case H5SL_TYPE_HID: + H5SL_SEARCH(SCALAR, slist, x, const hid_t, key, -) + break; + case H5SL_TYPE_GENERIC: H5SL_SEARCH(GENERIC, slist, x, const void, key, -) break; @@ -1382,6 +1396,10 @@ H5SL_less(H5SL_t *slist, const void *key) H5SL_SEARCH(OBJ, slist, x, const H5_obj_t, key, -) break; + case H5SL_TYPE_HID: + H5SL_SEARCH(SCALAR, slist, x, const hid_t, key, -) + break; + case H5SL_TYPE_GENERIC: H5SL_SEARCH(GENERIC, slist, x, const void, key, -) break; @@ -1484,6 +1502,10 @@ H5SL_greater(H5SL_t *slist, const void *key) H5SL_SEARCH(OBJ, slist, x, const H5_obj_t, key, -) break; + case H5SL_TYPE_HID: + H5SL_SEARCH(SCALAR, slist, x, const hid_t, key, -) + break; + case H5SL_TYPE_GENERIC: H5SL_SEARCH(GENERIC, slist, x, const void, key, -) break; @@ -1576,6 +1598,10 @@ H5SL_find(H5SL_t *slist, const void *key) H5SL_FIND(OBJ, slist, x, const H5_obj_t, key, -) break; + case H5SL_TYPE_HID: + H5SL_FIND(SCALAR, slist, x, const hid_t, key, -) + break; + case H5SL_TYPE_GENERIC: H5SL_FIND(GENERIC, slist, x, const void, key, -) break; @@ -1665,6 +1691,10 @@ H5SL_below(H5SL_t *slist, const void *key) H5SL_FIND(OBJ, slist, x, const H5_obj_t, key, -) break; + case H5SL_TYPE_HID: + H5SL_FIND(SCALAR, slist, x, const hid_t, key, -) + break; + case H5SL_TYPE_GENERIC: H5SL_FIND(GENERIC, slist, x, const void, key, -) break; @@ -1767,6 +1797,10 @@ H5SL_above(H5SL_t *slist, const void *key) H5SL_FIND(OBJ, slist, x, const H5_obj_t, key, -) break; + case H5SL_TYPE_HID: + H5SL_FIND(SCALAR, slist, x, const hid_t, key, -) + break; + case H5SL_TYPE_GENERIC: H5SL_FIND(GENERIC, slist, x, const void, key, -) break; @@ -1994,7 +2028,8 @@ H5SL_item(H5SL_node_t *slist_node) herr_t H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) { - H5SL_node_t *node; /* Pointers to skip list nodes */ + H5SL_node_t *node; /* Pointer to current skip list node */ + H5SL_node_t *next; /* Pointer to next skip list node */ herr_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2008,12 +2043,16 @@ H5SL_iterate(H5SL_t *slist, H5SL_operator_t op, void *op_data) /* Free skip list nodes */ node = slist->header->forward[0]; while(node != NULL) { + /* Protect against the node being deleted by the callback */ + next = node->forward[0]; + /* Call the iterator callback */ /* Casting away const OK -QAK */ if((ret_value = (op)(node->item, (void *)node->key, op_data)) != 0) break; - node = node->forward[0]; + /* Advance to next node */ + node = next; } /* end while */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5SLprivate.h b/src/H5SLprivate.h index 07ee414..ce2f091 100644 --- a/src/H5SLprivate.h +++ b/src/H5SLprivate.h @@ -48,6 +48,7 @@ typedef enum { H5SL_TYPE_UNSIGNED, /* Skip list keys are 'unsigned's */ H5SL_TYPE_SIZE, /* Skip list keys are 'size_t's */ H5SL_TYPE_OBJ, /* Skip list keys are 'H5_obj_t's */ + H5SL_TYPE_HID, /* Skip list keys are 'hid_t's */ H5SL_TYPE_GENERIC /* Skip list keys are unknown, comparison callback supplied */ } H5SL_type_t; @@ -528,7 +528,6 @@ H5FL_DEFINE_STATIC(H5T_path_t); static const H5I_class_t H5I_DATATYPE_CLS[1] = {{ H5I_DATATYPE, /* ID class value */ 0, /* Class flags */ - 64, /* Minimum hash size for class */ 8, /* # of reserved IDs for class */ (H5I_free_t)H5T_close /* Callback routine for closing objects of this class */ }}; diff --git a/src/H5detect.c b/src/H5detect.c index be661ea..3554d50 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -124,7 +124,7 @@ static int bit_cmp(int, int *, volatile void *, volatile void *, static void fix_order(int, int, int *, const char **); static int imp_bit(int, int *, volatile void *, volatile void *, const unsigned char *); -static unsigned long find_bias(int, int, int *, void *); +static unsigned long find_bias(int, int, int *, volatile void *); static void precision (detected_t*); static void print_header(void); static void detect_C89_integers(void); @@ -1135,7 +1135,7 @@ imp_bit(int n, int *perm, volatile void *_a, volatile void *_b, *------------------------------------------------------------------------- */ static unsigned long -find_bias(int epos, int esize, int *perm, void *_a) +find_bias(int epos, int esize, int *perm, volatile void *_a) { unsigned char *a = (unsigned char *) _a; unsigned char mask; diff --git a/src/H5private.h b/src/H5private.h index 2bfcb70..f54bd9d 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -277,12 +277,15 @@ #ifdef __cplusplus # define __attribute__(X) /*void*/ # define UNUSED /*void*/ +# define NORETURN /*void*/ #else /* __cplusplus */ #ifdef H5_HAVE_ATTRIBUTE # define UNUSED __attribute__((unused)) +# define NORETURN __attribute__((noreturn)) #else # define __attribute__(X) /*void*/ # define UNUSED /*void*/ +# define NORETURN /*void*/ #endif #endif /* __cplusplus */ diff --git a/src/H5public.h b/src/H5public.h index 6136c05..fad88b1 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -75,10 +75,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 165 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 167 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "swmr0" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.165-swmr0" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.167-swmr0" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) @@ -195,7 +195,7 @@ typedef signed long long hssize_t; #elif H5_SIZEOF_HADDR_T ==H5_SIZEOF_LONG # define H5_PRINTF_HADDR_FMT "%lu" #elif H5_SIZEOF_HADDR_T ==H5_SIZEOF_LONG_LONG -# define H5_PRINTF_HADDR_FMT "%"H5_PRINTF_LL_WIDTH"u" +# define H5_PRINTF_HADDR_FMT "%" H5_PRINTF_LL_WIDTH "u" #else # error "nothing appropriate for H5_PRINTF_HADDR_FMT" #endif diff --git a/src/H5system.c b/src/H5system.c index 4280066..614b8b9 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -201,7 +201,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) if(sizeof(hsize_t) < sizeof(long)) modifier[0] = '\0'; else if(sizeof(hsize_t) == sizeof(long)) - HDstrncpy(modifier, "l", 2); + HDstrncpy(modifier, "l", (size_t)2); else HDstrncpy(modifier, H5_PRINTF_LL_WIDTH, HDstrlen(H5_PRINTF_LL_WIDTH) + 1); break; @@ -211,7 +211,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) if(sizeof(size_t) < sizeof(long)) modifier[0] = '\0'; else if(sizeof(size_t) == sizeof(long)) - HDstrncpy(modifier, "l", 2); + HDstrncpy(modifier, "l", (size_t)2); else HDstrncpy(modifier, H5_PRINTF_LL_WIDTH, HDstrlen(H5_PRINTF_LL_WIDTH) + 1); break; diff --git a/src/H5win32defs.h b/src/H5win32defs.h index d452925..185e9b4 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -74,7 +74,7 @@ struct timezone { extern "C" { #endif /* __cplusplus */ H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); - H5_DLL char* Wgetlogin(); + H5_DLL char* Wgetlogin(void); H5_DLL int c99_snprintf(char* str, size_t size, const char* format, ...); H5_DLL int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap); #ifdef __cplusplus diff --git a/src/Makefile.in b/src/Makefile.in index a1666be..104a7ed 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -523,7 +523,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog # Add libtool shared library version numbers to the HDF5 library # See libtool versioning documentation online. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 155 +LT_VERS_REVISION = 157 LT_VERS_AGE = 0 # Our main target, the HDF5 library |