Skip to content

Commit 1146b45

Browse files
Fixed aligned_alloc for Android API < 16. Issue #49. Thanks @zhaijialong !
1 parent 7a6e442 commit 1146b45

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/vk_mem_alloc.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,19 @@ remove them if not needed.
27982798
#define VMA_NULL nullptr
27992799
#endif
28002800

2801-
#if defined(__APPLE__) || defined(__ANDROID__)
2801+
#if defined(__ANDROID_API__) && (__ANDROID_API__ < 16)
2802+
#include <cstdlib>
2803+
void *aligned_alloc(size_t alignment, size_t size)
2804+
{
2805+
// alignment must be >= sizeof(void*)
2806+
if(alignment < sizeof(void*))
2807+
{
2808+
alignment = sizeof(void*);
2809+
}
2810+
2811+
return memalign(alignment, size);
2812+
}
2813+
#elif defined(__APPLE__) || defined(__ANDROID__)
28022814
#include <cstdlib>
28032815
void *aligned_alloc(size_t alignment, size_t size)
28042816
{

0 commit comments

Comments
 (0)