Made aligned_alloc produce aligned values.

Previous implementation of aligned_alloc met the specification, but was
not particularly useful.  This uses the same implementation for
alligned_alloc and memalign.
This commit is contained in:
Matthew Parkinson
2020-01-08 15:25:29 +00:00
parent 1fd4ddd23e
commit 5786ecc3cf

View File

@@ -104,14 +104,6 @@ extern "C"
}
#endif
SNMALLOC_EXPORT void*
SNMALLOC_NAME_MANGLE(aligned_alloc)(size_t alignment, size_t size)
{
assert((size % alignment) == 0);
(void)alignment;
return SNMALLOC_NAME_MANGLE(malloc)(size);
}
inline size_t aligned_size(size_t alignment, size_t size)
{
// Client responsible for checking alignment is not zero
@@ -159,6 +151,13 @@ extern "C"
return SNMALLOC_NAME_MANGLE(malloc)(aligned_size(alignment, size));
}
SNMALLOC_EXPORT void*
SNMALLOC_NAME_MANGLE(aligned_alloc)(size_t alignment, size_t size)
{
assert((size % alignment) == 0);
return SNMALLOC_NAME_MANGLE(memalign)(alignment, size);
}
SNMALLOC_EXPORT int SNMALLOC_NAME_MANGLE(posix_memalign)(
void** memptr, size_t alignment, size_t size)
{