mirror of
https://github.com/cc65/cc65.git
synced 2025-01-03 16:33:19 +00:00
Merge branch 'master' of http://github.com/cc65/cc65
This commit is contained in:
commit
c32846dc6e
@ -75,7 +75,7 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test alignment: is it a power of two? There must be only one bit set. */
|
/* Test alignment: is it a power of two? There must be only one bit set. */
|
||||||
if (alignment == 0 || (alignment & --alignment) != 0) {
|
if (alignment == 0 || (alignment & (alignment - 1)) != 0) {
|
||||||
*memptr = NULL;
|
*memptr = NULL;
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size)
|
|||||||
** overhead added one time; and, the worst thing that might happen is that
|
** overhead added one time; and, the worst thing that might happen is that
|
||||||
** we cannot free the upper and lower blocks.
|
** we cannot free the upper and lower blocks.
|
||||||
*/
|
*/
|
||||||
b = malloc (size + alignment);
|
b = malloc (--alignment + size);
|
||||||
|
|
||||||
/* Handle out-of-memory */
|
/* Handle out-of-memory */
|
||||||
if (b == NULL) {
|
if (b == NULL) {
|
||||||
@ -169,6 +169,3 @@ int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size)
|
|||||||
|
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user