Closed mulimoen closed 2 years ago
Thanks @aldanor for reviewing this. Align checks are for casting to pointer-to-pointer, e.g. error: casting from *mut u8
to a more-strictly-aligned pointer (*mut *const u8
) (1 < 8 bytes). Could be I have misunderstood some of this code, quite a lot of tricky pointer logic there.
Given that we allocate memory either via libc::malloc
, whose man states:
The
malloc()
andcalloc()
functions return a pointer to the allocated memory that is suitably aligned for any kind of variable.
Or via H5allocate_memory
:
H5MM_malloc
HDmalloc
malloc
=> all good, no checks neededH5MM_block_t
block via HDmalloc
(so blocks are 8-byte aligned at the very least)H5MM_HEAD_GUARD_SIZE = 8
, so each block start is 8-byte aligneddouble _align; /* Align following buffer (b) to double boundary (unused) */
=> in whichever case, 8-byte alignment is pretty much guaranteed and we don't need to check it ourselves?
That is some great detective work @aldanor! I would also not expect to see any alignment issues as allocations in C
tends to be very conservative, so it's great that we can remove these checks
Great, thanks!
@mulimoen Thanks for taking care of all this - many lints actually make sense - e.g. there was some old code that couldn't use
[T; N]
deriving Clone for allN
so we had to do it manually, etc.There's a few things I've pointed out that are questionable: