Keil Logo


4.17 posix_memalign()

Defined in stdlib.h, the posix_memalign() function provides aligned memory allocation.

This function is fully POSIX-compliant.


int posix_memalign(void **memptr, size_t alignment, size_t size);


This function allocates size bytes of memory at an address that is a multiple of alignment.
The value of alignment must be a power of two and a multiple of sizeof(void *).
You can free memory allocated by posix_memalign() using the standard C library free() function.


The returned address is written to the void * variable pointed to by memptr.
The integer return value from the function is zero on success, or an error code on failure.
If no block of memory can be found with the requested size and alignment, the function returns ENOMEM and the value of *memptr is undefined.
Non-ConfidentialPDF file icon PDF versionARM DUI0378H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.