diff options
author | Raymond Lu <songyulu@hdfgroup.org> | 2013-10-25 19:26:08 (GMT) |
---|---|---|
committer | Raymond Lu <songyulu@hdfgroup.org> | 2013-10-25 19:26:08 (GMT) |
commit | 277ee2f7ee210255fbe96bc8e6101af2e93ed508 (patch) | |
tree | 14f9fbe89584a98fb72aabf0929ebe05acd768ca /test/tfile.c | |
parent | b7a4e1a44ee8df805a99b252ef57d0497378bfd3 (diff) | |
download | hdf5-277ee2f7ee210255fbe96bc8e6101af2e93ed508.zip hdf5-277ee2f7ee210255fbe96bc8e6101af2e93ed508.tar.gz hdf5-277ee2f7ee210255fbe96bc8e6101af2e93ed508.tar.bz2 |
[svn-r24360] Jira issue 8528: H5Fget_obj_ids overfilled the list of object IDs by one. This is the second round of checkin after
receiving review comments from people. I put the safeguard in both H5F_get_objects and H5F_get_objects_cb to prevent
overfill the list.
tested with h5committest.
Diffstat (limited to 'test/tfile.c')
-rw-r--r-- | test/tfile.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/tfile.c b/test/tfile.c index 6c0eba4..797b4fa 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1044,6 +1044,40 @@ test_get_obj_ids(void) H5Fclose(fid); HDfree(oid_list); + + /* Reopen the file to check whether H5Fget_obj_count and H5Fget_obj_ids still works + * when the file is closed first */ + fid = H5Fopen(FILE7, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + + /* Open NDSETS datasets under the root group */ + for(n = 0; n < NDSETS; n++) { + sprintf(dname, "dataset%d", n); + dset[n] = H5Dopen2(fid, dname, H5P_DEFAULT); + CHECK(dset[n], FAIL, "H5Dcreate2"); + } + + /* Close the file first */ + H5Fclose(fid); + + /* Get the number of all opened objects */ + oid_count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL); + CHECK(oid_count, FAIL, "H5Fget_obj_count"); + VERIFY(oid_count, NDSETS, "H5Fget_obj_count"); + + oid_list = (hid_t *)HDcalloc((size_t)oid_count, sizeof(hid_t)); + CHECK(oid_list, NULL, "HDcalloc"); + + /* Get the list of all opened objects */ + ret_count = H5Fget_obj_ids(H5F_OBJ_ALL, H5F_OBJ_ALL, (size_t)oid_count, oid_list); + CHECK(ret_count, FAIL, "H5Fget_obj_ids"); + VERIFY(ret_count, NDSETS, "H5Fget_obj_count"); + + /* Close all open objects with H5Oclose */ + for(n = 0; n < oid_count; n++) + H5Oclose(oid_list[n]); + + HDfree(oid_list); } /**************************************************************** |