|
|
@node aligned_alloc |
|
|
@subsection @code{aligned_alloc} |
|
|
@findex aligned_alloc |
|
|
|
|
|
ISO C23 specification:@* @url{https: |
|
|
|
|
|
POSIX specification:@* @url{https: |
|
|
|
|
|
Documentation:@* @uref{https: |
|
|
|
|
|
Gnulib module: aligned_alloc |
|
|
@mindex aligned_alloc |
|
|
|
|
|
Portability problems fixed by Gnulib: |
|
|
@itemize |
|
|
@item |
|
|
This function fails if the alignment argument is smaller than |
|
|
@code{sizeof (void *)} on some platforms: |
|
|
macOS 14, AIX 7.3.1. |
|
|
|
|
|
@item |
|
|
This function returns a null pointer if the requested size is |
|
|
not a multiple of the alignment: |
|
|
Solaris 11.4. |
|
|
|
|
|
@item |
|
|
This function returns a null pointer if the size argument is zero: |
|
|
macOS 15, AIX 7.3, Solaris 11.4. |
|
|
|
|
|
@item |
|
|
On some platforms, @code{aligned_alloc} crashes if the requested size is |
|
|
not a multiple of the alignment: |
|
|
AddressSanitizer (gcc 11.2 or clang 13). |
|
|
@end itemize |
|
|
|
|
|
Portability problems not fixed by Gnulib: |
|
|
@itemize |
|
|
@item |
|
|
This function is missing on many older platforms: |
|
|
glibc 2.15, macOS 10.14, FreeBSD 6.4, NetBSD 7.1, OpenBSD 6.0, Minix 3.1.8, AIX 7.1, HP-UX 11.31, Solaris 11.3, Cygwin 1.7.x, mingw, MSVC 14, Android 8.1. |
|
|
|
|
|
@item |
|
|
If the alignment and size are absurdly large, this function crashes: |
|
|
@c https: |
|
|
glibc 2.42. |
|
|
@end itemize |
|
|
|
|
|
Gnulib has partial substitutes for @code{aligned_alloc} |
|
|
that do not crash even if the AddressSanitizer bug is present: |
|
|
|
|
|
@itemize |
|
|
@item |
|
|
@mindex alignalloc |
|
|
The Gnulib module @code{alignalloc} provides a portable function |
|
|
@code{alignalloc} that is a near-substitute for glibc |
|
|
@code{aligned_alloc}, except that the result must be freed |
|
|
with @code{alignfree} rather than plain @code{free}. |
|
|
|
|
|
@item |
|
|
@mindex aligned-malloc |
|
|
The Gnulib module @code{aligned-malloc} provides functions for |
|
|
allocating and freeing blocks of suitably aligned memory. |
|
|
|
|
|
@item |
|
|
@mindex pagealign_alloc |
|
|
The Gnulib module @code{pagealign_alloc} provides a similar API for |
|
|
allocating and freeing blocks of memory aligned on a system page boundary. |
|
|
@end itemize |
|
|
|