/*-------------------------------------------------------------------------- NAME H5R_top_term_package PURPOSE Terminate various H5R objects USAGE void H5R_top_term_package() RETURNS void DESCRIPTION Release IDs for the atom group, deferring full interface shutdown until later (in H5R_term_package). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ int H5R_top_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR if (H5R_top_package_initialize_s) { if (H5I_nmembers(H5I_REFERENCE) > 0) { (void)H5I_clear_type(H5I_REFERENCE, FALSE, FALSE); n++; } /* Mark closed */ if (0 == n) H5R_top_package_initialize_s = FALSE; } FUNC_LEAVE_NOAPI(n) } /* end H5R_top_term_package() */
/*-------------------------------------------------------------------------- NAME H5R_term_package PURPOSE Terminate various H5R objects USAGE void H5R_term_package() RETURNS void DESCRIPTION Release the atom group and any other resources allocated. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS Can't report errors... Finishes shutting down the interface, after H5R_top_term_package() is called EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ int H5R_term_package(void) { int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR if (H5_PKG_INIT_VAR) { /* Sanity checks */ HDassert(0 == H5I_nmembers(H5I_REFERENCE)); HDassert(FALSE == H5R_top_package_initialize_s); /* Destroy the reference id group */ n += (H5I_dec_type_ref(H5I_REFERENCE) > 0); /* Mark closed */ if (0 == n) H5_PKG_INIT_VAR = FALSE; } FUNC_LEAVE_NOAPI(n) } /* end H5R_term_package() */
/* Test the H5Iis_valid function */ static int test_is_valid(void) { hid_t dtype; /* datatype id */ int64_t nmembs1; /* number of type memnbers */ int64_t nmembs2; htri_t tri_ret; /* htri_t return value */ herr_t ret; /* return value */ /* Create a datatype id */ dtype = H5Tcopy(H5T_NATIVE_INT); CHECK(dtype, FAIL, "H5Tcopy"); if (dtype < 0) goto out; /* Check that the ID is valid */ tri_ret = H5Iis_valid(dtype); VERIFY(tri_ret, TRUE, "H5Iis_valid"); if (tri_ret != TRUE) goto out; /* Artificially manipulate the reference counts so app_count is 0, and dtype * appears to be an internal id. This takes advantage of the fact that * H5Ipkg is included. */ ret = H5I_inc_ref(dtype, FALSE); CHECK(ret, FAIL, "H5I_inc_ref"); if (ret < 0) goto out; ret = H5I_dec_app_ref(dtype); CHECK(ret, FAIL, "H5I_dec_ref"); if (ret < 0) goto out; /* Check that dtype is invalid */ tri_ret = H5Iis_valid(dtype); VERIFY(tri_ret, FALSE, "H5Iis_valid"); if (tri_ret != FALSE) goto out; /* Close dtype and verify that it has been closed */ nmembs1 = H5I_nmembers(H5I_DATATYPE); CHECK(nmembs1, FAIL, "H5I_nmembers"); if (nmembs1 < 0) goto out; ret = H5I_dec_ref(dtype); CHECK(ret, FAIL, "H5I_dec_ref"); if (ret < 0) goto out; nmembs2 = H5I_nmembers(H5I_DATATYPE); VERIFY(nmembs2, nmembs1 - 1, "H5I_nmembers"); if (nmembs2 != nmembs1 - 1) goto out; /* Check that dtype is invalid */ tri_ret = H5Iis_valid(dtype); VERIFY(tri_ret, FALSE, "H5Iis_valid"); if (tri_ret != FALSE) goto out; /* Check that an id of -1 is invalid */ tri_ret = H5Iis_valid((hid_t)-1); VERIFY(tri_ret, FALSE, "H4Iis_valid"); if (tri_ret != FALSE) goto out; return 0; out: /* Don't attempt to close dtype as we don't know the exact state of the * reference counts. Every state in this function will be automatically * closed at library exit anyways, as internal count is never > 1. */ return -1; }