X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=utils%2Faligned_malloc.c;h=b345ad1e586c209556c6e4fb6f8eba82c076d19f;hp=c805b9e089c3b7270e7e04bac46d49dc49bcfb8d;hb=4361b69d3178d7fc98d0388f9a223af6c2651aba;hpb=d6b0217f2417bd19187f0ebc389d6c5c2233b11c diff --git a/utils/aligned_malloc.c b/utils/aligned_malloc.c index c805b9e0..b345ad1e 100644 --- a/utils/aligned_malloc.c +++ b/utils/aligned_malloc.c @@ -18,11 +18,13 @@ implied warranty. #include #include -#if !ALIGNED_MALLOC_HAS_MEMALIGN - #include #include +/* aligned_alloc() (C11) or posix_memalign() (POSIX) are other possibilities + for aligned_malloc(). + */ + int aligned_malloc(void **ptr, unsigned alignment, size_t size) { void *block_start; @@ -41,7 +43,6 @@ int aligned_malloc(void **ptr, unsigned alignment, size_t size) void aligned_free(void *ptr) { - free(((void **)(ptr))[-1]); + if(ptr) + free(((void **)(ptr))[-1]); } - -#endif