On 7/21/20 1:47 AM, Bruno Haible wrote:
The posix_memalign and memalign functions only help on those platforms where
they exist. It's not possible to emulate posix_memalign or memalign when they
are not present, because when malloc() returned p, we can call free (p)
but not free (p+4) or free (p+8) or similar.
Gnulib has a module 'pagealign_alloc' but it produces a getpagesize() alignment
- not useful (very wasteful) for a 16-bytes alignment.
C11 and C++17 have aligned_alloc, which Emacs uses in preference to
posix_memalign. Is there some reason this new module doesn't use aligned_alloc?
If so, that should be documented; if not, I suggest preferring aligned_alloc to
posix_memalign since aligned_alloc should be available on more systems as the
new standards take hold.
Also, how about naming the new module 'aligned-alloc' and having it implement
aligned_alloc? That would make for more-seamless integration.