diff --git a/MANIFEST b/MANIFEST index ce941e653b9..b6dcf5d9842 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1019,8 +1019,6 @@ ./src/H5SMpkg.h ./src/H5SMprivate.h ./src/H5SMtest.c -./src/H5ST.c -./src/H5STprivate.h ./src/H5T.c ./src/H5Tarray.c ./src/H5Tbit.c @@ -1304,7 +1302,6 @@ ./test/tsizeslheap.h5 ./test/tskiplist.c ./test/tsohm.c -./test/ttst.c ./test/ttsafe.c ./test/ttsafe.h ./test/ttsafe_acreate.c diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index f4e283893d3..592a69693e9 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -29,7 +29,7 @@ static H5I_type_t H5PT_ptable_id_type = H5I_UNINIT; #define H5PT_HASH_TABLE_SIZE 64 /* Packet Table private functions */ -static herr_t H5PT_free_id(void *id); +static herr_t H5PT_free_id(void *id, void **_ctx); static herr_t H5PT_close(htbl_t *table); static herr_t H5PT_create_index(htbl_t *table_id); static herr_t H5PT_set_index(htbl_t *table_id, hsize_t pt_index); @@ -402,7 +402,7 @@ H5PTopen(hid_t loc_id, const char *dset_name) *------------------------------------------------------------------------- */ static herr_t -H5PT_free_id(void *id) +H5PT_free_id(void *id, void H5_ATTR_UNUSED **_ctx) { HDfree(id); return SUCCEED; diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index 1ac162f3ef8..efa61a32eb1 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -57,11 +57,11 @@ H5TBmake_table(const char *table_title, hid_t loc_id, const char *dset_name, hsi hsize_t nrecords, size_t type_size, const char *field_names[], const size_t *field_offset, const hid_t *field_types, hsize_t chunk_size, void *fill_data, int compress, const void *buf) { - hid_t did = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t plist_id = H5I_BADID; - hid_t attr_id = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hid_t plist_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; hsize_t dims[1]; hsize_t dims_chunk[1]; hsize_t maxdims[1] = {H5S_UNLIMITED}; @@ -129,17 +129,17 @@ H5TBmake_table(const char *table_title, hid_t loc_id, const char *dset_name, hsi /* terminate access to the data space. */ if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; /* end access to the dataset */ if (H5Dclose(did) < 0) goto out; - did = H5I_BADID; + did = H5I_INVALID_HID; /* end access to the property list */ if (H5Pclose(plist_id) < 0) goto out; - plist_id = H5I_BADID; + plist_id = H5I_INVALID_HID; /*------------------------------------------------------------------------- * set the conforming table attributes @@ -196,24 +196,24 @@ H5TBmake_table(const char *table_title, hid_t loc_id, const char *dset_name, hsi if (H5Aclose(attr_id) < 0) goto out; - attr_id = H5I_BADID; + attr_id = H5I_INVALID_HID; } /* end for */ /* terminate access to the data space. */ if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; /* end access to the dataset */ if (H5Dclose(did) < 0) goto out; - did = H5I_BADID; + did = H5I_INVALID_HID; } /* end if */ /* release the datatype. */ if (H5Tclose(mem_type_id) < 0) goto out; - mem_type_id = H5I_BADID; + mem_type_id = H5I_INVALID_HID; ret_val = 0; @@ -267,9 +267,9 @@ herr_t H5TBappend_records(hid_t loc_id, const char *dset_name, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; hsize_t nrecords_orig; hsize_t nfields; herr_t ret_val = -1; @@ -332,11 +332,11 @@ herr_t H5TBwrite_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; hsize_t count[1]; hsize_t offset[1]; hsize_t mem_size[1]; @@ -425,14 +425,14 @@ H5TBwrite_fields_name(hid_t loc_id, const char *dset_name, const char *field_nam hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t file_space_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t write_type_id = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t nmtype_id = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t file_space_id = H5I_INVALID_HID; + hid_t preserve_id = H5I_INVALID_HID; hssize_t nfields; hssize_t i, j; hsize_t count[1]; @@ -510,10 +510,10 @@ H5TBwrite_fields_name(hid_t loc_id, const char *dset_name, const char *field_nam /* close */ if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; if (H5Tclose(nmtype_id) < 0) goto out; - nmtype_id = H5I_BADID; + nmtype_id = H5I_INVALID_HID; } /* end if */ H5free_memory(member_name); @@ -583,14 +583,14 @@ H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, con hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *field_sizes, const void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t file_space_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t write_type_id = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t nmtype_id = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t file_space_id = H5I_INVALID_HID; + hid_t preserve_id = H5I_INVALID_HID; hsize_t count[1]; hsize_t offset[1]; hsize_t i; @@ -663,10 +663,10 @@ H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, con /* close */ if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; if (H5Tclose(nmtype_id) < 0) goto out; - nmtype_id = H5I_BADID; + nmtype_id = H5I_INVALID_HID; H5free_memory(member_name); member_name = NULL; @@ -747,10 +747,10 @@ herr_t H5TBread_table(hid_t loc_id, const char *dset_name, size_t type_size, const size_t *field_offset, const size_t *field_sizes, void *dst_buf) { - hid_t did = H5I_BADID; - hid_t ftype_id = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t sid = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t ftype_id = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; hsize_t dims[1]; herr_t ret_val = -1; @@ -820,9 +820,9 @@ herr_t H5TBread_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t ftype_id = H5I_BADID; - hid_t mem_type_id = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t ftype_id = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; hsize_t nrecords_orig; hsize_t nfields; herr_t ret_val = -1; @@ -887,13 +887,13 @@ H5TBread_fields_name(hid_t loc_id, const char *dset_name, const char *field_name hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t ftype_id = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t mtype_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t ftype_id = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hid_t mtype_id = H5I_INVALID_HID; + hid_t nmtype_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; hssize_t nfields; hsize_t count[1]; hsize_t offset[1]; @@ -960,10 +960,10 @@ H5TBread_fields_name(hid_t loc_id, const char *dset_name, const char *field_name /* close */ if (H5Tclose(mtype_id) < 0) goto out; - mtype_id = H5I_BADID; + mtype_id = H5I_INVALID_HID; if (H5Tclose(nmtype_id) < 0) goto out; - nmtype_id = H5I_BADID; + nmtype_id = H5I_INVALID_HID; j++; } /* end if */ @@ -1044,13 +1044,13 @@ H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, cons hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t read_type_id = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t read_type_id = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t nmtype_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; hsize_t count[1]; hsize_t offset[1]; hsize_t mem_size[1]; @@ -1117,10 +1117,10 @@ H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, cons /* close the member type */ if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; if (H5Tclose(nmtype_id) < 0) goto out; - nmtype_id = H5I_BADID; + nmtype_id = H5I_INVALID_HID; H5free_memory(member_name); member_name = NULL; @@ -1198,11 +1198,11 @@ H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, cons herr_t H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; hsize_t nfields; hsize_t ntotal_records; hsize_t read_start; @@ -1294,16 +1294,16 @@ H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nr /* close */ if (H5Sclose(m_sid) < 0) goto out; - m_sid = H5I_BADID; + m_sid = H5I_INVALID_HID; if (H5Tclose(mem_type_id) < 0) goto out; - mem_type_id = H5I_BADID; + mem_type_id = H5I_INVALID_HID; if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; if (H5Tclose(tid) < 0) goto out; - tid = H5I_BADID; + tid = H5I_INVALID_HID; } /* read_nrecords */ /*------------------------------------------------------------------------- @@ -1361,11 +1361,11 @@ herr_t H5TBinsert_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, size_t type_size, const size_t *field_offset, const size_t *field_sizes, void *buf) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t mem_type_id = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t mem_type_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; hsize_t nfields; hsize_t ntotal_records; hsize_t read_nrecords; @@ -1442,10 +1442,10 @@ H5TBinsert_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nr /* terminate access to the dataspace */ if (H5Sclose(m_sid) < 0) goto out; - m_sid = H5I_BADID; + m_sid = H5I_INVALID_HID; if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; /*------------------------------------------------------------------------- * write the "pushed down" records @@ -1513,10 +1513,10 @@ herr_t H5TBadd_records_from(hid_t loc_id, const char *dset_name1, hsize_t start1, hsize_t nrecords, const char *dset_name2, hsize_t start2) { - hid_t did = H5I_BADID; - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; + hid_t did = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; hsize_t count[1]; hsize_t offset[1]; hsize_t mem_size[1]; @@ -1643,24 +1643,24 @@ H5TBcombine_tables(hid_t loc_id1, const char *dset_name1, hid_t loc_id2, const c const char *dset_name3) { /* identifiers for the 1st dataset. */ - hid_t did_1 = H5I_BADID; - hid_t tid_1 = H5I_BADID; - hid_t sid_1 = H5I_BADID; - hid_t pid_1 = H5I_BADID; + hid_t did_1 = H5I_INVALID_HID; + hid_t tid_1 = H5I_INVALID_HID; + hid_t sid_1 = H5I_INVALID_HID; + hid_t pid_1 = H5I_INVALID_HID; /* identifiers for the 2nd dataset. */ - hid_t did_2 = H5I_BADID; - hid_t tid_2 = H5I_BADID; - hid_t sid_2 = H5I_BADID; - hid_t pid_2 = H5I_BADID; + hid_t did_2 = H5I_INVALID_HID; + hid_t tid_2 = H5I_INVALID_HID; + hid_t sid_2 = H5I_INVALID_HID; + hid_t pid_2 = H5I_INVALID_HID; /* identifiers for the 3rd dataset. */ - hid_t did_3 = H5I_BADID; - hid_t tid_3 = H5I_BADID; - hid_t sid_3 = H5I_BADID; - hid_t pid_3 = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t attr_id = H5I_BADID; + hid_t did_3 = H5I_INVALID_HID; + hid_t tid_3 = H5I_INVALID_HID; + hid_t sid_3 = H5I_INVALID_HID; + hid_t pid_3 = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; hsize_t count[1]; hsize_t offset[1]; hsize_t mem_size[1]; @@ -1807,17 +1807,17 @@ H5TBcombine_tables(hid_t loc_id1, const char *dset_name1, hid_t loc_id2, const c if (H5Aclose(attr_id) < 0) goto out; - attr_id = H5I_BADID; + attr_id = H5I_INVALID_HID; if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end for */ /* close data space. */ if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; } /* end if */ /*------------------------------------------------------------------------- @@ -1856,7 +1856,7 @@ H5TBcombine_tables(hid_t loc_id1, const char *dset_name1, hid_t loc_id2, const c */ if (H5Sclose(m_sid) < 0) goto out; - m_sid = H5I_BADID; + m_sid = H5I_INVALID_HID; HDfree(tmp_buf); tmp_buf = NULL; @@ -1999,25 +1999,25 @@ H5TBinsert_field(hid_t loc_id, const char *dset_name, const char *field_name, hi hsize_t position, const void *fill_data, const void *buf) { /* identifiers for the 1st, original dataset */ - hid_t did_1 = H5I_BADID; - hid_t tid_1 = H5I_BADID; - hid_t sid_1 = H5I_BADID; - hid_t pid_1 = H5I_BADID; - hid_t msid_1 = H5I_BADID; + hid_t did_1 = H5I_INVALID_HID; + hid_t tid_1 = H5I_INVALID_HID; + hid_t sid_1 = H5I_INVALID_HID; + hid_t pid_1 = H5I_INVALID_HID; + hid_t msid_1 = H5I_INVALID_HID; /* identifiers for the 2nd, new dataset */ - hid_t did_2 = H5I_BADID; - hid_t tid_2 = H5I_BADID; - hid_t sid_2 = H5I_BADID; - hid_t pid_2 = H5I_BADID; - hid_t msid_2 = H5I_BADID; + hid_t did_2 = H5I_INVALID_HID; + hid_t tid_2 = H5I_INVALID_HID; + hid_t sid_2 = H5I_INVALID_HID; + hid_t pid_2 = H5I_INVALID_HID; + hid_t msid_2 = H5I_INVALID_HID; /* identifiers for the 3rd, final dataset */ - hid_t did_3 = H5I_BADID; - hid_t tid_3 = H5I_BADID; - hid_t sid_3 = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; - hid_t attr_id = H5I_BADID; + hid_t did_3 = H5I_INVALID_HID; + hid_t tid_3 = H5I_INVALID_HID; + hid_t sid_3 = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t write_type_id = H5I_INVALID_HID; + hid_t preserve_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; size_t member_size; size_t new_member_size = 0; size_t total_size; @@ -2157,7 +2157,7 @@ H5TBinsert_field(hid_t loc_id, const char *dset_name, const char *field_name, hi /* close the member type */ if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end else */ } /* end for */ @@ -2307,12 +2307,12 @@ H5TBinsert_field(hid_t loc_id, const char *dset_name, const char *field_name, hi if (H5Aclose(attr_id) < 0) goto out; - attr_id = H5I_BADID; + attr_id = H5I_INVALID_HID; /* close the member type */ if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end for */ /*------------------------------------------------------------------------- @@ -2334,11 +2334,11 @@ H5TBinsert_field(hid_t loc_id, const char *dset_name, const char *field_name, hi if (H5Aclose(attr_id) < 0) goto out; - attr_id = H5I_BADID; + attr_id = H5I_INVALID_HID; if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end fill_data */ ret_val = 0; @@ -2415,23 +2415,23 @@ herr_t H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name) { /* identifiers for the 1st original dataset */ - hid_t did_1 = H5I_BADID; - hid_t tid_1 = H5I_BADID; - hid_t sid_1 = H5I_BADID; - hid_t pid_1 = H5I_BADID; + hid_t did_1 = H5I_INVALID_HID; + hid_t tid_1 = H5I_INVALID_HID; + hid_t sid_1 = H5I_INVALID_HID; + hid_t pid_1 = H5I_INVALID_HID; /* identifiers for the 2nd new dataset */ - hid_t did_2 = H5I_BADID; - hid_t tid_2 = H5I_BADID; - hid_t sid_2 = H5I_BADID; - hid_t pid_2 = H5I_BADID; + hid_t did_2 = H5I_INVALID_HID; + hid_t tid_2 = H5I_INVALID_HID; + hid_t sid_2 = H5I_INVALID_HID; + hid_t pid_2 = H5I_INVALID_HID; /* identifiers for the 3rd final dataset */ - hid_t did_3 = H5I_BADID; - hid_t tid_3 = H5I_BADID; - hid_t member_type_id = H5I_BADID; - hid_t preserve_id = H5I_BADID; - hid_t read_type_id = H5I_BADID; - hid_t write_type_id = H5I_BADID; - hid_t attr_id = H5I_BADID; + hid_t did_3 = H5I_INVALID_HID; + hid_t tid_3 = H5I_INVALID_HID; + hid_t member_type_id = H5I_INVALID_HID; + hid_t preserve_id = H5I_INVALID_HID; + hid_t read_type_id = H5I_INVALID_HID; + hid_t write_type_id = H5I_INVALID_HID; + hid_t attr_id = H5I_INVALID_HID; size_t member_size; size_t type_size1; size_t type_size2; @@ -2515,7 +2515,7 @@ H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name) /* close the member type */ if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; H5free_memory(member_name); member_name = NULL; @@ -2598,7 +2598,7 @@ H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name) /* close the member type */ if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end if */ H5free_memory(member_name); @@ -2682,22 +2682,22 @@ H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name) /* end access to the property list */ if (H5Pclose(preserve_id) < 0) goto out; - preserve_id = H5I_BADID; + preserve_id = H5I_INVALID_HID; /* close the member type */ if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; /* close the read type */ if (H5Tclose(read_type_id) < 0) goto out; - read_type_id = H5I_BADID; + read_type_id = H5I_INVALID_HID; /* close the write type */ if (H5Tclose(write_type_id) < 0) goto out; - write_type_id = H5I_BADID; + write_type_id = H5I_INVALID_HID; HDfree(tmp_buf); tmp_buf = NULL; @@ -2769,18 +2769,18 @@ H5TBdelete_field(hid_t loc_id, const char *dset_name, const char *field_name) if (H5Aclose(attr_id) < 0) goto out; - attr_id = H5I_BADID; + attr_id = H5I_INVALID_HID; /* close the member type */ if (H5Tclose(member_type_id) < 0) goto out; - member_type_id = H5I_BADID; + member_type_id = H5I_INVALID_HID; } /* end for */ /* close data space. */ if (H5Sclose(sid_1) < 0) goto out; - sid_1 = H5I_BADID; + sid_1 = H5I_INVALID_HID; } /* end if */ ret_val = 0; @@ -2962,9 +2962,9 @@ H5TBAget_fill(hid_t loc_id, const char *dset_name, hid_t dset_id, unsigned char herr_t H5TBget_table_info(hid_t loc_id, const char *dset_name, hsize_t *nfields, hsize_t *nrecords) { - hid_t tid = H5I_BADID; - hid_t sid = H5I_BADID; - hid_t did = H5I_BADID; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; hsize_t dims[1]; int num_members; herr_t ret_val = -1; @@ -3008,7 +3008,7 @@ H5TBget_table_info(hid_t loc_id, const char *dset_name, hsize_t *nfields, hsize_ /* terminate access to the dataspace */ if (H5Sclose(sid) < 0) goto out; - sid = H5I_BADID; + sid = H5I_INVALID_HID; *nrecords = dims[0]; } /* end if */ @@ -3048,11 +3048,11 @@ herr_t H5TBget_field_info(hid_t loc_id, const char *dset_name, char *field_names[], size_t *field_sizes, size_t *field_offsets, size_t *type_size) { - hid_t did = H5I_BADID; /* dataset ID */ - hid_t tid = H5I_BADID; /* file type ID */ - hid_t n_tid = H5I_BADID; /* native type ID */ - hid_t m_tid = H5I_BADID; /* member type ID */ - hid_t nm_tid = H5I_BADID; /* native member ID */ + hid_t did = H5I_INVALID_HID; /* dataset ID */ + hid_t tid = H5I_INVALID_HID; /* file type ID */ + hid_t n_tid = H5I_INVALID_HID; /* native type ID */ + hid_t m_tid = H5I_INVALID_HID; /* member type ID */ + hid_t nm_tid = H5I_INVALID_HID; /* native member ID */ hssize_t nfields; hssize_t i; herr_t ret_val = -1; @@ -3111,10 +3111,10 @@ H5TBget_field_info(hid_t loc_id, const char *dset_name, char *field_names[], siz /* close the member types */ if (H5Tclose(m_tid) < 0) goto out; - m_tid = H5I_BADID; + m_tid = H5I_INVALID_HID; if (H5Tclose(nm_tid) < 0) goto out; - nm_tid = H5I_BADID; + nm_tid = H5I_INVALID_HID; } /* end for */ ret_val = 0; @@ -3267,9 +3267,9 @@ static hid_t H5TB_create_type(hid_t loc_id, const char *dset_name, size_t type_size, const size_t *field_offset, const size_t *field_sizes, hid_t ftype_id) { - hid_t mem_type_id = H5I_BADID; - hid_t mtype_id = H5I_BADID; - hid_t nmtype_id = H5I_BADID; + hid_t mem_type_id = H5I_INVALID_HID; + hid_t mtype_id = H5I_INVALID_HID; + hid_t nmtype_id = H5I_INVALID_HID; size_t size_native; hsize_t nfields = 0; char ** fnames = NULL; @@ -3310,10 +3310,10 @@ H5TB_create_type(hid_t loc_id, const char *dset_name, size_t type_size, const si goto out; if (H5Tclose(mtype_id) < 0) goto out; - mtype_id = H5I_BADID; + mtype_id = H5I_INVALID_HID; if (H5Tclose(nmtype_id) < 0) goto out; - nmtype_id = H5I_BADID; + nmtype_id = H5I_INVALID_HID; } /* end for */ ret_val = mem_type_id; @@ -3364,8 +3364,8 @@ herr_t H5TB_common_append_records(hid_t dataset_id, hid_t mem_type_id, size_t nrecords, hsize_t orig_table_size, const void *buf) { - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; hsize_t count[1]; hsize_t offset[1]; hsize_t dims[1]; @@ -3429,8 +3429,8 @@ herr_t H5TB_common_read_records(hid_t dataset_id, hid_t mem_type_id, hsize_t start, size_t nrecords, hsize_t table_size, void *buf) { - hid_t sid = H5I_BADID; - hid_t m_sid = H5I_BADID; + hid_t sid = H5I_INVALID_HID; + hid_t m_sid = H5I_INVALID_HID; hsize_t count[1]; hsize_t offset[1]; hsize_t mem_size[1]; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f19c62ab117..fbde308157a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -574,14 +574,6 @@ set (H5SM_HDRS IDE_GENERATED_PROPERTIES ("H5SM" "${H5SM_HDRS}" "${H5SM_SOURCES}" ) -set (H5ST_SOURCES - ${HDF5_SRC_DIR}/H5ST.c -) -set (H5ST_HDRS -) -IDE_GENERATED_PROPERTIES ("H5ST" "${H5ST_HDRS}" "${H5ST_SOURCES}" ) - - set (H5T_SOURCES ${HDF5_SRC_DIR}/H5T.c ${HDF5_SRC_DIR}/H5Tarray.c @@ -741,7 +733,6 @@ set (common_SRCS ${H5S_SOURCES} ${H5SL_SOURCES} ${H5SM_SOURCES} - ${H5ST_SOURCES} ${H5T_SOURCES} ${H5TS_SOURCES} ${H5VM_SOURCES} @@ -889,8 +880,6 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5SMpkg.h ${HDF5_SRC_DIR}/H5SMprivate.h - ${HDF5_SRC_DIR}/H5STprivate.h - ${HDF5_SRC_DIR}/H5Tpkg.h ${HDF5_SRC_DIR}/H5Tprivate.h @@ -1145,7 +1134,7 @@ if (NOT ONLY_SHARED_LIBS) ${HDF_EXTRA_FLAGS} PRIVATE $<$:H5_DEBUG_API> # Enable tracing of the API - $<$:H5Z_DEBUG;H5T_DEBUG;H5ST_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG> + $<$:H5Z_DEBUG;H5T_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG> ) TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC) target_link_libraries (${HDF5_LIB_TARGET} @@ -1187,7 +1176,7 @@ if (BUILD_SHARED_LIBS) PRIVATE $<$:H5_HAVE_THREADSAFE> $<$:H5_DEBUG_API> # Enable tracing of the API - $<$:H5Z_DEBUG;H5T_DEBUG;H5ST_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG> + $<$:H5Z_DEBUG;H5T_DEBUG;H5S_DEBUG;H5O_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5F_DEBUG;H5D_DEBUG;H5B2_DEBUG;H5AC_DEBUG> ) TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_LIBSH_TARGET} diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 38ea346c839..7214b75e15b 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -429,7 +429,7 @@ H5FD__log_fapl_copy(const void *_old_fa) if (new_fa->logfile) new_fa->logfile = (char *)H5MM_xfree(new_fa->logfile); H5MM_free(new_fa); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_fapl_copy() */ @@ -487,8 +487,8 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) #ifdef H5_HAVE_WIN32_API struct _BY_HANDLE_FILE_INFORMATION fileinfo; #endif - H5_timer_t open_timer = {{0}, {0}, {0}, FALSE}; /* Timer for open() call */ - H5_timer_t stat_timer = {{0}, {0}, {0}, FALSE}; /* Timer for stat() call */ + H5_timer_t open_timer; /* Timer for open() call */ + H5_timer_t stat_timer; /* Timer for stat() call */ h5_stat_t sb; H5FD_t * ret_value = NULL; /* Return value */ @@ -505,6 +505,10 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (ADDR_OVERFLOW(maxaddr)) HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr") + /* Initialize timers */ + H5_timer_init(&open_timer); + H5_timer_init(&stat_timer); + /* Build the open flags */ o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY; if (H5F_ACC_TRUNC & flags) @@ -521,10 +525,8 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "bad VFL driver info") /* Start timer for open() call */ - if (fa->flags & H5FD_LOG_TIME_OPEN) { - H5_timer_init(&open_timer); + if (fa->flags & H5FD_LOG_TIME_OPEN) H5_timer_start(&open_timer); - } /* end if */ /* Open the file */ if ((fd = HDopen(name, o_flags, H5_POSIX_CREATE_MODE_RW)) < 0) { @@ -534,17 +536,15 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', errno = %d, error message = '%s', flags = %x, o_flags = %x", name, myerrno, HDstrerror(myerrno), flags, (unsigned)o_flags); - } /* end if */ + } /* Stop timer for open() call */ if (fa->flags & H5FD_LOG_TIME_OPEN) H5_timer_stop(&open_timer); /* Start timer for stat() call */ - if (fa->flags & H5FD_LOG_TIME_STAT) { - H5_timer_init(&stat_timer); + if (fa->flags & H5FD_LOG_TIME_STAT) H5_timer_start(&stat_timer); - } /* end if */ /* Get the file stats */ if (HDfstat(fd, &sb) < 0) @@ -597,15 +597,15 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (file->fa.flags & H5FD_LOG_FILE_READ) { file->nread = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->nread); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_FILE_WRITE) { file->nwrite = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->nwrite); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_FLAVOR) { file->flavor = (unsigned char *)H5MM_calloc(file->iosize); HDassert(file->flavor); - } /* end if */ + } /* Set the log file pointer */ if (fa->logfile) @@ -619,14 +619,14 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5_timer_get_times(open_timer, &open_times); HDfprintf(file->logfp, "Open took: (%f s)\n", open_times.elapsed); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_TIME_STAT) { H5_timevals_t stat_times; /* Elapsed time for stat() call */ H5_timer_get_times(stat_timer, &stat_times); HDfprintf(file->logfp, "Stat took: (%f s)\n", stat_times.elapsed); - } /* end if */ - } /* end if */ + } + } /* Check the file locking flags in the fapl */ if (ignore_disabled_file_locks_s != FAIL) @@ -648,7 +648,7 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) if (H5P_exist_plist(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME) > 0) if (H5P_get(plist, H5F_ACS_FAMILY_TO_SINGLE_NAME, &file->fam_to_single) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, NULL, "can't get property of changing family to single") - } /* end if */ + } /* Set return value */ ret_value = (H5FD_t *)file; @@ -659,7 +659,7 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HDclose(fd); if (file) file = H5FL_FREE(H5FD_log_t, file); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_open() */ @@ -680,20 +680,21 @@ H5FD__log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) static herr_t H5FD__log_close(H5FD_t *_file) { - H5FD_log_t *file = (H5FD_log_t *)_file; - H5_timer_t close_timer = {{0}, {0}, {0}, FALSE}; /* Timer for close() call */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t *file = (H5FD_log_t *)_file; + H5_timer_t close_timer; /* Timer for close() call */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ HDassert(file); + /* Initialize timer */ + H5_timer_init(&close_timer); + /* Start timer for close() call */ - if (file->fa.flags & H5FD_LOG_TIME_CLOSE) { - H5_timer_init(&close_timer); + if (file->fa.flags & H5FD_LOG_TIME_CLOSE) H5_timer_start(&close_timer); - } /* end if */ /* Close the underlying file */ if (HDclose(file->fd) < 0) @@ -714,7 +715,7 @@ H5FD__log_close(H5FD_t *_file) H5_timer_get_times(close_timer, &close_times); HDfprintf(file->logfp, "Close took: (%f s)\n", close_times.elapsed); - } /* end if */ + } /* Dump the total number of seek/read/write operations */ if (file->fa.flags & H5FD_LOG_NUM_READ) @@ -749,13 +750,13 @@ H5FD__log_close(H5FD_t *_file) last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); last_val = file->nwrite[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ + } HDfprintf(file->logfp, "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) written to %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - } /* end if */ + } /* Dump the read I/O information */ if (file->fa.flags & H5FD_LOG_FILE_READ) { @@ -770,13 +771,13 @@ H5FD__log_close(H5FD_t *_file) last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); last_val = file->nread[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ + } HDfprintf(file->logfp, "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) read from %3d times\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), (int)last_val); - } /* end if */ + } /* Dump the I/O flavor information */ if (file->fa.flags & H5FD_LOG_FLAVOR) { @@ -791,12 +792,12 @@ H5FD__log_close(H5FD_t *_file) last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); last_val = file->flavor[addr]; last_addr = addr; - } /* end if */ + } addr++; - } /* end while */ + } HDfprintf(file->logfp, "\tAddr %10" PRIuHADDR "-%10" PRIuHADDR " (%10lu bytes) flavor is %s\n", last_addr, (addr - 1), (unsigned long)(addr - last_addr), flavors[last_val]); - } /* end if */ + } /* Free the logging information */ if (file->fa.flags & H5FD_LOG_FILE_WRITE) @@ -923,7 +924,7 @@ H5FD__log_query(const H5FD_t *_file, unsigned long *flags /* out */) if (file && file->fam_to_single) *flags |= H5FD_FEAT_IGNORE_DRVRINFO; /* Ignore the driver info when file is opened (which eliminates it) */ - } /* end if */ + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_query() */ @@ -962,13 +963,13 @@ H5FD__log_alloc(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, hs HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], (int)type, (size_t)size); - } /* end if */ + } if (file->fa.flags & H5FD_LOG_ALLOC) HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Allocated\n", addr, (haddr_t)((addr + size) - 1), size, flavors[type]); - } /* end if */ + } /* Set return value */ ret_value = addr; @@ -1001,13 +1002,13 @@ H5FD__log_free(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], H5FD_MEM_DEFAULT, (size_t)size); - } /* end if */ + } /* Log the file memory freed */ if (file->fa.flags & H5FD_LOG_FREE) HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Freed\n", addr, (haddr_t)((addr + size) - 1), size, flavors[type]); - } /* end if */ + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD__log_free() */ @@ -1068,14 +1069,14 @@ H5FD__log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) HDassert(addr < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[file->eoa], (int)type, (size_t)size); - } /* end if */ + } /* Log the extension like an allocation */ if (file->fa.flags & H5FD_LOG_ALLOC) HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Allocated\n", file->eoa, addr, size, flavors[type]); - } /* end if */ + } /* Check for decreasing file size */ if (H5F_addr_lt(addr, file->eoa) && H5F_addr_gt(addr, 0)) { @@ -1086,15 +1087,15 @@ H5FD__log_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr) HDassert((addr + size) < file->iosize); H5_CHECK_OVERFLOW(size, hsize_t, size_t); HDmemset(&file->flavor[addr], H5FD_MEM_DEFAULT, (size_t)size); - } /* end if */ + } /* Log the shrink like a free */ if (file->fa.flags & H5FD_LOG_FREE) HDfprintf(file->logfp, "%10" PRIuHADDR "-%10" PRIuHADDR " (%10" PRIuHSIZE " bytes) (%s) Freed\n", file->eoa, addr, size, flavors[type]); - } /* end if */ - } /* end if */ + } + } file->eoa = addr; @@ -1177,23 +1178,22 @@ static herr_t H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, void *buf /*out*/) { - H5FD_log_t * file = (H5FD_log_t *)_file; - size_t orig_size = size; /* Save the original size for later */ - haddr_t orig_addr = addr; - H5_timer_t read_timer = {{0}, {0}, {0}, FALSE}; /* Timer for read operation */ - H5_timevals_t read_times; /* Elapsed time for read operation */ -#ifndef H5_HAVE_PREADWRITE - H5_timer_t seek_timer; /* Timer for seek operation */ - H5_timevals_t seek_times; /* Elapsed time for seek operation */ -#endif /* H5_HAVE_PREADWRITE */ - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t * file = (H5FD_log_t *)_file; + size_t orig_size = size; /* Save the original size for later */ + haddr_t orig_addr = addr; + H5_timer_t read_timer; /* Timer for read operation */ + H5_timevals_t read_times; /* Elapsed time for read operation */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC HDassert(file && file->pub.cls); HDassert(buf); + /* Initialize timer */ + H5_timer_init(&read_timer); + /* Check for overflow conditions */ if (!H5F_addr_defined(addr)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined, addr = %llu", (unsigned long long)addr) @@ -1210,17 +1210,22 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDassert((addr + size) < file->iosize); while (tmp_size-- > 0) file->nread[tmp_addr++]++; - } /* end if */ - } /* end if */ + } + } #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pread) */ if (addr != file->pos || OP_READ != file->op) { + + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ + + /* Initialize timer */ + H5_timer_init(&seek_timer); + /* Start timer for seek() call */ - if (file->fa.flags & H5FD_LOG_TIME_SEEK) { - H5_timer_init(&seek_timer); + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_start(&seek_timer); - } /* end if */ if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") @@ -1237,7 +1242,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_get_times(seek_timer, &seek_times); file->total_seek_time += seek_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual seek events. */ if (file->fa.flags & H5FD_LOG_LOC_SEEK) { @@ -1251,15 +1256,13 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PREADWRITE */ + } + } +#endif /* H5_HAVE_PREADWRITE */ /* Start timer for read operation */ - if (file->fa.flags & H5FD_LOG_TIME_READ) { - H5_timer_init(&read_timer); + if (file->fa.flags & H5FD_LOG_TIME_READ) H5_timer_start(&read_timer); - } /* end if */ /* * Read data, being careful of interrupted system calls, partial results, @@ -1304,13 +1307,13 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDctime(&mytime), file->filename, file->fd, myerrno, HDstrerror(myerrno), buf, (unsigned long long)size, (unsigned long long)bytes_in, (unsigned long long)bytes_read, (unsigned long long)offset); - } /* end if */ + } if (0 == bytes_read) { - /* end of file but not end of format address space */ + /* End of file but not end of format address space */ HDmemset(buf, 0, size); break; - } /* end if */ + } HDassert(bytes_read >= 0); HDassert((size_t)bytes_read <= size); @@ -1318,8 +1321,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had size -= (size_t)bytes_read; addr += (haddr_t)bytes_read; buf = (char *)buf + bytes_read; - - } /* end while */ + } /* Stop timer for read operation */ if (file->fa.flags & H5FD_LOG_TIME_READ) @@ -1333,7 +1335,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had if (file->fa.flags & H5FD_LOG_TIME_READ) { H5_timer_get_times(read_timer, &read_times); file->total_read_time += read_times.elapsed; - } /* end if */ + } /* Log information about the read */ if (file->fa.flags & H5FD_LOG_LOC_READ) { @@ -1347,7 +1349,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] || (H5FD_mem_t)file->flavor[(orig_addr + orig_size) - 1] == H5FD_MEM_DEFAULT); - } /* end if */ + } /* Add the read time, if we're tracking that. * Note that the read time is NOT emitted for when just H5FD_LOG_TIME_READ @@ -1357,7 +1359,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had HDfprintf(file->logfp, " (%fs @ %f)\n", read_times.elapsed, read_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ + } /* Update current position */ file->pos = addr; @@ -1368,7 +1370,7 @@ H5FD__log_read(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, had /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_read() */ @@ -1391,17 +1393,13 @@ static herr_t H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, size_t size, const void *buf) { - H5FD_log_t * file = (H5FD_log_t *)_file; - size_t orig_size = size; /* Save the original size for later */ - haddr_t orig_addr = addr; - H5_timer_t write_timer = {{0}, {0}, {0}, FALSE}; /* Timer for write operation */ - H5_timevals_t write_times; /* Elapsed time for write operation */ -#ifndef H5_HAVE_PREADWRITE - H5_timer_t seek_timer; /* Timer for seek operation */ - H5_timevals_t seek_times; /* Elapsed time for seek operation */ -#endif /* H5_HAVE_PREADWRITE */ - HDoff_t offset = (HDoff_t)addr; - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_log_t * file = (H5FD_log_t *)_file; + size_t orig_size = size; /* Save the original size for later */ + haddr_t orig_addr = addr; + H5_timer_t write_timer; /* Timer for write operation */ + H5_timevals_t write_times; /* Elapsed time for write operation */ + HDoff_t offset = (HDoff_t)addr; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -1409,13 +1407,16 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDassert(size > 0); HDassert(buf); + /* Initialize timer */ + H5_timer_init(&write_timer); + /* Verify that we are writing out the type of data we allocated in this location */ if (file->flavor) { HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[addr] || (H5FD_mem_t)file->flavor[addr] == H5FD_MEM_DEFAULT); HDassert(type == H5FD_MEM_DEFAULT || type == (H5FD_mem_t)file->flavor[(addr + size) - 1] || (H5FD_mem_t)file->flavor[(addr + size) - 1] == H5FD_MEM_DEFAULT); - } /* end if */ + } /* Check for overflow conditions */ if (!H5F_addr_defined(addr)) @@ -1433,16 +1434,21 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDassert((addr + size) < file->iosize); while (tmp_size-- > 0) file->nwrite[tmp_addr++]++; - } /* end if */ + } #ifndef H5_HAVE_PREADWRITE /* Seek to the correct location (if we don't have pwrite) */ if (addr != file->pos || OP_WRITE != file->op) { + + H5_timer_t seek_timer; /* Timer for seek operation */ + H5_timevals_t seek_times; /* Elapsed time for seek operation */ + + /* Initialize timer */ + H5_timer_init(&seek_timer); + /* Start timer for seek() call */ - if (file->fa.flags & H5FD_LOG_TIME_SEEK) { - H5_timer_init(&seek_timer); + if (file->fa.flags & H5FD_LOG_TIME_SEEK) H5_timer_start(&seek_timer); - } /* end if */ if (HDlseek(file->fd, (HDoff_t)addr, SEEK_SET) < 0) HSYS_GOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position") @@ -1459,7 +1465,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha if (file->fa.flags & H5FD_LOG_TIME_SEEK) { H5_timer_get_times(seek_timer, &seek_times); file->total_seek_time += seek_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual seek events. */ if (file->fa.flags & H5FD_LOG_LOC_SEEK) { @@ -1473,15 +1479,13 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDfprintf(file->logfp, " (%fs @ %f)\n", seek_times.elapsed, seek_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ - } /* end if */ -#endif /* H5_HAVE_PREADWRITE */ + } + } +#endif /* H5_HAVE_PREADWRITE */ /* Start timer for write operation */ - if (file->fa.flags & H5FD_LOG_TIME_WRITE) { - H5_timer_init(&write_timer); + if (file->fa.flags & H5FD_LOG_TIME_WRITE) H5_timer_start(&write_timer); - } /* end if */ /* * Write the data, being careful of interrupted system calls and partial @@ -1548,7 +1552,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha if (file->fa.flags & H5FD_LOG_TIME_WRITE) { H5_timer_get_times(write_timer, &write_times); file->total_write_time += write_times.elapsed; - } /* end if */ + } /* Log information about the write */ if (file->fa.flags & H5FD_LOG_LOC_WRITE) { @@ -1561,8 +1565,8 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha if ((H5FD_mem_t)file->flavor[orig_addr] == H5FD_MEM_DEFAULT) { HDmemset(&file->flavor[orig_addr], (int)type, orig_size); HDfprintf(file->logfp, " (fresh)"); - } /* end if */ - } /* end if */ + } + } /* Add the write time, if we're tracking that. * Note that the write time is NOT emitted for when just H5FD_LOG_TIME_WRITE @@ -1572,7 +1576,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha HDfprintf(file->logfp, " (%fs @ %f)\n", write_times.elapsed, write_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ + } /* Update current position and eof */ file->pos = addr; @@ -1585,7 +1589,7 @@ H5FD__log_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id, ha /* Reset last file I/O information */ file->pos = HADDR_UNDEF; file->op = OP_UNKNOWN; - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD__log_write() */ @@ -1615,14 +1619,15 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ /* Extend the file to make sure it's large enough */ if (!H5F_addr_eq(file->eoa, file->eof)) { - H5_timer_t trunc_timer = {{0}, {0}, {0}, FALSE}; /* Timer for truncate operation */ - H5_timevals_t trunc_times; /* Elapsed time for truncate operation */ + H5_timer_t trunc_timer; /* Timer for truncate operation */ + H5_timevals_t trunc_times; /* Elapsed time for truncate operation */ + + /* Initialize timer */ + H5_timer_init(&trunc_timer); /* Start timer for truncate operation */ - if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { - H5_timer_init(&trunc_timer); + if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) H5_timer_start(&trunc_timer); - } /* end if */ #ifdef H5_HAVE_WIN32_API { @@ -1646,7 +1651,7 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ dwError = GetLastError(); if (dwError != NO_ERROR) HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL, "unable to set file pointer") - } /* end if */ + } if (0 == SetEndOfFile(file->hFile)) HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly") @@ -1669,7 +1674,7 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ if (file->fa.flags & H5FD_LOG_TIME_TRUNCATE) { H5_timer_get_times(trunc_timer, &trunc_times); file->total_truncate_time += trunc_times.elapsed; - } /* end if */ + } /* Emit log string if we're tracking individual truncate events. */ if (file->fa.flags & H5FD_LOG_TRUNCATE) { @@ -1683,7 +1688,7 @@ H5FD__log_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_ATTR_ HDfprintf(file->logfp, " (%fs @ %f)\n", trunc_times.elapsed, trunc_timer.initial.elapsed); else HDfprintf(file->logfp, "\n"); - } /* end if */ + } /* Update the eof value */ file->eof = file->eoa; diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 168bbe162eb..92266244f2f 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -35,6 +35,15 @@ #define TRUE 1 #endif +/* Windows doesn't like some POSIX names and redefines them with an + * underscore + */ +#ifdef _WIN32 +#define my_strdup _strdup +#else +#define my_strdup strdup +#endif + /* Loop through all mapped files */ #define UNIQUE_MEMBERS_CORE(MAP, ITER, SEEN, LOOPVAR) \ { \ @@ -103,9 +112,8 @@ typedef struct H5FD_multi_dxpl_t { } H5FD_multi_dxpl_t; /* Private functions */ -static char *my_strdup(const char *s); -static int compute_next(H5FD_multi_t *file); -static int open_members(H5FD_multi_t *file); +static int compute_next(H5FD_multi_t *file); +static int open_members(H5FD_multi_t *file); /* Callback prototypes */ static herr_t H5FD_multi_term(void); @@ -171,36 +179,6 @@ static const H5FD_class_t H5FD_multi_g = { H5FD_FLMAP_DEFAULT /*fl_map */ }; -/*------------------------------------------------------------------------- - * Function: my_strdup - * - * Purpose: Private version of strdup() - * - * Return: Success: Ptr to new copy of string - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Friday, August 13, 1999 - * - *------------------------------------------------------------------------- - */ -static char * -my_strdup(const char *s) -{ - char * x; - size_t str_len; - - if (!s) - return NULL; - str_len = strlen(s) + 1; - if (NULL == (x = (char *)malloc(str_len))) - return NULL; - memcpy(x, s, str_len); - - return x; -} - /*------------------------------------------------------------------------- * Function: H5FD_multi_init * diff --git a/src/H5MM.c b/src/H5MM.c index d17db16e262..b4447f61e77 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -449,11 +449,17 @@ H5MM_xstrdup(const char *s) FUNC_ENTER_NOAPI(NULL) +#if defined H5_MEMORY_ALLOC_SANITY_CHECK if (s) { if (NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDstrcpy(ret_value, s); - } /* end if */ + } +#else + if (s) + if (NULL == (ret_value = HDstrdup(s))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "string duplication failed") +#endif done: FUNC_LEAVE_NOAPI(ret_value) @@ -483,10 +489,15 @@ H5MM_strdup(const char *s) FUNC_ENTER_NOAPI(NULL) if (!s) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "null string") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "NULL string not allowed") +#if defined H5_MEMORY_ALLOC_SANITY_CHECK if (NULL == (ret_value = (char *)H5MM_malloc(HDstrlen(s) + 1))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDstrcpy(ret_value, s); +#else + if (NULL == (ret_value = HDstrdup(s))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "string duplication failed") +#endif done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5ST.c b/src/H5ST.c deleted file mode 100644 index 0b7b8581e29..00000000000 --- a/src/H5ST.c +++ /dev/null @@ -1,779 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* TERNARY SEARCH TREE ALGS - This code is described in "Ternary Search Trees" by Jon -Bentley and Robert Sedgewick in the April, 1998, Dr. Dobb's Journal. -*/ - -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5STprivate.h" /* Ternary search trees */ - -#ifdef H5ST_DEBUG -static herr_t H5ST__dump_internal(H5ST_ptr_t p); -#endif /* H5ST_DEBUG */ - -/* Declare a free list to manage the H5ST_node_t struct */ -H5FL_DEFINE_STATIC(H5ST_node_t); - -/* Declare a free list to manage the H5ST_tree_t struct */ -H5FL_DEFINE_STATIC(H5ST_tree_t); - -/*-------------------------------------------------------------------------- - NAME - H5ST_create - PURPOSE - Create a TST - USAGE - H5ST_ptr_t H5ST_create() - - RETURNS - Returns a pointer to the new TST tree on success, NULL on failure. - DESCRIPTION - Create a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_tree_t * -H5ST_create(void) -{ - H5ST_tree_t *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Allocate wrapper for TST */ - if (NULL == (ret_value = H5FL_MALLOC(H5ST_tree_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - - /* Set the internal fields */ - ret_value->root = NULL; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_create() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST__close_internal - PURPOSE - Close a TST, deallocating it. - USAGE - herr_t H5ST_close(p) - H5ST_ptr_t p; IN/OUT: Root of TST to free - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Close a TST, freeing all nodes. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5ST__close_internal(H5ST_ptr_t p) -{ - FUNC_ENTER_STATIC_NOERR - - /* Recursively free TST */ - if (p) { - H5ST__close_internal(p->lokid); - if (p->splitchar) - H5ST__close_internal(p->eqkid); - H5ST__close_internal(p->hikid); - p = H5FL_FREE(H5ST_node_t, p); - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST__close_internal() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_close - PURPOSE - Close a TST, deallocating it. - USAGE - herr_t H5ST_close(tree) - H5ST_tree_t *tree; IN/OUT: TST tree to free - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Close a TST, freeing all nodes. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_close(H5ST_tree_t *tree) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check arguments */ - if (NULL == tree) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid TST") - - /* Free the TST itself */ - if (H5ST__close_internal(tree->root) < 0) - HGOTO_ERROR(H5E_TST, H5E_CANTFREE, FAIL, "can't free TST") - - /* Free root node itself */ - tree = H5FL_FREE(H5ST_tree_t, tree); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_close() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_insert - PURPOSE - Insert a string/object pair into a TST - USAGE - herr_t H5ST_insert(tree,s,obj) - H5ST_tree_t *tree; IN/OUT: TST to insert string into - const char *s; IN: String to use as key for object - void *obj; IN: Pointer to object to insert - - RETURNS - Returns non-negative on success, negative on failure. - DESCRIPTION - Insert a key (string)/object pair into a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_insert(H5ST_tree_t *tree, const char *s, void *obj) -{ - int d; /* Comparison value */ - H5ST_ptr_t pp, *p; /* Pointer to current node and pointer to that */ - H5ST_ptr_t parent = NULL; /* Pointer to parent node */ - H5ST_ptr_t up = NULL; /* Pointer to up node */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Find the correct location to insert object */ - p = &tree->root; - while ((pp = *p)) { - /* If this node matches the character in the key, then drop down to the lower tree */ - if (0 == (d = *s - pp->splitchar)) { - if (*s++ == 0) - HGOTO_ERROR(H5E_TST, H5E_EXISTS, FAIL, "key already in tree") - up = pp; - p = &(pp->eqkid); - } /* end if */ - else { - /* Walk through the current tree, searching for the matching character */ - parent = pp; - if (d < 0) - p = &(pp->lokid); - else - p = &(pp->hikid); - } /* end else */ - } /* end while */ - - /* Finish walking through the key string, adding nodes until the end */ - for (;;) { - if (NULL == (*p = H5FL_MALLOC(H5ST_node_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - pp = *p; - pp->splitchar = *s; - pp->up = up; - pp->parent = parent; - pp->lokid = pp->eqkid = pp->hikid = NULL; - - /* If this is the end of the key string, break out */ - if (*s++ == 0) { - pp->eqkid = (H5ST_ptr_t)obj; - break; - } /* end if */ - - /* Continue to next character */ - parent = NULL; - up = pp; - p = &(pp->eqkid); - } /* end for */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_insert() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_search - PURPOSE - Determine if a key is in the TST - USAGE - hbool_t H5ST_search(tree,s) - H5ST_tree_t *tree; IN: TST to find string in - const char *s; IN: String to use as key to locate - - RETURNS - Success: TRUE if key string in TST, FALSE if not - Failure: negative - DESCRIPTION - Locate a key (string) in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -htri_t -H5ST_search(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t p; /* Temporary pointer to TST node */ - htri_t ret_value = FALSE; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - p = tree->root; - while (p) { - if (*s < p->splitchar) - p = p->lokid; - else if (*s == p->splitchar) { - if (*s++ == 0) - HGOTO_DONE(TRUE); - p = p->eqkid; - } - else - p = p->hikid; - } /* end while */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_search() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST__find_internal - PURPOSE - Find the node matching a particular key string - USAGE - H5ST_ptr_t H5ST_find(p,s) - H5ST_ptr_t p; IN: TST to find string in - const char *s; IN: String to use as key to locate - - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Locate a key (string) in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static H5ST_ptr_t -H5ST__find_internal(H5ST_ptr_t p, const char *s) -{ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - while (p) { - if (*s < p->splitchar) - p = p->lokid; - else if (*s == p->splitchar) { - if (*s++ == 0) - HGOTO_DONE(p); - p = p->eqkid; - } - else - p = p->hikid; - } /* end while */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST__find_internal() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_find - PURPOSE - Find the node matching a particular key string - USAGE - H5ST_ptr_t H5ST_find(tree,s) - H5ST_tree_t *tree; IN: TST to find string in - const char *s; IN: String to use as key to locate - - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Locate a key (string) in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_ptr_t -H5ST_find(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - if (NULL == (ret_value = H5ST__find_internal(tree->root, s))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_find() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_locate - PURPOSE - Find an object in a TST - USAGE - void *H5ST_locate(tree,s) - H5ST_tree_t *tree; IN: TST to locate object within - const char *s; IN: String of key for object to locate - RETURNS - Success: Non-NULL, pointer to object stored for key - Failure: Negative - DESCRIPTION - Locate a node in a TST, returning the object from the node. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -void * -H5ST_locate(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t node; /* Pointer to node located */ - void * ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Locate the node to remove */ - if (NULL == (node = H5ST__find_internal(tree->root, s))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") - - /* Get the pointer to the object to return */ - ret_value = node->eqkid; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5ST_locate() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST__findfirst_internal - PURPOSE - Find the first node in a TST - USAGE - H5ST_ptr_t H5ST__findfirst_internal(p) - H5ST_ptr_t p; IN: TST to locate first node within - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the first (lexicographically) node in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static H5ST_ptr_t -H5ST__findfirst_internal(H5ST_ptr_t p) -{ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - while (p) { - /* Find least node in current tree */ - while (p->lokid) - p = p->lokid; - - /* Is least node '\0'? */ - if (p->splitchar == '\0') { - /* Return it */ - HGOTO_DONE(p); - } /* end if */ - else { - /* Go down to next level of tree */ - p = p->eqkid; - } /* end else */ - } /* end while */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST__findfirst_internal() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_findfirst - PURPOSE - Find the first node in a TST - USAGE - H5ST_ptr_t H5ST_findfirst(tree) - H5ST_tree_t *tree; IN: TST to locate first node within - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the first (lexicographically) node in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_ptr_t -H5ST_findfirst(H5ST_tree_t *tree) -{ - H5ST_ptr_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - if (NULL == (ret_value = H5ST__findfirst_internal(tree->root))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "no nodes in TST"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_findfirst() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST__getnext - PURPOSE - Internal routine to find the next node in a given level of a TST - USAGE - H5ST_ptr_t H5ST__getnext(p) - H5ST_ptr_t *p; IN: Pointer to node to find next node from - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the next (lexicographically) node in the current level of a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static H5ST_ptr_t -H5ST__getnext(H5ST_ptr_t p) -{ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC_NOERR - - /* If the node to continue from has higher-valued nodes attached */ - if (p->hikid) { - /* Go to first higher-valued node */ - p = p->hikid; - - /* Find least node from here */ - while (p->lokid) - p = p->lokid; - HGOTO_DONE(p); - } /* end if */ - else { - H5ST_ptr_t q; /* Temporary TST node pointer */ - - /* Go up one level in current tree */ - q = p->parent; - if (q == NULL) - HGOTO_DONE(NULL); - - /* While the previous node was the higher-valued node, keep backing up the tree */ - while (q->hikid == p) { - p = q; - q = p->parent; - if (NULL == q) - HGOTO_DONE(NULL); - } /* end while */ - HGOTO_DONE(q); - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST__getnext() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_findnext - PURPOSE - Find the next node from a node in a TST - USAGE - H5ST_ptr_t H5ST_findnext(p) - H5ST_ptr_t p; IN: Current node to continue from - RETURNS - Success: Non-NULL - Failure: NULL - DESCRIPTION - Get the next (lexicographically) node in a TST - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -H5ST_ptr_t -H5ST_findnext(H5ST_ptr_t p) -{ - H5ST_ptr_t q; /* Temporary pointer to TST node */ - H5ST_ptr_t ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Find the next node at the current level, or go back up the tree */ - do { - q = H5ST__getnext(p); - if (q) { - HGOTO_DONE(H5ST__findfirst_internal(q->eqkid)); - } /* end if */ - else - p = p->up; - } while (p); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_findnext() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST__delete_internal - PURPOSE - Delete a node from a TST - USAGE - herr_t H5ST__delete_internal(root,p) - H5ST_ptr_t *root; IN/OUT: Root of TST to delete node from - H5ST_ptr_t p; IN: Node to delete - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Delete a node from a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This should be the final node for a string. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5ST__delete_internal(H5ST_ptr_t *root, H5ST_ptr_t p) -{ - H5ST_ptr_t q, /* Temporary pointer to TST node */ - newp; /* Pointer to node which will replace deleted node in tree */ - - FUNC_ENTER_STATIC_NOERR - - /* Find node to replace one being deleted */ - if (p->lokid) { - /* If the deleted node has lo & hi kids, attach them together */ - if (p->hikid) { - q = p->lokid; - while (q->hikid) - q = q->hikid; - q->hikid = p->hikid; - p->hikid->parent = q; - } /* end if */ - newp = p->lokid; - } /* end if */ - else if (p->hikid) { - newp = p->hikid; - } /* end if */ - else { - newp = NULL; - } /* end else */ - - /* Deleted node is in middle of tree */ - if (p->parent) { - /* Attach new node to correct side of parent */ - if (p == p->parent->lokid) - p->parent->lokid = newp; - else - p->parent->hikid = newp; - if (newp) - newp->parent = p->parent; - } /* end if */ - else { - if (newp) - newp->parent = p->parent; - if (p->up) { - p->up->eqkid = newp; - - /* If we deleted the last node in the TST, delete the upper node also */ - if (NULL == newp) - H5ST__delete_internal(root, p->up); - } /* end if */ - else /* Deleted last node at top level of tree */ - *root = newp; - } /* end else */ - - p = H5FL_FREE(H5ST_node_t, p); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST__delete_internal() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_delete - PURPOSE - Delete a node from a TST - USAGE - herr_t H5ST_delete(tree,p) - H5ST_tree_t *tree; IN/OUT: TST to delete node from - H5ST_ptr_t p; IN: Node to delete - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Delete a node from a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This should be the final node for a string. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_delete(H5ST_tree_t *tree, H5ST_ptr_t p) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - if (H5ST__delete_internal(&tree->root, p) < 0) - HGOTO_ERROR(H5E_TST, H5E_CANTDELETE, FAIL, "can't delete node from TST") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5ST_delete() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_remove - PURPOSE - Remove a node from a TST - USAGE - void *H5ST_remove(tree,s) - H5ST_tree_t *tree; IN/OUT: TST to remove node from - const char *s; IN: String of key for node to remove - RETURNS - Success: Non-NULL, pointer to object stored for key - Failure: Negative - DESCRIPTION - Remove a node from a TST, returning the object from the node. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -void * -H5ST_remove(H5ST_tree_t *tree, const char *s) -{ - H5ST_ptr_t node; /* Pointer to node to remove */ - void * ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Locate the node to remove */ - if (NULL == (node = H5ST__find_internal(tree->root, s))) - HGOTO_ERROR(H5E_TST, H5E_NOTFOUND, NULL, "key not found in TST") - - /* Get the pointer to the object to return */ - ret_value = node->eqkid; - - /* Remove the node from the TST */ - if (H5ST__delete_internal(&tree->root, node) < 0) - HGOTO_ERROR(H5E_TST, H5E_CANTDELETE, NULL, "can't delete node from TST") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5ST_remove() */ - -#ifdef H5ST_DEBUG - -/*-------------------------------------------------------------------------- - NAME - H5ST__dump_internal - PURPOSE - Dump all the nodes of a TST - USAGE - herr_t H5ST_dump(p) - H5ST_ptr_t p; IN: Root of TST to dump - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Dump information for a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5ST__dump_internal(H5ST_ptr_t p) -{ - FUNC_ENTER_STATIC_NOERR - - if (p) { - HDprintf("p=%p\n", (void *)p); - HDprintf("\tp->up=%p\n", (void *)p->up); - HDprintf("\tp->parent=%p\n", (void *)p->parent); - HDprintf("\tp->lokid=%p\n", (void *)p->lokid); - HDprintf("\tp->hikid=%p\n", (void *)p->hikid); - HDprintf("\tp->eqkid=%p\n", (void *)p->eqkid); - HDprintf("\tp->splitchar=%c\n", p->splitchar); - - H5ST__dump_internal(p->lokid); - if (p->splitchar) - H5ST__dump_internal(p->eqkid); - else - HDprintf("%s\n", (char *)p->eqkid); - H5ST__dump_internal(p->hikid); - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST__dump_internal() */ - -/*-------------------------------------------------------------------------- - NAME - H5ST_dump - PURPOSE - Dump all the nodes of a TST - USAGE - herr_t H5ST_dump(tree) - H5ST_tree_t *tree; IN: TST to dump - RETURNS - Success: Non-negative - Failure: Negative - DESCRIPTION - Dump information for a TST. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5ST_dump(H5ST_tree_t *tree) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Dump the tree */ - H5ST__dump_internal(tree->root); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5ST_dump() */ -#endif /* H5ST_DEBUG */ diff --git a/src/H5STprivate.h b/src/H5STprivate.h deleted file mode 100644 index 2d009fa7bc0..00000000000 --- a/src/H5STprivate.h +++ /dev/null @@ -1,63 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * This file contains private information about the H5ST module - */ -#ifndef H5STprivate_H -#define H5STprivate_H - -#ifdef LATER -#include "H5STpublic.h" -#endif /* LATER */ - -/* Private headers needed by this file */ -#include "H5private.h" - -/* Typedefs */ - -/* Internal nodes for TST */ -typedef struct H5ST_node *H5ST_ptr_t; -typedef struct H5ST_node { - char splitchar; /* Character represented at node */ - H5ST_ptr_t up; /* Pointer to the node in the tree above (before) this node */ - H5ST_ptr_t parent; /* Pointer to the next higher tree node in this tree */ - H5ST_ptr_t lokid; /* Pointer to the lower node from this one, in this tree */ - H5ST_ptr_t eqkid; /* Pointer to the parent node in the next tree down (after) this node */ - H5ST_ptr_t hikid; /* Pointer to the higher node from this one, in this tree */ -} H5ST_node_t; - -/* Wrapper about TST */ -typedef struct { - H5ST_ptr_t root; /* Pointer to actual TST */ -} H5ST_tree_t; - -/* Macro to access "data" pointer in H5ST_node_t's returned from functions */ -#define H5ST_NODE_DATA(p) ((void *)(p->eqkid)) - -/* Private routines */ -H5_DLL H5ST_tree_t *H5ST_create(void); -H5_DLL herr_t H5ST_close(H5ST_tree_t *p); -H5_DLL herr_t H5ST_insert(H5ST_tree_t *root, const char *s, void *obj); -H5_DLL htri_t H5ST_search(H5ST_tree_t *root, const char *s); -H5_DLL H5ST_ptr_t H5ST_find(H5ST_tree_t *root, const char *s); -H5_DLL void * H5ST_locate(H5ST_tree_t *root, const char *s); -H5_DLL H5ST_ptr_t H5ST_findfirst(H5ST_tree_t *p); -H5_DLL H5ST_ptr_t H5ST_findnext(H5ST_ptr_t p); -H5_DLL void * H5ST_remove(H5ST_tree_t *root, const char *s); -H5_DLL herr_t H5ST_delete(H5ST_tree_t *root, H5ST_ptr_t p); -#ifdef H5ST_DEBUG -H5_DLL herr_t H5ST_dump(H5ST_tree_t *tree); -#endif /* H5ST_DEBUG */ - -#endif /* H5STprivate_H */ diff --git a/src/Makefile.am b/src/Makefile.am index 75e04616429..00fb02368b0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -110,7 +110,6 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Sselect.c H5Stest.c \ H5SL.c \ H5SM.c H5SMbtree2.c H5SMcache.c H5SMmessage.c H5SMtest.c \ - H5ST.c \ H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c H5Tcompound.c H5Tconv.c \ H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c \ H5Tfixed.c \ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ecfef575f5c..eeac12eab04 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -189,7 +189,6 @@ set (testhdf5_SOURCES ${HDF5_TEST_SOURCE_DIR}/tskiplist.c ${HDF5_TEST_SOURCE_DIR}/tsohm.c ${HDF5_TEST_SOURCE_DIR}/ttime.c - ${HDF5_TEST_SOURCE_DIR}/ttst.c ${HDF5_TEST_SOURCE_DIR}/tunicode.c ${HDF5_TEST_SOURCE_DIR}/tvltypes.c ${HDF5_TEST_SOURCE_DIR}/tvlstr.c diff --git a/test/Makefile.am b/test/Makefile.am index b67792764f9..045686de13f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -213,7 +213,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse # Sources for testhdf5 executable testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ tgenprop.c th5o.c th5s.c tcoords.c theap.c tid.c titerate.c tmeta.c tmisc.c \ - trefer.c trefstr.c tselect.c tskiplist.c tsohm.c ttime.c ttst.c tunicode.c \ + trefer.c trefstr.c tselect.c tskiplist.c tsohm.c ttime.c tunicode.c \ tvlstr.c tvltypes.c # Sources for Use Cases diff --git a/test/cache_common.c b/test/cache_common.c index 089f9a0d311..d8a271ccb05 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -2766,7 +2766,6 @@ flush_cache(H5F_t *file_ptr, hbool_t destroy_entries, hbool_t dump_stats, hbool_ if (pass) { H5C_t *cache_ptr; - herr_t result = 0; HDassert(file_ptr); diff --git a/test/dtypes.c b/test/dtypes.c index 03516a14de9..30585af7e57 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1485,7 +1485,7 @@ test_compound_8(void) struct s2 { char c; s1 d; - } s2; + }; hid_t tid1, tid1_copy, tid2, tid2_copy, tid3, arr_tid; size_t tsize; hsize_t dims[1] = {ARRAY_DIM}; diff --git a/test/reserved.c b/test/reserved.c index 1ea73a6e6f5..6e41a1695a7 100644 --- a/test/reserved.c +++ b/test/reserved.c @@ -126,7 +126,7 @@ rsrv_heap(void) /* If we can read a dataset from the file, the file has been flushed to disk * (if the heap or object headers weren't flushed, the file would be empty). */ - if (dataset_id == H5I_BADID) + if (dataset_id == H5I_INVALID_HID) TEST_ERROR; if (H5Dclose(dataset_id) < 0) @@ -268,7 +268,7 @@ rsrv_ohdr(void) /* If we can read the dataset from the file, the file has been flushed to disk * (if the heap or object headers weren't flushed, the file would be empty). */ - if (dataset_id == H5I_BADID) + if (dataset_id == H5I_INVALID_HID) TEST_ERROR; if (H5Dclose(dataset_id) < 0) @@ -432,7 +432,7 @@ rsrv_vlen(void) /* If we can read the dataset from the file, the file has been flushed to disk * (if the heap or object headers weren't flushed, the file would be empty). */ - if (dataset_id == H5I_BADID) + if (dataset_id == H5I_INVALID_HID) TEST_ERROR; if (H5Dclose(dataset_id) < 0) diff --git a/test/testhdf5.c b/test/testhdf5.c index 3585c447983..2991d0b513a 100644 --- a/test/testhdf5.c +++ b/test/testhdf5.c @@ -45,7 +45,6 @@ main(int argc, char *argv[]) AddTest("config", test_configure, cleanup_configure, "Configure definitions", NULL); AddTest("metadata", test_metadata, cleanup_metadata, "Encoding/decoding metadata", NULL); AddTest("checksum", test_checksum, cleanup_checksum, "Checksum algorithm", NULL); - AddTest("tst", test_tst, NULL, "Ternary Search Trees", NULL); AddTest("heap", test_heap, NULL, "Memory Heaps", NULL); AddTest("skiplist", test_skiplist, NULL, "Skip Lists", NULL); AddTest("refstr", test_refstr, NULL, "Reference Counted Strings", NULL); diff --git a/test/testhdf5.h b/test/testhdf5.h index feaa3d82572..a38309aecd1 100644 --- a/test/testhdf5.h +++ b/test/testhdf5.h @@ -203,7 +203,6 @@ extern "C" { /* Prototypes for the test routines */ void test_metadata(void); void test_checksum(void); -void test_tst(void); void test_heap(void); void test_refstr(void); void test_file(void); diff --git a/test/theap.c b/test/theap.c index f8a6e9b1626..9d5787bbdcf 100644 --- a/test/theap.c +++ b/test/theap.c @@ -1050,7 +1050,7 @@ test_heap_term(void) HDfree(inc_sort_num); if (dec_sort_num) HDfree(dec_sort_num); -} /* end test_tst_term() */ +} /* end test_heap_term() */ /**************************************************************** ** diff --git a/test/ttst.c b/test/ttst.c deleted file mode 100644 index 07f118cf28b..00000000000 --- a/test/ttst.c +++ /dev/null @@ -1,391 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - FILE - tst.c - Test HDF Ternary Search Tree (tst) routines. - - REMARKS - - DESIGN - - BUGS/LIMITATIONS - - EXPORTED ROUTINES - - AUTHOR - Quincey Koziol - - MODIFICATION HISTORY - 12/9/02 - Started coding - */ - -#include "testhdf5.h" -#include "H5STprivate.h" - -/* Test words to insert into s TST */ -static const char *words[] = { - "We", "hold", "these", "truths", "to", "be", "self-evident,", - "that", "all", "men", "are", "created", "equal,", "that", - "they", "are", "endowed", "by", "their", "Creator", "with", - "certain", "unalienable", "Rights,", "that", "among", "these", "are", - "Life,", "Liberty", "and", "the", "pursuit", "of", "Happiness."}; -/* Number of words in test words set */ -size_t num_words; - -/* Number of unique words in test word set */ -size_t num_uniq_words; -/* Unique words in test word set */ -char **uniq_words; -/* Randomized order version of words in test word set */ -char **rand_uniq_words; -/* Sorted order version of words in test word set */ -char **sort_uniq_words; - -static int -tst_strcmp(const void *_s1, const void *_s2) -{ - return (HDstrcmp(*(const char *const *)_s1, *(const char *const *)_s2)); -} - -/**************************************************************** -** -** test_tst_init(): Test basic H5ST (ternary search tree) selection code. -** Initialize data for TST testing -** -****************************************************************/ -static void -test_tst_init(void) -{ - time_t curr_time; /* Current time, for seeding random number generator */ - char * tmp_word; /* Temporary pointer to word in word set */ - size_t u, v, w; /* Local index variables */ - - /* Compute the number of words in the test set */ - num_words = sizeof(words) / sizeof(words[0]); - - /* Determine the number of unique words in test set */ - /* (Not particularly efficient, be careful if many words are added to set) */ - num_uniq_words = 0; - for (u = 0; u < num_words; u++) { - /* Assume word is unique */ - num_uniq_words++; - for (v = 0; v < u; v++) - /* If word is already found in words looked at, decrement unique count */ - if (!HDstrcmp(words[u], words[v])) { - num_uniq_words--; - break; - } /* end if */ - } /* end for */ - - /* Allocate space for the array of unique words */ - uniq_words = (char **)HDmalloc(sizeof(char *) * num_uniq_words); - - /* Allocate space for the array of randomized order unique words also */ - rand_uniq_words = (char **)HDmalloc(sizeof(char *) * num_uniq_words); - - /* Allocate space for the array of sorted order unique words also */ - sort_uniq_words = (char **)HDmalloc(sizeof(char *) * num_uniq_words); - - /* Insert unique words from test set into unique word set */ - w = 0; - for (u = 0; u < num_words; u++) { - /* Assume word is unique */ - tmp_word = (char *)words[u]; - for (v = 0; v < u; v++) - /* If word is already found in words looked at, decrement unique count */ - if (!HDstrcmp(words[u], words[v])) { - tmp_word = NULL; - break; - } /* end if */ - - /* Check if word was actually unique */ - if (tmp_word != NULL) - uniq_words[w++] = tmp_word; - } /* end for */ - - /* Create randomized set of unique words */ - for (u = 0; u < num_uniq_words; u++) - rand_uniq_words[u] = uniq_words[u]; - curr_time = HDtime(NULL); - HDsrandom((unsigned)curr_time); - for (u = 0; u < num_uniq_words; u++) { - v = u + ((size_t)HDrandom() % (num_uniq_words - u)); - if (u != v) { - tmp_word = rand_uniq_words[u]; - rand_uniq_words[u] = rand_uniq_words[v]; - rand_uniq_words[v] = tmp_word; - } /* end if */ - } /* end for */ - - /* Create sorted set of unique words */ - for (u = 0; u < num_uniq_words; u++) - sort_uniq_words[u] = uniq_words[u]; - HDqsort(sort_uniq_words, num_uniq_words, sizeof(char *), tst_strcmp); -} /* end test_tst_init() */ - -/**************************************************************** -** -** test_tst_create(): Test basic H5ST (ternary search tree) selection code. -** Tests creating and closing TSTs. -** -****************************************************************/ -static void -test_tst_create(void) -{ - H5ST_tree_t *tree; /* TST created */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(5, ("Testing Creating & Closing TSTs\n")); - - /* Try closing a NULL tree */ - tree = NULL; - ret = H5ST_close(tree); - VERIFY(ret, FAIL, "H5ST_close"); - - /* Try creating a TST */ - tree = H5ST_create(); - CHECK_PTR(tree, "H5ST_create"); - - /* Try closing a real tree */ - ret = H5ST_close(tree); - CHECK(ret, FAIL, "H5ST_close"); - -} /* end test_tst_create() */ - -/**************************************************************** -** -** test_tst_insert(): Test basic H5ST (ternary search tree) selection code. -** Tests inserting key/value pairs into TST -** -****************************************************************/ -static void -test_tst_insert(void) -{ - H5ST_tree_t *tree; /* TST created */ - H5ST_ptr_t found; /* Pointer to TST node found */ - void * obj; /* Pointer to object located in TST */ - size_t u; /* Local index counter */ - htri_t check; /* Is string in TST? */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(5, ("Testing Inserting Values into TSTs\n")); - - /* Create the TST */ - tree = H5ST_create(); - CHECK_PTR(tree, "H5ST_create"); - - /* Insert unique words into TST, in random order */ - for (u = 0; u < num_uniq_words; u++) { - ret = H5ST_insert(tree, rand_uniq_words[u], rand_uniq_words[u]); - CHECK(ret, FAIL, "H5ST_insert"); - } /* end for */ - - /* Verify that all words were inserted into TST properly */ - for (u = 0; u < num_uniq_words; u++) { - /* Check that the word is present */ - check = H5ST_search(tree, uniq_words[u]); - VERIFY(check, TRUE, "H5ST_search"); - - /* Check that the value "payloads" are correct */ - found = H5ST_find(tree, uniq_words[u]); - CHECK_PTR(found, "H5ST_find"); - - if (HDstrcmp((const char *)found->eqkid, uniq_words[u]) != 0) - TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, uniq_words[%u]=%s\n", __LINE__, - (char *)found->eqkid, (unsigned)u, uniq_words[u]); - - obj = H5ST_locate(tree, uniq_words[u]); - CHECK_PTR(obj, "H5ST_locate"); - - if (HDstrcmp((const char *)obj, uniq_words[u]) != 0) - TestErrPrintf("%d: TST objects don't match!, obj=%s, uniq_words[%u]=%s\n", __LINE__, (char *)obj, - (unsigned)u, uniq_words[u]); - } /* end for */ - - /* Verify that words not in the TST aren't found */ - check = H5ST_search(tree, "foo"); - VERIFY(check, FALSE, "H5ST_search"); - check = H5ST_search(tree, "bar"); - VERIFY(check, FALSE, "H5ST_search"); - check = H5ST_search(tree, "baz"); - VERIFY(check, FALSE, "H5ST_search"); - - /* Close the TST */ - ret = H5ST_close(tree); - CHECK(ret, FAIL, "H5ST_close"); -} /* end test_tst_insert() */ - -/**************************************************************** -** -** test_tst_iterate(): Test basic H5ST (ternary search tree) code. -** Tests iterating through key/value pairs in TST -** -****************************************************************/ -static void -test_tst_iterate(void) -{ - H5ST_tree_t *tree; /* TST created */ - H5ST_ptr_t found; /* Pointer to TST node found */ - size_t u; /* Local index counter */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(5, ("Testing Iterating Over TSTs\n")); - - /* Create the TST */ - tree = H5ST_create(); - CHECK_PTR(tree, "H5ST_create"); - - /* Insert unique words into TST, in random order */ - for (u = 0; u < num_uniq_words; u++) { - ret = H5ST_insert(tree, rand_uniq_words[u], rand_uniq_words[u]); - CHECK(ret, FAIL, "H5ST_insert"); - } /* end for */ - - /* Use findfirst/findnext calls to iterate through TST */ - found = H5ST_findfirst(tree); - CHECK_PTR(found, "H5ST_findfirst"); - u = 0; - do { - /* Check that the strings in the TST are in the correct order */ - if (HDstrcmp((const char *)found->eqkid, sort_uniq_words[u]) != 0) - TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, sort_uniq_words[%u]=%s\n", - __LINE__, (char *)found->eqkid, (unsigned)u, sort_uniq_words[u]); - - /* Advance to next string in TST */ - found = H5ST_findnext(found); - u++; - } while (found != NULL); - - /* Close the TST */ - ret = H5ST_close(tree); - CHECK(ret, FAIL, "H5ST_close"); -} /* end test_tst_iterate() */ - -/**************************************************************** -** -** test_tst_remove(): Test basic H5ST (ternary search tree) code. -** Tests removing key/value pairs by string value in TST -** -****************************************************************/ -static void -test_tst_remove(void) -{ - H5ST_tree_t *tree; /* TST created */ - H5ST_ptr_t found; /* Pointer to TST node found */ - void * obj; /* Pointer to object removed from TST */ - htri_t check; /* Is string in TST? */ - size_t u; /* Local index counter */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(5, ("Testing Removing String Values from TSTs\n")); - - /* Create the TST */ - tree = H5ST_create(); - CHECK_PTR(tree, "H5ST_create"); - - /* Insert unique words into TST, in random order */ - for (u = 0; u < num_uniq_words; u++) { - ret = H5ST_insert(tree, rand_uniq_words[u], rand_uniq_words[u]); - CHECK(ret, FAIL, "H5ST_insert"); - } /* end for */ - - /* Remove strings from TST in random order */ - for (u = 0; u < num_uniq_words; u++) { - obj = H5ST_remove(tree, rand_uniq_words[u]); - CHECK_PTR(obj, "H5ST_remove"); - - /* Check that the correct string was removed from TST */ - if (HDstrcmp((const char *)obj, rand_uniq_words[u]) != 0) - TestErrPrintf("%d: TST node values don't match!, obj=%s, rand_uniq_words[%u]=%s\n", __LINE__, - (char *)obj, (unsigned)u, rand_uniq_words[u]); - - /* Check that the string can't be found in the TST any longer */ - check = H5ST_search(tree, rand_uniq_words[u]); - VERIFY(check, FALSE, "H5ST_search"); - } /* end for */ - - /* Re-insert unique words into TST, in random order */ - for (u = 0; u < num_uniq_words; u++) { - ret = H5ST_insert(tree, rand_uniq_words[u], rand_uniq_words[u]); - CHECK(ret, FAIL, "H5ST_insert"); - } /* end for */ - - /* Remove TST nodes from TST in random order */ - for (u = 0; u < num_uniq_words; u++) { - /* Get the pointer to the node to delete */ - found = H5ST_find(tree, rand_uniq_words[u]); - CHECK_PTR(found, "H5ST_find"); - - /* Check that the correct object will be removed from TST */ - if (HDstrcmp((const char *)found->eqkid, rand_uniq_words[u]) != 0) - TestErrPrintf("%d: TST node values don't match!, found->eqkid=%s, rand_uniq_words[%u]=%s\n", - __LINE__, (char *)found->eqkid, (unsigned)u, rand_uniq_words[u]); - - /* Remove the node */ - ret = H5ST_delete(tree, found); - CHECK(ret, FAIL, "H5ST_delete"); - - /* Check that the string can't be found in the TST any longer */ - check = H5ST_search(tree, rand_uniq_words[u]); - VERIFY(check, FALSE, "H5ST_search"); - } /* end for */ - - /* Close the TST */ - ret = H5ST_close(tree); - CHECK(ret, FAIL, "H5ST_close"); -} /* end test_tst_remove() */ - -/**************************************************************** -** -** test_tst_finalize(): Test basic H5ST (ternary search tree) selection code. -** Wrap up data for TST testing -** -****************************************************************/ -static void -test_tst_finalize(void) -{ - /* Release memory for unordered, randomized and sorted order unique words */ - HDfree(uniq_words); - HDfree(rand_uniq_words); - HDfree(sort_uniq_words); -} /* end test_tst_finalize() */ - -/**************************************************************** -** -** test_tst(): Main H5ST selection testing routine. -** -****************************************************************/ -void -test_tst(void) -{ - /* Output message about test being performed */ - MESSAGE(5, ("Testing Ternary Search Trees\n")); - - /* Initialize TST testing data */ - test_tst_init(); - - /* Actual TST tests */ - test_tst_create(); /* Test TST creation */ - test_tst_insert(); /* Test TST insertion */ - test_tst_iterate(); /* Test TST iteration */ - test_tst_remove(); /* Test TST deletion */ - - /* Finalize TST testing data */ - test_tst_finalize(); -} /* end test_tst() */ diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index 8947a293b8e..db0ef13f5f7 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -57,9 +57,9 @@ macro (ADD_VFD_TEST vfdname resultcode) WORKING_DIRECTORY ${HDF5_TEST_PAR_BINARY_DIR}/${vfdname} ) endforeach () - set_tests_properties (MPI_TEST_VFD-${vfdname}-pflush1 PROPERTIES WILL_FAIL "true") + set_tests_properties (MPI_TEST_VFD-${vfdname}-t_pflush1 PROPERTIES WILL_FAIL "true") #set_property (TEST MPI_TEST_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") - set_tests_properties (MPI_TEST_VFD-${vfdname}-pflush2 PROPERTIES DEPENDS MPI_TEST_VFD-${vfdname}-pflush1) + set_tests_properties (MPI_TEST_VFD-${vfdname}-t_pflush2 PROPERTIES DEPENDS MPI_TEST_VFD-${vfdname}-t_pflush1) endif () endmacro ()