X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Faligned_malloc.c;h=b345ad1e586c209556c6e4fb6f8eba82c076d19f;hb=4361b69d3178d7fc98d0388f9a223af6c2651aba;hp=4db92a41813bc3a969daa5ea31e6909deded1876;hpb=8afc01a67be4fbf3f1cc0fce9adf01b5289a21c6;p=xscreensaver diff --git a/utils/aligned_malloc.c b/utils/aligned_malloc.c index 4db92a41..b345ad1e 100644 --- a/utils/aligned_malloc.c +++ b/utils/aligned_malloc.c @@ -18,11 +18,13 @@ implied warranty. #include #include -#if !(_POSIX_VERSION >= 200112L || _XOPEN_VERSION >= 600) - #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