mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-08 00:09:31 +03:00
Return EINVAL when alignment is not a power of 2 to match posix standard
This commit is contained in:
parent
5dfced26c2
commit
d146984a91
1 changed files with 1 additions and 1 deletions
|
@ -135,7 +135,7 @@ int posix_memalign(void** p, size_t alignment, size_t size) {
|
|||
// TODO: the spec says we should return EINVAL also if alignment is not a power of 2.
|
||||
// The spec also dictates we should not modify `*p` on an error. (issue#27)
|
||||
// <http://man7.org/linux/man-pages/man3/posix_memalign.3.html>
|
||||
if (alignment % sizeof(void*) != 0) return EINVAL; // no `p==NULL` check as it is declared as non-null
|
||||
if ((alignment % sizeof(void*))||(alignment % 2) != 0) return EINVAL; // no `p==NULL` check as it is declared as non-null
|
||||
void* q = mi_malloc_aligned(size, alignment);
|
||||
if (q==NULL && size != 0) return ENOMEM;
|
||||
*p = q;
|
||||
|
|
Loading…
Add table
Reference in a new issue