diff options
author | David Young <dyoung@hdfgroup.org> | 2022-03-18 21:04:21 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2022-03-18 21:04:21 (GMT) |
commit | 14dd1f5440730842dcacb4d47e2e4c755c1c333b (patch) | |
tree | 4d1866af5cf39a872f12bee69c58231e298fa0c4 | |
parent | 3b9b61adde53f40189d665650a5ffe62a4f025e8 (diff) | |
download | hdf5-feature/alignment.zip hdf5-feature/alignment.tar.gz hdf5-feature/alignment.tar.bz2 |
Per discussion, use HD and add comments.feature/alignment
-rw-r--r-- | src/H5Tvlen.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 59c3e19..9202767 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -377,7 +377,10 @@ H5T__vlen_mem_seq_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, si HDassert(_vl); HDassert(len); - memcpy(&vl, _vl, sizeof(hvl_t)); + /* Copy to ensure correct alignment. memcpy is best here because + * it optimizes to fast code. + */ + HDmemcpy(&vl, _vl, sizeof(hvl_t)); *len = vl.len; @@ -405,7 +408,8 @@ H5T__vlen_mem_seq_getptr(void *_vl) /* check parameters, return result */ HDassert(_vl); - memcpy(&vl, _vl, sizeof(hvl_t)); + /* Copy to ensure correct alignment. */ + HDmemcpy(&vl, _vl, sizeof(hvl_t)); FUNC_LEAVE_NOAPI(vl.p) } /* end H5T__vlen_mem_seq_getptr() */ @@ -432,7 +436,8 @@ H5T__vlen_mem_seq_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hb /* Check parameters */ HDassert(_vl); - memcpy(&vl, _vl, sizeof(hvl_t)); + /* Copy to ensure correct alignment. */ + HDmemcpy(&vl, _vl, sizeof(hvl_t)); *isnull = ((vl.len == 0 || vl.p == NULL) ? TRUE : FALSE); @@ -493,7 +498,8 @@ H5T__vlen_mem_seq_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, /* check parameters, copy data */ HDassert(buf); HDassert(_vl); - memcpy(&vl, _vl, sizeof(hvl_t)); + /* Copy to ensure correct alignment. */ + HDmemcpy(&vl, _vl, sizeof(hvl_t)); HDassert(vl.p); H5MM_memcpy(buf, vl.p, len); @@ -577,7 +583,8 @@ H5T__vlen_mem_str_getlen(H5VL_object_t H5_ATTR_UNUSED *file, const void *_vl, si /* check parameters */ HDassert(_vl); - memcpy(&s, _vl, sizeof(char *)); + /* Copy to ensure correct alignment. */ + HDmemcpy(&s, _vl, sizeof(char *)); *len = HDstrlen(s); @@ -605,7 +612,8 @@ H5T__vlen_mem_str_getptr(void *_vl) /* check parameters */ HDassert(_vl); - memcpy(&s, _vl, sizeof(char *)); + /* Copy to ensure correct alignment. */ + HDmemcpy(&s, _vl, sizeof(char *)); FUNC_LEAVE_NOAPI(s) } /* end H5T__vlen_mem_str_getptr() */ @@ -629,7 +637,8 @@ H5T__vlen_mem_str_isnull(const H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, hb FUNC_ENTER_STATIC_NOERR - memcpy(&s, _vl, sizeof(char *)); + /* Copy to ensure correct alignment. */ + HDmemcpy(&s, _vl, sizeof(char *)); *isnull = (s == NULL ? TRUE : FALSE); @@ -684,7 +693,8 @@ H5T__vlen_mem_str_read(H5VL_object_t H5_ATTR_UNUSED *file, void *_vl, void *buf, /* check parameters */ HDassert(buf); HDassert(_vl); - memcpy(&s, _vl, sizeof(char *)); + /* Copy to ensure correct alignment. */ + HDmemcpy(&s, _vl, sizeof(char *)); H5MM_memcpy(buf, s, len); } /* end if */ |