From f44305429c35dac4c049e7895131b429b2782d0a Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Wed, 28 Feb 2018 11:24:46 +0100 Subject: [PATCH] Fix for aligned_alloc for Apple MolenVK. Thanks @rextimmy ! --- src/vk_mem_alloc.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/vk_mem_alloc.h b/src/vk_mem_alloc.h index 24d4a44..349b83f 100644 --- a/src/vk_mem_alloc.h +++ b/src/vk_mem_alloc.h @@ -1747,9 +1747,16 @@ remove them if not needed. #include void *aligned_alloc(size_t alignment, size_t size) { + // alignment must be >= sizeof(void*) + if(alignment < sizeof(void*)) + { + alignment = sizeof(void*); + } + void *pointer; - posix_memalign(&pointer, alignment, size); - return pointer; + if(posix_memalign(&pointer, alignment, size) == 0) + return pointer; + return VMA_NULL; } #endif