15 void *al_malloc(size_t alignment
, size_t size
)
17 #if defined(HAVE_ALIGNED_ALLOC)
18 size
= (size
+(alignment
-1))&~(alignment
-1);
19 return aligned_alloc(alignment
, size
);
20 #elif defined(HAVE_POSIX_MEMALIGN)
22 if(posix_memalign(&ret
, alignment
, size
) == 0)
25 #elif defined(HAVE__ALIGNED_MALLOC)
26 return _aligned_malloc(size
, alignment
);
28 char *ret
= malloc(size
+alignment
);
32 while(((ptrdiff_t)ret
&(alignment
-1)) != 0)
39 void *al_calloc(size_t alignment
, size_t size
)
41 void *ret
= al_malloc(alignment
, size
);
42 if(ret
) memset(ret
, 0, size
);
46 void al_free(void *ptr
)
48 #if defined(HAVE_ALIGNED_ALLOC) || defined(HAVE_POSIX_MEMALIGN)
50 #elif defined(HAVE__ALIGNED_MALLOC)
58 } while(*finder
== 0x55);