mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Fix align_malloc on Linux (#645)
posix_memalign requires alignment to be a power of two and a multiple of sizeof(void*). All powers of two greater than sizeof(void*) are multiples of sizeof(void*) so we only need to make sure sizeof(void*) is the minimum value passed to posix_memalign. Fixes #644 Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
@@ -40,6 +40,9 @@ static void * align_malloc(size_t size, size_t alignment)
|
||||
if ( ptr )
|
||||
return ptr;
|
||||
#else
|
||||
if (alignment < sizeof(void*)) {
|
||||
alignment = sizeof(void*);
|
||||
}
|
||||
if (0 == posix_memalign(&ptr, alignment, size))
|
||||
return ptr;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user