| 1 |
'\" t |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.TH memalign 3 2025-12-13 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
memalign |
| 9 |
\- |
| 10 |
allocate aligned memory |
| 11 |
.SH LIBRARY |
| 12 |
Standard C library |
| 13 |
.RI ( libc ,\~ \-lc ) |
| 14 |
.SH SYNOPSIS |
| 15 |
.nf |
| 16 |
.B #include <malloc.h> |
| 17 |
.P |
| 18 |
.BI "[[deprecated]] void *memalign(size_t " alignment ", size_t " size ); |
| 19 |
.fi |
| 20 |
.SH DESCRIPTION |
| 21 |
.BR memalign () |
| 22 |
is equivalent to |
| 23 |
.BR aligned_alloc (3), |
| 24 |
except for the CAVEATS documented below. |
| 25 |
.\" The behavior of memalign() for size==0 is as for posix_memalign() |
| 26 |
.\" but no standards govern this. |
| 27 |
.SH ATTRIBUTES |
| 28 |
For an explanation of the terms used in this section, see |
| 29 |
.BR attributes (7). |
| 30 |
.TS |
| 31 |
allbox; |
| 32 |
lbx lb lb |
| 33 |
l l l. |
| 34 |
Interface Attribute Value |
| 35 |
T{ |
| 36 |
.na |
| 37 |
.nh |
| 38 |
.BR memalign () |
| 39 |
T} Thread safety MT-Safe |
| 40 |
.TE |
| 41 |
.SH VERSIONS |
| 42 |
On some systems |
| 43 |
.BR memalign () |
| 44 |
is declared in |
| 45 |
.I <stdlib.h> |
| 46 |
instead of |
| 47 |
.IR <malloc.h> . |
| 48 |
.SH STANDARDS |
| 49 |
None. |
| 50 |
.SH HISTORY |
| 51 |
glibc 2.0. |
| 52 |
SunOS 4.1.3. |
| 53 |
.SH CAVEATS |
| 54 |
.BR memalign () |
| 55 |
may not check that the |
| 56 |
.I alignment |
| 57 |
argument is correct. |
| 58 |
.P |
| 59 |
Some systems provide no way to reclaim memory allocated with |
| 60 |
.BR memalign () |
| 61 |
(because one can pass to |
| 62 |
.BR free (3) |
| 63 |
only a pointer obtained from |
| 64 |
.BR malloc (3), |
| 65 |
while, for example, |
| 66 |
.BR memalign () |
| 67 |
would call |
| 68 |
.BR malloc (3) |
| 69 |
and then align the obtained value). |
| 70 |
The glibc implementation |
| 71 |
allows memory obtained from |
| 72 |
.BR memalign () |
| 73 |
to be reclaimed with |
| 74 |
.BR free (3). |
| 75 |
.SH SEE ALSO |
| 76 |
.BR aligned_alloc (3) |