From d8e18e0011587b6c8ad95b4dd12c8ea9c5065497 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 6 Sep 2018 16:30:22 -0400 Subject: [PATCH] aligned_alloc is now the same as BSD memalign The resolution to DR 460 (which is explicitly included in C17) removed the requirement for the size to be a multiple of the alignment. --- malloc.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/malloc.c b/malloc.c index f3513a2..ef417b6 100644 --- a/malloc.c +++ b/malloc.c @@ -909,20 +909,12 @@ EXPORT int h_posix_memalign(void **memptr, size_t alignment, size_t size) { } EXPORT void *h_aligned_alloc(size_t alignment, size_t size) { - if (size % alignment) { - errno = EINVAL; - return NULL; - } init(); size = adjust_size_for_canaries(size); return alloc_aligned_simple(alignment, size); } -EXPORT void *h_memalign(size_t alignment, size_t size) { - init(); - size = adjust_size_for_canaries(size); - return alloc_aligned_simple(alignment, size); -} +EXPORT void *h_memalign(size_t alignment, size_t size) ALIAS(h_aligned_alloc); EXPORT void *h_valloc(size_t size) { init();