1.\" 2.\" This file and its contents are supplied under the terms of the 3.\" Common Development and Distribution License ("CDDL"), version 1.0. 4.\" You may only use this file in accordance with the terms of version 5.\" 1.0 of the CDDL. 6.\" 7.\" A full copy of the text of the CDDL should have accompanied this 8.\" source. A copy of the CDDL is also available via the Internet at 9.\" http://www.illumos.org/license/CDDL. 10.\" 11.\" 12.\" Copyright 2016 Joyent, Inc. 13.\" 14.Dd May 11, 2024 15.Dt ALIGNED_ALLOC 3C 16.Os 17.Sh NAME 18.Nm aligned_alloc 19.Nd aligned memory allocation 20.Sh SYNOPSIS 21.In stdlib.h 22.Ft "void *" 23.Fo aligned_alloc 24.Fa "size_t alignment" 25.Fa "size_t size" 26.Fc 27.Sh DESCRIPTION 28The 29.Fn aligned_alloc 30function allocates 31.Fa size 32bytes aligned on the specified alignment boundary 33.Fa alignment . 34The value of 35.Fa alignment 36is constrained: it must be a power of two. 37.Sh RETURN VALUES 38Upon successful completion, the 39.Fn aligned_alloc 40function returns a pointer to suitably aligned memory at least 41.Fa size 42bytes large. 43Otherwise, a 44.Sy NULL 45pointer is returned and 46.Sy errno 47is set to indicate the error. 48.Sh ERRORS 49The 50.Fn aligned_alloc 51function will fail if: 52.Bl -tag -width Er 53.It Er ENOMEM 54The physical limits of the system are exceeded by 55.Fa size 56bytes of memory which cannot be allocated. 57.It Er EAGAIN 58There is not enough memory available to allocate 59.Fa size 60bytes of memory; but the application could try again later. 61.It Er EINVAL 62An invalid value for 63.Fa alignment 64was passed in. 65It is not a power of two. 66.El 67.Sh INTERFACE STABILITY 68.Sy Comitted 69.Sh MT-LEVEL 70.Sy MT-Safe 71.Sh SEE ALSO 72.Xr malloc 3C , 73.Xr memalign 3C , 74.Xr posix_memalign 3C , 75.Xr attributes 7 76