| 1673 | } |
| 1674 | |
| 1675 | void* |
| 1676 | rpaligned_alloc(size_t alignment, size_t size) { |
| 1677 | if (alignment <= 16) |
| 1678 | return rpmalloc(size); |
| 1679 | |
| 1680 | #if ENABLE_VALIDATE_ARGS |
| 1681 | if (size + alignment < size) { |
| 1682 | errno = EINVAL; |
| 1683 | return 0; |
| 1684 | } |
| 1685 | #endif |
| 1686 | |
| 1687 | void* ptr = rpmalloc(size + alignment); |
| 1688 | if ((uintptr_t)ptr & (alignment - 1)) |
| 1689 | ptr = (void*)(((uintptr_t)ptr & ~((uintptr_t)alignment - 1)) + alignment); |
| 1690 | return ptr; |
| 1691 | } |
| 1692 | |
| 1693 | void* |
| 1694 | rpmemalign(size_t alignment, size_t size) { |
no test coverage detected