[Chapel Merge] Avoid passing 'size=0' to memalign

Branch: refs/heads/main
Revision: 6cf066570478d9f4c7125d617b7532586077b00d
Author: bradcray
Link: Avoid passing 'size=0' to memalign by bradcray · Pull Request #26645 · chapel-lang/chapel · GitHub
Log Message:
Avoid passing 'size=0' to memalign (#26645)

[reviewed by @mppf]

With our current version of valgrind (3.20.0), we're getting a complaint
about sending a size of 0 into memalign(). This PR addresses that by:

  • having our memalign wrapper return 'NULL' if a size of 0 is passsed in
    rather than calling memalign()
  • updating the post-malloc checks to avoid calling them when the
    returned pointer is NULL if the size was 0

Compare: Comparing fc9a2910047eaf885118ac9d507611558912da9b...2d5f48a6f7dd8e5ed6e6254b4c2db31959a55aa5 · chapel-lang/chapel · GitHub

Diff:
M runtime/include/chpl-mem-hook.h
M runtime/include/chpl-mem-sys.h
https://github.com/chapel-lang/chapel/pull/26645.diff