C11 has no requirement that the alignment be a multiple of sizeof(void*), and in fact seems to require any "valid alignment supported by the implementation" to work. since the alignment of char is 1 and thus a valid alignment, an alignment argument of 1 should be accepted.
11 lines
234 B
C
11 lines
234 B
C
#include <stdlib.h>
|
|
#include <errno.h>
|
|
|
|
int posix_memalign(void **res, size_t align, size_t len)
|
|
{
|
|
if (align < sizeof(void *)) return EINVAL;
|
|
void *mem = aligned_alloc(align, len);
|
|
if (!mem) return errno;
|
|
*res = mem;
|
|
return 0;
|
|
}
|