mesa: posix_memalign requires alignment to be multiple of sizeof(void*)
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Thu, 14 Aug 2008 09:10:53 +0000 (10:10 +0100)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Thu, 14 Aug 2008 10:01:42 +0000 (11:01 +0100)
src/gallium/include/pipe/p_util.h

index 4e1a996122d21f11481c63bd5b1d1153185655f0..b4ab70a3fc86ca3e00fe99bfac3ba45c182757d9 100644 (file)
@@ -213,6 +213,7 @@ align_malloc(size_t bytes, uint alignment)
 {
 #if defined(HAVE_POSIX_MEMALIGN)
    void *mem;
+   alignment = (alignment + (uint)sizeof(void*) - 1) & ~((uint)sizeof(void*) - 1);
    if(posix_memalign(& mem, alignment, bytes) != 0)
       return NULL;
    return mem;