diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2023-08-25 20:56:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-25 20:56:50 (GMT) |
commit | 627f7c5e026a55f176d8dfcab51633cf3b704ce6 (patch) | |
tree | b8ef6ca645521104c25a7b5538259bb449d51c58 /src/H5FDonion_index.c | |
parent | 3dd60d914e762c6cf7d99646bc516015229176cd (diff) | |
download | hdf5-627f7c5e026a55f176d8dfcab51633cf3b704ce6.zip hdf5-627f7c5e026a55f176d8dfcab51633cf3b704ce6.tar.gz hdf5-627f7c5e026a55f176d8dfcab51633cf3b704ce6.tar.bz2 |
Convert some H5MM calls to standard C equivalents (#2382)
* H5MM_calloc and malloc are now mapped to stdlib C calls
* H5MM_memcpy now maps directly to memcpy in release builds
* H5MM_memcpy is still implemented as a separate function that
checks for buffer overlap when H5MM_DEBUG is defined
(default w/ debug builds)
* Switches many library memcpy calls to use H5MM_memcpy
* Fixes a possible zero allocation in H5Olayout.c
Diffstat (limited to 'src/H5FDonion_index.c')
-rw-r--r-- | src/H5FDonion_index.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/H5FDonion_index.c b/src/H5FDonion_index.c index a6215ab..fae87ca 100644 --- a/src/H5FDonion_index.c +++ b/src/H5FDonion_index.c @@ -483,7 +483,7 @@ H5FD__onion_revision_index_insert(H5FD_onion_revision_index_t *rix, const H5FD_o if (entry->phys_addr != node->entry_data.phys_addr) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "physical address mismatch"); } - memcpy(&node->entry_data, entry, sizeof(H5FD_onion_index_entry_t)); + H5MM_memcpy(&node->entry_data, entry, sizeof(H5FD_onion_index_entry_t)); append_dest = NULL; /* Node updated, do not append */ break; } @@ -496,7 +496,7 @@ H5FD__onion_revision_index_insert(H5FD_onion_revision_index_t *rix, const H5FD_o HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "cannot allocate new ash chain node"); node->version = H5FD_ONION_REVISION_INDEX_HASH_CHAIN_NODE_VERSION_CURR; node->next = NULL; - memcpy(&node->entry_data, entry, sizeof(H5FD_onion_index_entry_t)); + H5MM_memcpy(&node->entry_data, entry, sizeof(H5FD_onion_index_entry_t)); *append_dest = node; rix->n_entries++; } @@ -612,25 +612,25 @@ H5FD__onion_revision_record_decode(unsigned char *buf, H5FD_onion_revision_recor ptr = buf + 8; - memcpy(&ui64, ptr, 8); + H5MM_memcpy(&ui64, ptr, 8); ui8p = (uint8_t *)&ui64; UINT64DECODE(ui8p, record->revision_num); ptr += 8; - memcpy(&ui64, ptr, 8); + H5MM_memcpy(&ui64, ptr, 8); ui8p = (uint8_t *)&ui64; UINT64DECODE(ui8p, record->parent_revision_num); ptr += 8; - memcpy(record->time_of_creation, ptr, 16); + H5MM_memcpy(record->time_of_creation, ptr, 16); ptr += 16; - memcpy(&ui64, ptr, 8); + H5MM_memcpy(&ui64, ptr, 8); ui8p = (uint8_t *)&ui64; UINT64DECODE(ui8p, record->logical_eof); ptr += 8; - memcpy(&ui32, ptr, 4); + H5MM_memcpy(&ui32, ptr, 4); ui8p = (uint8_t *)&ui32; UINT32DECODE(ui8p, page_size); ptr += 4; @@ -645,12 +645,12 @@ H5FD__onion_revision_record_decode(unsigned char *buf, H5FD_onion_revision_recor record->archival_index.page_size_log2++) ; - memcpy(&ui64, ptr, 8); + H5MM_memcpy(&ui64, ptr, 8); ui8p = (uint8_t *)&ui64; UINT64DECODE(ui8p, n_entries); ptr += 8; - memcpy(&ui32, ptr, 4); + H5MM_memcpy(&ui32, ptr, 4); ui8p = (uint8_t *)&ui32; UINT32DECODE(ui8p, comment_size); ptr += 4; @@ -671,7 +671,7 @@ H5FD__onion_revision_record_decode(unsigned char *buf, H5FD_onion_revision_recor for (size_t i = 0; i < n_entries; i++) { entry = &record->archival_index.list[i]; - memcpy(&ui64, ptr, 8); + H5MM_memcpy(&ui64, ptr, 8); ui8p = (uint8_t *)&ui64; UINT64DECODE(ui8p, entry->logical_page); ptr += 8; @@ -682,12 +682,12 @@ H5FD__onion_revision_record_decode(unsigned char *buf, H5FD_onion_revision_recor entry->logical_page = entry->logical_page >> record->archival_index.page_size_log2; - memcpy(&ui64, ptr, 8); + H5MM_memcpy(&ui64, ptr, 8); ui8p = (uint8_t *)&ui64; UINT64DECODE(ui8p, entry->phys_addr); ptr += 8; - memcpy(&ui32, ptr, 4); + H5MM_memcpy(&ui32, ptr, 4); ui8p = (uint8_t *)&ui32; UINT32DECODE(ui8p, sum); ptr += 4; @@ -706,13 +706,13 @@ H5FD__onion_revision_record_decode(unsigned char *buf, H5FD_onion_revision_recor else { if (record->comment == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "no comment pointer"); - memcpy(record->comment, ptr, comment_size); + H5MM_memcpy(record->comment, ptr, comment_size); } ptr += comment_size; sum = H5_checksum_fletcher32(buf, (size_t)(ptr - buf)); - memcpy(&ui32, ptr, 4); + H5MM_memcpy(&ui32, ptr, 4); ui8p = (uint8_t *)&ui32; UINT32DECODE(ui8p, record->checksum); ptr += 4; @@ -765,12 +765,12 @@ H5FD__onion_revision_record_encode(H5FD_onion_revision_record_t *record, unsigne page_size = (uint32_t)(1 << record->archival_index.page_size_log2); - memcpy(ptr, H5FD_ONION_REVISION_RECORD_SIGNATURE, 4); + H5MM_memcpy(ptr, H5FD_ONION_REVISION_RECORD_SIGNATURE, 4); ptr += 4; UINT32ENCODE(ptr, vers_u32); UINT64ENCODE(ptr, record->revision_num); UINT64ENCODE(ptr, record->parent_revision_num); - memcpy(ptr, record->time_of_creation, 16); + H5MM_memcpy(ptr, record->time_of_creation, 16); ptr += 16; UINT64ENCODE(ptr, record->logical_eof); UINT32ENCODE(ptr, page_size); @@ -798,7 +798,7 @@ H5FD__onion_revision_record_encode(H5FD_onion_revision_record_t *record, unsigne if (record->comment_size > 0) { assert(record->comment != NULL && *record->comment != '\0'); - memcpy(ptr, record->comment, record->comment_size); + H5MM_memcpy(ptr, record->comment, record->comment_size); ptr += record->comment_size; } @@ -876,7 +876,8 @@ H5FD__onion_merge_revision_index_into_archival_index(const H5FD_onion_revision_i const H5FD_onion_revision_index_hash_chain_node_t *node = NULL; for (node = rix->_hash_table[i]; node != NULL; node = node->next) { - memcpy(&new_aix.list[new_aix.n_entries], &node->entry_data, sizeof(H5FD_onion_index_entry_t)); + H5MM_memcpy(&new_aix.list[new_aix.n_entries], &node->entry_data, + sizeof(H5FD_onion_index_entry_t)); new_aix.n_entries++; } } @@ -901,7 +902,7 @@ H5FD__onion_merge_revision_index_into_archival_index(const H5FD_onion_revision_i /* Add only if page not already added from revision index */ if (H5FD__onion_archival_index_find(&new_aix, aix->list[i].logical_page, &entry) == 0) { - memcpy(&kept_list[n_kept], &aix->list[i], sizeof(H5FD_onion_index_entry_t)); + H5MM_memcpy(&kept_list[n_kept], &aix->list[i], sizeof(H5FD_onion_index_entry_t)); n_kept++; } } @@ -914,12 +915,12 @@ H5FD__onion_merge_revision_index_into_archival_index(const H5FD_onion_revision_i HGOTO_ERROR(H5E_VFL, H5E_CANTALLOC, FAIL, "unable to allocate exact-size archival index list"); /* Copy (new) revision list entries to replacement list */ - memcpy(aix->list, new_aix.list, sizeof(H5FD_onion_index_entry_t) * new_aix.n_entries); + H5MM_memcpy(aix->list, new_aix.list, sizeof(H5FD_onion_index_entry_t) * new_aix.n_entries); aix->n_entries = new_aix.n_entries; /* Copy (old) kept archival list entries to replacement list */ if (n_kept > 0) { - memcpy(&aix->list[aix->n_entries], kept_list, sizeof(H5FD_onion_index_entry_t) * n_kept); + H5MM_memcpy(&aix->list[aix->n_entries], kept_list, sizeof(H5FD_onion_index_entry_t) * n_kept); aix->n_entries += n_kept; } |