]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Support for posix_memalign in FreeBSD 11. #873
authorNathan Moinvaziri <nathan@nathanm.com>
Sat, 20 Mar 2021 03:45:13 +0000 (20:45 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sat, 20 Mar 2021 22:36:16 +0000 (23:36 +0100)
Co-authored-by: Hans Kristian Rosbach <hk-git@circlestorm.org>
Co-authored-by: concatime <concatime@users.noreply@github.com>
zutil_p.h

index a5f2e525d14beeb87c25eb4e1445fbf0ea21ff9d..7dc2e3d353002447eb7c208633f1819511de1fee 100644 (file)
--- a/zutil_p.h
+++ b/zutil_p.h
@@ -7,13 +7,19 @@
 
 #ifdef __APPLE__
 #  include <stdlib.h>
+#elif defined(__FreeBSD__)
+#  include <stdlib.h>
+#  include <malloc_np.h>
 #else
 #  include <malloc.h>
 #endif
 
 /* Function to allocate 16 or 64-byte aligned memory */
 static inline void *zng_alloc(size_t size) {
-#if defined(_WIN32)
+#if defined(__FreeBSD__)
+    void *ptr;
+    return posix_memalign(&ptr, 64, size) ? NULL : ptr;
+#elif defined(_WIN32)
     return (void *)_aligned_malloc(size, 64);
 #elif defined(__APPLE__)
     return (void *)malloc(size);     /* MacOS always aligns to 16 bytes */